From 62fb07baaa2f16aa4abe6d5f594727bd42dea4e1 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Thu, 21 Mar 2013 13:56:28 +0100 Subject: [PATCH] 8008611: Better handling of annotations in JMX Reviewed-by: skoivu, dholmes, jfdenise --- .../classes/com/sun/jmx/mbeanserver/Introspector.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java index b2abc521b0f..732c280f7dd 100644 --- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java +++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java @@ -378,13 +378,19 @@ public class Introspector { for (Annotation a : annots) { Class c = a.annotationType(); Method[] elements = c.getMethods(); + boolean packageAccess = false; for (Method element : elements) { DescriptorKey key = element.getAnnotation(DescriptorKey.class); if (key != null) { String name = key.value(); Object value; 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) { // we don't expect this - except for possibly // security exceptions?