-
Bug
-
Resolution: Not an Issue
-
P2
-
8
j.l.Class.getAnnotationsByType(Class) returns wrong result for inherited repeating annotations.
JCK tests fail for jdk8-b99.
Minimized test:
--------------------------------------------------
public class Test {
public static void main(String[] args) {
Ann[] bResult = B.class.getAnnotationsByType(Ann.class);
System.out.println("B @Ann count: " + bResult.length + ", should be 4");
Ann[] dResult = D.class.getAnnotationsByType(Ann.class);
System.out.println("D @Ann count: " + dResult.length + ", should be 2");
}
}
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(AnnCont.class)
@Inherited
@interface Ann {
int value();
}
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface AnnCont {
Ann[] value();
}
@Ann(0) @Ann(1)
class A {}
@Ann(2) @Ann(3)
class B extends A {}
@Ann(0)
class F {}
@Ann(2)
class D extends F {}
--------------------------------------------------
Output:
--------------------------------------------------
B @Ann count: 2, should be 4
D @Ann count: 1, should be 2
JCK tests fail for jdk8-b99.
Minimized test:
--------------------------------------------------
public class Test {
public static void main(String[] args) {
Ann[] bResult = B.class.getAnnotationsByType(Ann.class);
System.out.println("B @Ann count: " + bResult.length + ", should be 4");
Ann[] dResult = D.class.getAnnotationsByType(Ann.class);
System.out.println("D @Ann count: " + dResult.length + ", should be 2");
}
}
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(AnnCont.class)
@Inherited
@interface Ann {
int value();
}
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface AnnCont {
Ann[] value();
}
@Ann(0) @Ann(1)
class A {}
@Ann(2) @Ann(3)
class B extends A {}
@Ann(0)
class F {}
@Ann(2)
class D extends F {}
--------------------------------------------------
Output:
--------------------------------------------------
B @Ann count: 2, should be 4
D @Ann count: 1, should be 2
- is blocked by
-
JDK-8004912 Repeating annotations - getAnnotationsByType(Class<T>) is not working as expected for few inheritance scenarios
- Closed
- relates to
-
JDK-8004912 Repeating annotations - getAnnotationsByType(Class<T>) is not working as expected for few inheritance scenarios
- Closed