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

Jan Lahoda jlahoda at openjdk.org
Tue Jan 13 08:14:55 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.

This pull request has now been integrated.

Changeset: 578204f8
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/578204f8c49f06be8b9c4855359ca61c9e107678
Stats:     24 lines in 3 files changed: 20 ins; 0 del; 4 mod

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

Reviewed-by: vromero

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

PR: https://git.openjdk.org/jdk/pull/29107


More information about the compiler-dev mailing list