summaryrefslogtreecommitdiff
path: root/java/openjdk6/files/icedtea/security/20130618/8008611-jmx_annotations.patch
blob: 55c46fd18cec465b8bbf723c669e910ae488210f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# HG changeset patch
# User egahlin
# Date 1363870588 -3600
# Node ID 0ffc0656881cac6747ac1a62895e855750d1a04e
# Parent  cd93c29052e6930c24a0350b8fe607ac1f1be068
8008611: Better handling of annotations in JMX
Reviewed-by: skoivu, dholmes, jfdenise

diff --git a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
--- jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+++ jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
@@ -359,13 +359,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?