提交 2243ee91 编写于 作者: E egahlin

8008611: Better handling of annotations in JMX

Reviewed-by: skoivu, dholmes, jfdenise
上级 310e5f02
...@@ -378,13 +378,19 @@ public class Introspector { ...@@ -378,13 +378,19 @@ public class Introspector {
for (Annotation a : annots) { for (Annotation a : annots) {
Class<? extends Annotation> c = a.annotationType(); Class<? extends Annotation> c = a.annotationType();
Method[] elements = c.getMethods(); Method[] elements = c.getMethods();
boolean packageAccess = false;
for (Method element : elements) { for (Method element : elements) {
DescriptorKey key = element.getAnnotation(DescriptorKey.class); DescriptorKey key = element.getAnnotation(DescriptorKey.class);
if (key != null) { if (key != null) {
String name = key.value(); String name = key.value();
Object value; Object value;
try { try {
value = element.invoke(a); // Avoid checking access more than once per annotation
if (!packageAccess) {
ReflectUtil.checkPackageAccess(c);
packageAccess = true;
}
value = MethodUtil.invoke(element, a, null);
} catch (RuntimeException e) { } catch (RuntimeException e) {
// we don't expect this - except for possibly // we don't expect this - except for possibly
// security exceptions? // security exceptions?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册