RFR: 8374379: Type annotation in new array dimension expression causes java.lang.AssertionError

Vicente Romero vromero at openjdk.org
Thu Jan 8 15:41:31 UTC 2026


On Thu, 8 Jan 2026 07:09:10 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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.

lgtm

-------------

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29107#pullrequestreview-3640002980


More information about the compiler-dev mailing list