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

AssertionError with ToolProvider.getSystemJavaCompiler and -proc:only

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • tbd
    • 11, 14
    • tools
    • 11
    • generic
    • generic

    Description

      This bug was originally reported at AdoptOpenJDK here and has all the details:
      https://github.com/AdoptOpenJDK/openjdk-build/issues/1309

      There appears to be a regression from JDK 8 in the annotation processing engine related to modules. The reproducer works on OpenJDK 8u212-b10, but fails with JDK 11.0.4+11 and better (including JDK head) with -proc:only.

      Steps to reproduce:
      $ git clone https://github.com/jerboaa/JDKCompilerBug.git bug
      $ cd bug
      $ mvn clean package
      $ java -showversion -cp target/jdkcompiler-1.0-SNAPSHOT.jar com.bilalekrem.jdkcompiler.Main true
      openjdk version "14-internal" 2020-03-17
      OpenJDK Runtime Environment (fastdebug build 14-internal+0-adhoc.sgehwolf.openjdk-head)
      OpenJDK 64-Bit Server VM (fastdebug build 14-internal+0-adhoc.sgehwolf.openjdk-head, mixed mode, sharing)
      java.lang.AssertionError
      at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
      at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
      at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:247)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.readSourceFile(JavaCompiler.java:836)
      at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ImplicitCompleter.complete(JavacProcessingEnvironment.java:1576)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:657)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1356)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.apiComplete(Symbol.java:663)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.getKind(Symbol.java:1424)
      at com.bilalekrem.jdkcompiler.Main.getKind(Main.java:85)
      at com.bilalekrem.jdkcompiler.Main.main(Main.java:58)
      Printing element kind
      Multiple: -- resulted: true
      Single: -- resulted: false
      Exception in thread "main" java.lang.RuntimeException: Test failed!
      at com.bilalekrem.jdkcompiler.Main.main(Main.java:63)

      Actual:

      java.lang.AssertionError
      at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
      at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
      at jdk.compiler/com.sun.tools.javac.comp.Modules.enter(Modules.java:247)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.readSourceFile(JavaCompiler.java:836)
      at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ImplicitCompleter.complete(JavacProcessingEnvironment.java:1576)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:657)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1356)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.apiComplete(Symbol.java:663)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.getKind(Symbol.java:1424)
      at com.bilalekrem.jdkcompiler.Main.getKind(Main.java:85)
      at com.bilalekrem.jdkcompiler.Main.main(Main.java:58)
      Printing element kind
      Multiple: -- resulted: true
      Single: -- resulted: false
      Exception in thread "main" java.lang.RuntimeException: Test failed!
      at com.bilalekrem.jdkcompiler.Main.main(Main.java:63)

      Expected (with JDK 8):
      $ java -showversion -cp target/jdkcompiler-1.0-SNAPSHOT.jar com.bilalekrem.jdkcompiler.Main true
      openjdk version "1.8.0_222"
      OpenJDK Runtime Environment (build 1.8.0_222-b10)
      OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

      Printing element kind
      Multiple: -- resulted: true
      Single: -- resulted: true
      Test passed!

      Note that passing "false" or no-arg to the reproducer, in which case -proc:only isn't set, the reproducer passes with jdk head:

      java -showversion -cp target/jdkcompiler-1.0-SNAPSHOT.jar com.bilalekrem.jdkcompiler.Main false
      openjdk version "14-internal" 2020-03-17
      OpenJDK Runtime Environment (fastdebug build 14-internal+0-adhoc.sgehwolf.openjdk-head)
      OpenJDK 64-Bit Server VM (fastdebug build 14-internal+0-adhoc.sgehwolf.openjdk-head, mixed mode, sharing)
      Printing element kind
      Multiple: -- resulted: true
      Single: -- resulted: true
      Test passed!

      Attachments

        Activity

          People

            jlahoda Jan Lahoda
            sgehwolf Severin Gehwolf
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: