RFR: 8374379: Type annotation in new array dimension expression causes java.lang.AssertionError
Jan Lahoda
jlahoda at openjdk.org
Thu Jan 8 07:15:03 UTC 2026
Consider code snippet like:
new int[(@annotation int) Integer.MIN_VALUE]
this crashes javac:
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.checkNonNull(Assert.java:62)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.fromAnnotations(Annotate.java:167)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.lambda$annotateTypeSecondStage$0(Annotate.java:1069)
...
The reason is that the annotation is not attributed, as `Annotate.TypeAnnotate` does not recurse into the array dimension expressions at all, and hence won't attribute the annotation.
This patch proposes to recurse into the dimensions for `Annotate.TypeAnnotate`, and also in `TypeAnnotations.TypeAnnotationPositions`, so that the position for the annotation is assigned properly.
-------------
Commit messages:
- Updating copyright years.
- 8374379: Internal compiler java.lang.AssertionError
Changes: https://git.openjdk.org/jdk/pull/29107/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29107&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8374379
Stats: 24 lines in 3 files changed: 20 ins; 0 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/29107.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29107/head:pull/29107
PR: https://git.openjdk.org/jdk/pull/29107
More information about the compiler-dev
mailing list