RFR: 8208470: Type annotations on inner type that is an array component
Vicente Romero
vromero at openjdk.org
Sat Feb 11 14:08:00 UTC 2023
As stated in the bug great description by Werner D.:
Considering this example:
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@interface TA {
int value();
}
class ArrayOfInner {
class Inner {}
@TA(1) ArrayOfInner. @TA(2) Inner oi;
@TA(3) ArrayOfInner. @TA(4) Inner [] oia;
@TA(5) Inner i;
@TA(6) Inner [] ia;
}
If compiled with javac 8, according to javap -v field ia has the annotation:
ArrayOfInner$Inner[] ia;
descriptor: [LArrayOfInner$Inner;
flags: (0x0000)
RuntimeVisibleTypeAnnotations:
0: #10(#11=I#21): FIELD, location=[ARRAY, INNER_TYPE]
TA(
value=6
)
if compiled with javac > 8 ia has the annotation:
ArrayOfInner$Inner[] ia;
descriptor: [LArrayOfInner$Inner;
flags: (0x0000)
RuntimeVisibleTypeAnnotations:
0: #10(#11=I#21): FIELD, location=[ARRAY]
TA(
value=6
)
Note the missing `INNER_TYPE` location. This PR is re-establishing the Java 8 behavior.
TIA
-------------
Commit messages:
- 8208470: Type annotations on inner type that is an array component
Changes: https://git.openjdk.org/jdk/pull/12522/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12522&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8208470
Stats: 85 lines in 4 files changed: 33 ins; 43 del; 9 mod
Patch: https://git.openjdk.org/jdk/pull/12522.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12522/head:pull/12522
PR: https://git.openjdk.org/jdk/pull/12522
More information about the compiler-dev
mailing list