-
Bug
-
Resolution: Fixed
-
P3
-
9, 10, 11, 21
Take 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;
}
Compile with javac 8 and 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
)
Compile with javac 9, 10, or a recent 11 build and 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.
The annotations for fields oi, oia, and i are generated consistently
for all versions and are just included to illustrate all the relevant
annotation positions.
The Java 8 behavior was correct and should be re-established.
Discussion: http://mail.openjdk.java.net/pipermail/compiler-dev/2018-July/012199.html
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;
}
Compile with javac 8 and 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
)
Compile with javac 9, 10, or a recent 11 build and 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.
The annotations for fields oi, oia, and i are generated consistently
for all versions and are just included to illustrate all the relevant
annotation positions.
The Java 8 behavior was correct and should be re-established.
Discussion: http://mail.openjdk.java.net/pipermail/compiler-dev/2018-July/012199.html
- relates to
-
JDK-8215366 Code quality improvements in com.sun.tools.javac.code.TypeAnnotations
-
- Resolved
-