-
Bug
-
Resolution: Not an Issue
-
P2
-
None
-
8
One of tests for repeating annotations for Reflection API fails.
Test URL: api/java_lang/Class/repanno/inheritanno/GetAnnotationsByTypeInheritedTests.html#GetAnnotationsByTypeInheritedTests[annotExtAnnotMixAnnotContCheckAnnotTest]
Minimized test:
-----------------------------------------------------------
public class Test {
public static void main(String[] args) {
Ann[] jResult = J.class.getAnnotationsByType(Ann.class);
System.out.println("J @Ann count: " + jResult.length + ", should be 4");
for(Ann j : jResult) {
System.out.println(j.value());
}
}
}
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(AnnCont.class)
@Inherited
@interface Ann {
int value();
}
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface AnnCont {
Ann[] value();
}
@Ann(0)
class F {}
@Ann(1) @AnnCont({@Ann(2), @Ann(3)})
class J extends F {}
-----------------------------------------------------------
Output:
-----------------------------------------------------------
J @Ann count: 3, should be 4
1
2
3
Test URL: api/java_lang/Class/repanno/inheritanno/GetAnnotationsByTypeInheritedTests.html#GetAnnotationsByTypeInheritedTests[annotExtAnnotMixAnnotContCheckAnnotTest]
Minimized test:
-----------------------------------------------------------
public class Test {
public static void main(String[] args) {
Ann[] jResult = J.class.getAnnotationsByType(Ann.class);
System.out.println("J @Ann count: " + jResult.length + ", should be 4");
for(Ann j : jResult) {
System.out.println(j.value());
}
}
}
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(AnnCont.class)
@Inherited
@interface Ann {
int value();
}
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface AnnCont {
Ann[] value();
}
@Ann(0)
class F {}
@Ann(1) @AnnCont({@Ann(2), @Ann(3)})
class J extends F {}
-----------------------------------------------------------
Output:
-----------------------------------------------------------
J @Ann count: 3, should be 4
1
2
3
- relates to
-
JDK-8004912 Repeating annotations - getAnnotationsByType(Class<T>) is not working as expected for few inheritance scenarios
- Closed