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

javac with annotation processor throws AssertionError: Filling jrt:/... during JarFileObject[/...]

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 22
    • 21, 22
    • tools
    • 22
    • b27
    • linux

        On OpenJDK 22-ea+26 (and ea-24/ea-25), with certain project configurations involving an annotation processor, a certain classpath, and anonymous classes, javac fails and throws an AssertionError internally:

        ```
        Caused by: java.lang.AssertionError: Filling jrt:/java.compiler/javax/lang/model/type/TypeMirror.class during JarFileObject[/home/yrodiere/workspaces/testcases/jdk-playground/processor/target/jdk-playground-processor-1.0-SNAPSHOT.jar:/org/hibernate/jpamodelgen/util/TypeUtils$2.class]
            at com.sun.tools.javac.util.Assert.error (Assert.java:162)
            at com.sun.tools.javac.code.ClassFinder.fillIn (ClassFinder.java:366)
            at com.sun.tools.javac.code.ClassFinder.complete (ClassFinder.java:302)
            at com.sun.tools.javac.code.Symbol.complete (Symbol.java:682)
            at com.sun.tools.javac.code.Symbol$ClassSymbol.complete (Symbol.java:1418)
            at com.sun.tools.javac.code.Symbol.apiComplete (Symbol.java:688)
            at com.sun.tools.javac.code.Type$ClassType.getKind (Type.java:1208)
            at com.sun.tools.javac.code.Types$14.combineMetadata (Types.java:2413)
            at com.sun.tools.javac.code.Types$14.visitClassType (Types.java:2453)
            at com.sun.tools.javac.code.Types$14.visitClassType (Types.java:2409)
            at com.sun.tools.javac.code.Type$ClassType.accept (Type.java:1050)
            at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit (Types.java:4903)
            at com.sun.tools.javac.code.Types.erasure (Types.java:2404)
            at com.sun.tools.javac.code.Types.erasure (Types.java:2390)
            at com.sun.tools.javac.jvm.ClassReader.isSameBinaryType (ClassReader.java:1403)
            at com.sun.tools.javac.jvm.ClassReader.findMethod (ClassReader.java:1376)
            at com.sun.tools.javac.jvm.ClassReader.readEnclosingMethodAttr (ClassReader.java:1323)
            at com.sun.tools.javac.jvm.ClassReader$10.read (ClassReader.java:999)
            at com.sun.tools.javac.jvm.ClassReader.readAttrs (ClassReader.java:1435)
            at com.sun.tools.javac.jvm.ClassReader.readClassAttrs (ClassReader.java:1449)
            at com.sun.tools.javac.jvm.ClassReader.readClass (ClassReader.java:2931)
            at com.sun.tools.javac.jvm.ClassReader.readClassBuffer (ClassReader.java:3049)
            at com.sun.tools.javac.jvm.ClassReader.readClassFile (ClassReader.java:3073)
            at com.sun.tools.javac.code.ClassFinder.fillIn (ClassFinder.java:373)
            at com.sun.tools.javac.code.ClassFinder.complete (ClassFinder.java:302)
            at com.sun.tools.javac.code.Symbol.complete (Symbol.java:682)
            at com.sun.tools.javac.code.Symbol$ClassSymbol.complete (Symbol.java:1418)
            at com.sun.tools.javac.code.Symbol.apiComplete (Symbol.java:688)
            at com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements (Symbol.java:859)
            at com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements (Symbol.java:797)
            at org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.process (JPAMetaModelEntityProcessor.java:36)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor (JavacProcessingEnvironment.java:1021)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.runContributingProcs (JavacProcessingEnvironment.java:857)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run (JavacProcessingEnvironment.java:1263)
            at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing (JavacProcessingEnvironment.java:1402)
            at com.sun.tools.javac.main.JavaCompiler.processAnnotations (JavaCompiler.java:1276)
            at com.sun.tools.javac.main.JavaCompiler.compile (JavaCompiler.java:946)
            at com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0 (JavacTaskImpl.java:104)
            at com.sun.tools.javac.api.JavacTaskImpl.invocationHelper (JavacTaskImpl.java:152)
            at com.sun.tools.javac.api.JavacTaskImpl.doCall (JavacTaskImpl.java:100)
            at com.sun.tools.javac.api.JavacTaskImpl.call (JavacTaskImpl.java:94)
            at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess (JavaxToolsCompiler.java:126)
            at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile (JavacCompiler.java:174)
            at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1134)
            at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:187)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
            at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
            at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
            at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
            at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
            at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
            at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
            at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
            at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
            at java.lang.reflect.Method.invoke (Method.java:580)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
            at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
            at java.lang.reflect.Method.invoke (Method.java:580)
            at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
            at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
            at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)
        ```

        We've been experiencing this on Hibernate ORM while testing against JDK 22-ea+24 and later (ea+25 and ea+26 also affected); see the currently failing CI build at https://ci.hibernate.org/job/hibernate-orm-pipeline/job/main/

        Since Hibernate ORM is a relatively large codebase and not very convenient for this sort of debugging, I came up with a minimal reproducer: see https://github.com/yrodiere/jdk-playground/tree/assertion-error-annotation-processor-jdk-22 and its readme.

        Reproducing this problem seems to require a rather specific setup. The reproducer is still a bit complex but that's the best I could do; I wasn't able to remove/change anything more without eliminating the problem.

        To run the reproducer (requires OpenJDK 21+, fails only on OpenJDK 22):

        ```
        git clone https://github.com/yrodiere/jdk-playground.git
        git switch assertion-error-annotation-processor-jdk-22
        ./mvnw clean install -e
        ```

        The reproducer relies on Maven and compiles with `javax.tools`, which has the advantage of producing a detailed stacktrace. Compilations fails when using `javac` too (`-Dmaven.compiler.forceJavacCompilerUse=true`), but then you won't get any details about the failure.

        See https://ci.hibernate.org/blue/organizations/jenkins/jdk-playground-personal-yoann/activity?branch=assertion-error-annotation-processor-jdk-22 for executions of the reproducer on our CI, with logs, for both OpenJDK 21 (passing) and OpenJDK 22 (failing).

              jlahoda Jan Lahoda
              yrodiere Yoann Rodiere
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: