Skip to content

Commit e534863

Browse files
Shivangi Guptacoffeys
authored andcommitted
8336942: Improve test coverage for class loading elements with annotations of different retentions
Backport-of: e36ce5f
1 parent e075b95 commit e534863

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/langtools/tools/javac/processing/model/type/BasicAnnoTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import java.lang.annotation.Annotation;
4242
import java.lang.annotation.ElementType;
4343
import java.lang.annotation.Repeatable;
44+
import java.lang.annotation.Retention;
45+
import java.lang.annotation.RetentionPolicy;
4446
import java.lang.annotation.Target;
4547
import java.lang.reflect.Method;
4648
import java.util.ArrayList;
@@ -93,13 +95,15 @@ public class BasicAnnoTests extends JavacTestingAbstractProcessor {
9395
private static final Map<String, Class<? extends Annotation>> nameToAnnotation =
9496
Map.ofEntries(new NameToAnnotationEntry("java.lang.Override", Override.class),
9597
new NameToAnnotationEntry("java.lang.annotation.Repeatable", Repeatable.class),
98+
new NameToAnnotationEntry("java.lang.annotation.Retention", Target.class),
9699
new NameToAnnotationEntry("java.lang.annotation.Target", Target.class),
97100
new NameToAnnotationEntry("BasicAnnoTests.Test", BasicAnnoTests.Test.class),
98101
new NameToAnnotationEntry("BasicAnnoTests.Tests",BasicAnnoTests.Tests.class),
99102
new NameToAnnotationEntry("BasicAnnoTests.TA", BasicAnnoTests.TA.class),
100103
new NameToAnnotationEntry("BasicAnnoTests.TB", BasicAnnoTests.TB.class),
101104
new NameToAnnotationEntry("BasicAnnoTests.TC", BasicAnnoTests.TC.class),
102-
new NameToAnnotationEntry("BasicAnnoTests.TCs", BasicAnnoTests.TCs.class));
105+
new NameToAnnotationEntry("BasicAnnoTests.TCs", BasicAnnoTests.TCs.class),
106+
new NameToAnnotationEntry("BasicAnnoTests.TD", BasicAnnoTests.TD.class));
103107

104108
static class NameToAnnotationEntry extends AbstractMap.SimpleEntry<String, Class<? extends Annotation>> {
105109
public NameToAnnotationEntry(String key, Class<? extends Annotation> entry) {
@@ -520,6 +524,12 @@ R scan(Iterable<? extends TypeMirror> iter, P p) {
520524
TC[] value();
521525
}
522526

527+
@Target(ElementType.TYPE_USE)
528+
@Retention(RetentionPolicy.RUNTIME)
529+
public @interface TD {
530+
int value();
531+
}
532+
523533
// Test cases
524534

525535
// TODO: add more cases for arrays
@@ -657,6 +667,10 @@ public class Inner6<T extends Object & Cloneable & @TA(17) Serializable> {}
657667
@Test(posn=1, annoType=TA.class, expect="23")
658668
public Set<@TA(23) ? super Object> f9;
659669

670+
@Test(posn=0, annoType=TA.class, expect="1")
671+
@Test(posn=0, annoType=TD.class, expect="2")
672+
public @TA(1) @TD(2) int f10;
673+
660674
// Test type use annotations on uses of type variables
661675
@Test(posn=6, annoType = TA.class, expect = "25")
662676
@Test(posn=6, annoType = TB.class, expect = "26")

0 commit comments

Comments
 (0)