-
Bug
-
Resolution: Fixed
-
P3
-
8, 9
-
b80
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8135867 | emb-9 | Unassigned | P3 | Resolved | Fixed | team |
public class TestAnnotations {
@MyAnnotation(name = "foo")
private static class OneAnnotation {
}
@MyAnnotation(name = "foo")
@MyAnnotation(name = "bar")
private static class TwoAnnotations {
}
public static void main(String argv[]) throws Exception {
annotationCount(OneAnnotation.class);
annotationCount(TwoAnnotations.class);
//load empty security policy
loadSecurityPolicy();
annotationCount(OneAnnotation.class);
annotationCount(TwoAnnotations.class);
}
private static void annotationCount(Class<?> clazz) {
MyAnnotation[] annotations = clazz.getAnnotationsByType(MyAnnotation.class);
System.err.println(clazz.getSimpleName() + " annotation count: " + annotations.length);
}
...
}
OneAnnotation annotation count: 1
TwoAnnotations annotation count: 2
OneAnnotation annotation count: 1
Exception in thread "main" java.security.AccessControlException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:128)
at sun.reflect.annotation.AnnotationSupport.getValueArray(AnnotationSupport.java:196)
at sun.reflect.annotation.AnnotationSupport.getIndirectlyPresent(AnnotationSupport.java:110)
at
@MyAnnotation(name = "foo")
private static class OneAnnotation {
}
@MyAnnotation(name = "foo")
@MyAnnotation(name = "bar")
private static class TwoAnnotations {
}
public static void main(String argv[]) throws Exception {
annotationCount(OneAnnotation.class);
annotationCount(TwoAnnotations.class);
//load empty security policy
loadSecurityPolicy();
annotationCount(OneAnnotation.class);
annotationCount(TwoAnnotations.class);
}
private static void annotationCount(Class<?> clazz) {
MyAnnotation[] annotations = clazz.getAnnotationsByType(MyAnnotation.class);
System.err.println(clazz.getSimpleName() + " annotation count: " + annotations.length);
}
...
}
OneAnnotation annotation count: 1
TwoAnnotations annotation count: 2
OneAnnotation annotation count: 1
Exception in thread "main" java.security.AccessControlException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:128)
at sun.reflect.annotation.AnnotationSupport.getValueArray(AnnotationSupport.java:196)
at sun.reflect.annotation.AnnotationSupport.getIndirectlyPresent(AnnotationSupport.java:110)
at
- backported by
-
JDK-8135867 Repeating annotations throws java.security.AccessControlException with a SecurityManager
-
- Resolved
-