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

ClassNotFoundException: javax.annotation.Generated, while doing annotation processing in post-Jigsaw build

XMLWordPrintable

      JMH, as many other annotation processors, are using @Generated annotation to mark classes emitted by the JMH itself, as mentioned in the docs:
       https://docs.oracle.com/javase/8/docs/api/javax/annotation/Generated.html

      This annotation is coming from JSR 250 "Common Annotations", and should be available for Java SE users. However, starting from jdk9 b111 (the one where Jigsaw had integrated), JMH builds fail with:

      [WARNING] /home/shade/benchmarks/indy-concat-bench/src/main/java/org/openjdk/LinkageBench.java:[4,15] Unsafe is internal proprietary API and may be removed in a future release
      [WARNING] at org.openjdk.jmh.generators.core.BenchmarkGenerator.generateImport(BenchmarkGenerator.java:582)
         at org.openjdk.jmh.generators.core.BenchmarkGenerator.generateClass(BenchmarkGenerator.java:540)
         at org.openjdk.jmh.generators.core.BenchmarkGenerator.generate(BenchmarkGenerator.java:94)
         at org.openjdk.jmh.generators.BenchmarkProcessor.process(BenchmarkProcessor.java:58)
         at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(jdk.compiler@9-ea/JavacProcessingEnvironment.java:958)
         at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(jdk.compiler@9-ea/JavacProcessingEnvironment.java:874)
         at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2100(jdk.compiler@9-ea/JavacProcessingEnvironment.java:106)
         at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(jdk.compiler@9-ea/JavacProcessingEnvironment.java:1181)
         at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(jdk.compiler@9-ea/JavacProcessingEnvironment.java:1289)
         at com.sun.tools.javac.main.JavaCompiler.processAnnotations(jdk.compiler@9-ea/JavaCompiler.java:1229)
         at com.sun.tools.javac.main.JavaCompiler.compile(jdk.compiler@9-ea/JavaCompiler.java:903)
         at com.sun.tools.javac.main.Main.compile(jdk.compiler@9-ea/Main.java:261)
         at com.sun.tools.javac.main.Main.compile(jdk.compiler@9-ea/Main.java:143)
         at com.sun.tools.javac.Main.compile(jdk.compiler@9-ea/Main.java:55)
         at com.sun.tools.javac.Main.main(jdk.compiler@9-ea/Main.java:41)
        Caused by: java.lang.ClassNotFoundException: javax.annotation.Generated
         at java.net.URLClassLoader.findClass(java.base@9-ea/URLClassLoader.java:384)
         at java.lang.ClassLoader.loadClass(java.base@9-ea/ClassLoader.java:486)
         at java.lang.ClassLoader.loadClass(java.base@9-ea/ClassLoader.java:419)
         ... 15 more

      [ERROR] COMPILATION ERROR :
      [INFO] -------------------------------------------------------------
      [ERROR] error: Annotation generator had thrown the exception. java.lang.NoClassDefFoundError: javax/annotation/Generated
      [INFO] 1 error
      [INFO] -------------------------------------------------------------

      I think this is caused by module system misconfiguration?

            jjg Jonathan Gibbons
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: