JDK-8320001 : javac crashes while adding type annotations to the return type of a constructor
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 21.0.2,22
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2023-11-14
  • Updated: 2024-01-26
  • Resolved: 2023-11-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 17 JDK 21 JDK 22
11-pool-oracleResolved 17-pool-oracleResolved 21.0.2Fixed 22 b26Fixed
Related Reports
Relates :  
Relates :  
Description
It's observed that some of the JCK tests related to Annotation processing are failing in JDK 22-b23 with "java.lang.AssertionError: Cannot add metadata to this type: VOID"
Possibly a regression caused by - https://bugs.openjdk.org/browse/JDK-8225377 

The tests are passing with JDK22-b22.

Attaching the sample AnnotationProcessor with sample target class file (Tester)

Here is the observation :
====

With b-22 ( Tester class successfully parsed by Annotation Processor)
====
/scratch/jdk-cache/22/22/jdk-22/bin/javac -processor  AnnoProc Tester
init...
process...
  annotations []

With b-23 ( java.lang.AssertionError: Cannot add metadata to this type: VOID )
====

 /scratch/jdk-cache/22/23/jdk-22/bin/javac -processor  AnnoProc Tester
An exception has occurred in the compiler (22-ea). 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.AssertionError: Cannot add metadata to this type: VOID
        at jdk.compiler/com.sun.tools.javac.code.Type.cloneWithMetadata(Type.java:351)
        at jdk.compiler/com.sun.tools.javac.code.Type.addMetadata(Type.java:390)
        at jdk.compiler/com.sun.tools.javac.code.Type.annotatedType(Type.java:456)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$TypeAnnotationTypeMapping.reannotate(ClassReader.java:2548)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$TypeAnnotationTypeMapping.visitType(ClassReader.java:2568)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$TypeAnnotationTypeMapping.visitType(ClassReader.java:2523)
        at jdk.compiler/com.sun.tools.javac.code.Type.accept(Type.java:223)
        at jdk.compiler/com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4894)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$TypeAnnotationSymbolVisitor.addTypeAnnotations(ClassReader.java:2426)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$TypeAnnotationSymbolVisitor.addTypeAnnotations(ClassReader.java:2394)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$TypeAnnotationSymbolVisitor.visitMethodSymbol(ClassReader.java:2335)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$TypeAnnotationSymbolVisitor.visitMethodSymbol(ClassReader.java:2286)
        at jdk.compiler/com.sun.tools.javac.code.Symbol$MethodSymbol.accept(Symbol.java:2271)
        at jdk.compiler/com.sun.tools.javac.code.Types$DefaultSymbolVisitor.visit(Types.java:4921)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.addTypeAnnotationsToSymbol(ClassReader.java:2283)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassReader$TypeAnnotationCompleter.run(ClassReader.java:2266)
        at jdk.compiler/com.sun.tools.javac.comp.Annotate.flush(Annotate.java:191)
        at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:322)
        at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:682)
        at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1418)
        at jdk.compiler/com.sun.tools.javac.code.ClassFinder.loadClass(ClassFinder.java:446)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.resolveBinaryNameOrIdent(JavaCompiler.java:730)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.resolveBinaryNameOrIdent(JavaCompiler.java:719)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1239)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
        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)


 




Comments
Thanks. This change got backed out from 21.0.2 and 17.0.11 with JDK-8322883 (for posterity).
10-01-2024

Hi, it's impossible to back out 8225377 without 8320001. 8320001 changes within a function added by 8225377. See also the description in the backout change 8233882. I agree that it is better to redo this in the July updates. Also a solution for 8322641 is pending.
10-01-2024

Let's back this one out with JDK-8225377 and try again for July. My $0.02 anyway.
09-01-2024

Hi [~cushon], rampdown of 17 and 11u starts January 30. I have prepared the backpout of 8225377 for 17. I can delay pushing it a while, but as I also need to make the 11u backport I don't want to wait too long.
08-01-2024

I think we should consider it. I have written up a retroactive CSR for JDK-8225377, what do you think about waiting for the outcome of the CSR review? Depending on the outcome of that I could also write up relnotes and a retroactive CSR for 17u and 11u. I think this change is currently in the April release of 11u and 17u so there is a bit of time to decide whether to back it out, is that right?
08-01-2024

Should we back this one out too for 17u-dev and 11u-dev together with JDK-8225377?
08-01-2024

[17u]: Let's wait a bit, this is a candidate for the January update. ... I approved it now, feel free to push.
13-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/2312 Date: 2023-11-29 20:12:10 +0000
29-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/2005 Date: 2023-11-29 20:12:11 +0000
29-11-2023

Fix Request 17u Backporting this patch fixes a regression introduced by JDK-8225377. The risk is low, it updates code introduced by JDK-8225377. The patch has a trivial merge conflict due to a change on an adjacent line. Included test passes.
29-11-2023

Fix Request 11u Backporting this patch fixes a regression introduced by JDK-8225377. The risk is low, it updates code introduced by JDK-8225377. The patch has a trivial merge conflict due to a change on an adjacent line. Included test passes.
29-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/412 Date: 2023-11-29 19:31:25 +0000
29-11-2023

Changeset: 5e24aaf4 Author: Vicente Romero <vromero@openjdk.org> Date: 2023-11-27 16:23:02 +0000 URL: https://git.openjdk.org/jdk/commit/5e24aaf4f7f11862ec8ac9d5c3e65d614104fb2c
27-11-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16774 Date: 2023-11-21 22:28:11 +0000
21-11-2023