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

javac fails with an exception when compiling import module under source level 8

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 23, 24
    • tools
    • None
    • b20

      Consider code like this:
      ---
      package test;

      import module java.base;

      public class Test {
          List<String> l;
      }
      ---

      When this is compiled with '--source 8 -XDshould-stop.at=FLOW`, this crashes javac:
      ---
      $ javac --source 8 -XDshould-stop.at=FLOW -XDdev /tmp/Test.java
      warning: [options] bootstrap class path is not set in conjunction with -source 8
        not setting the bootstrap class path may lead to class files that cannot run on JDK 8
          --release 8 is recommended instead of -source 8 because it sets the bootstrap class path automatically
      warning: [options] source value 8 is obsolete and will be removed in a future release
      warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
      /tmp/Test.java:3: error: module imports are a preview feature and are disabled by default.
      import module java.base;
             ^
        (use --enable-preview to enable module imports)
      1 error
      3 warnings
      An exception has occurred in the compiler (23-internal). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
      java.lang.NullPointerException: Cannot invoke "java.util.Set.contains(Object)" because "this.env.toplevel.modle.readModules" is null
              at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.doModuleImport(TypeEnter.java:477)
              at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.handleImports(TypeEnter.java:414)
              at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.resolveImports(TypeEnter.java:389)
              at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.runPhase(TypeEnter.java:318)
              at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:279)
              at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:248)
              at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:195)
              at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:687)
              at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1455)
              at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:632)
              at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:599)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1077)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:948)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
      printing javac parameters to: /tmp/javac.20240927_093418.args
      ---

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: