Skip to content

Using -release option instead of -target can break compilation #12824

Closed as not planned
@eejbyfeldt

Description

@eejbyfeldt

Reproduction steps

Scala version: 2.13.11
Java version: 17.0.7

$ cat import_sun.scala
import sun._
$ scalac -deprecation -target:8 import_sun.scala
warning: -target is deprecated: Use -release instead to compile against the correct platform API.
1 warning
$ scalac -release:8 import_sun.scala
import_sun.scala:1: error: not found: object sun
import sun._
       ^
1 error

Problem

Compiling with the -target flag gives a deprecation warning suggesting to use -release instead. But switching using -release means that the code no longer compiles.

If this is the intended behavior maybe the deprecation warnings/documentation should include more information of the differences between -target and -release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions