Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8038343

Eliminate use of reflection to access JavaBeans Introspector

XMLWordPrintable

      In JDK-6888171 we changed the introspector in the JMX monitor API implementation to access the JavaBeans Introspector via core reflection. This was good enough for our modularity efforts at the time and also good enough for the Compact Profiles effort in JDK 8.

      It is time to re-visit this code with a view to it working with modules and without needing to resort to setAccessible(true). Here is an example of how this code fails with an early build of modules:

      java.lang.IllegalAccessException: Class com.sun.jmx.mbeanserver.Introspector$BeansHelper (module java.management) can not access a member of class java.beans.Introspector (module java.desktop) with modifiers "public static"
      at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:142)
      at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:295)
      at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:287)
      at java.lang.reflect.Method.invoke(Method.java:477)
      at com.sun.jmx.mbeanserver.Introspector$BeansHelper.getBeanInfo(Introspector.java:757)
      at com.sun.jmx.mbeanserver.Introspector.elementFromComplex(Introspector.java:554)
      at javax.management.monitor.Monitor.getComparableFromAttribute(Monitor.java:872)
      at javax.management.monitor.Monitor.monitor(Monitor.java:1286)
      at javax.management.monitor.Monitor.access$600(Monitor.java:75)
      at javax.management.monitor.Monitor$MonitorTask$1.run(Monitor.java:1579)
      at javax.management.monitor.Monitor$MonitorTask$1.run(Monitor.java:1572)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.management.monitor.Monitor$MonitorTask.run(Monitor.java:1589)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:744)

            alanb Alan Bateman
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: