changeset 7430:5ae5c4120014

8008611: Better handling of annotations in JMX Reviewed-by: skoivu, dholmes, jfdenise
author egahlin
date Thu, 21 Mar 2013 13:56:28 +0100
parents 4224b02452f5
children 802f5e480c8a
files src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Tue Apr 02 10:38:51 2013 +0200
+++ b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Thu Mar 21 13:56:28 2013 +0100
@@ -378,13 +378,19 @@
         for (Annotation a : annots) {
             Class<? extends Annotation> 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?