changeset 5926:753eea1a0e03

8008611: Better handling of annotations in JMX Reviewed-by: skoivu, dholmes, jfdenise
author egahlin
date Thu, 21 Mar 2013 13:56:28 +0100
parents c98afec1bf86
children 6d4d0b939099 975d1f8c48dc 05a8336b1eab
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	Thu Mar 21 17:04:01 2013 +0400
+++ b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Thu Mar 21 13:56:28 2013 +0100
@@ -374,13 +374,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?