Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8340655

Source launcher fails on GraalVM 23 with preview enabled

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: External
    • Icon: P4 P4
    • 24
    • None
    • tools
    • b18

      Running `java --enable-preview T.java` with GraalVM 23 yields (GraalVM 17, 21, and 22 are not affected):
      ```
      error: exporting a package from system module java.base is not allowed with --release
      1 error
      error: compilation failed
      ```
      With T.java reading:
      ```
      public class T {
          public static void main(String... args) {
              System.out.println("hello world");
          }
      }
      ```

      The problem appears to be that, when --enable-preview is used, --release is automatically added when no `--source` is given on the command-line: https://bugs.openjdk.org/browse/JDK-8323605

      The `java` launcher bundled in GraalVM is primed to use various launcher options, including: `--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler`. The source launcher will then try to use `--add-exports=java.base/jdk.internal.misc=jdk.graal.compiler` as an option to `javac` when compiling the source, but `--add-exports=java.base/...` is incompatible with `--release`.

      Note that the original implementation of JEP 330 "Launch single-file source-code programs" already replaced `--source N` with `--release N` via https://github.com/openjdk/jdk11u/blob/0358cbd0a1538937612e3a78ffbfb64d7f4c45a2/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java#L287

      This is the commit in GraalVM that introduced the `--add-exports=java.base/...` option https://github.com/oracle/graal/commit/65eb7a532b572199f2b6758b6051a4ce5d855899

            dnsimon Douglas Simon
            cstein Christian Stein
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: