On Sun, 10 Mar 2024 20:19:44 GMT, Chen Liang <[email protected]> wrote:
> Please review this patch that fixes the issue where type annotations on > primitive types are not linked. > > Tested with file > https://cr.openjdk.org/~liach/8325433-arrayanno/ArrayAnno.java > > import java.lang.annotation.*; > > public class ArrayAnno { > @Retention(RetentionPolicy.RUNTIME) > @Target(ElementType.TYPE_USE) > @Documented > public @interface Anno { int value(); } > > public void method(@Anno(1) int @Anno(2) [] @Anno(3) [] arg) {} > public void method(@Anno(1) String @Anno(2) [] @Anno(3) [] arg) {} > } > > JDK 21: https://cr.openjdk.org/~liach/8325433-arrayanno/old/ArrayAnno.html > This patch: https://cr.openjdk.org/~liach/8325433-arrayanno/new/ArrayAnno.html > > Note that a bug within javac causes the annotations to become `@Anno(1) > String @Anno(3) [] @Anno(2) []` in the output files; this bug also affects > output class files so I assume this is a bug within javac's tree building. > (Intersting, the buggy javadoc output was copied wholesale in the original > `TestTypeAnnotations` output for `array2Deep` cases, but no one paid > attention to it) The 2-D array case is broken: currently source code `@A int @B [] @C []` is compiled to `@A int @C [] @B []` in both class file and javadoc output, so I don't want to add a buggy case that needs to be updated if this annotation placement bug is fixed. ------------- PR Comment: https://git.openjdk.org/jdk/pull/18179#issuecomment-1988412676
