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

HotSpotDiagnosticMXBean.setVMOption() throws NPE

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux zadok.basis.com 2.6.22-15-rt #1 SMP PREEMPT RT Wed Oct 22 02:21:14 GMT 2008 i686 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Calling setVMOption() with "HeapDumpPath" throws a NPE. The reason is that although sun.management.Flag.getFlag("HeapDumpPath") returns a non-null Flag, the instance method Flag.getValue() returns a null value. The if/else if clauses check for instanceof on the value returned from Flag.getValue(). Since in this case the value is null, none of the tests match, and the final else attempts to throw an IllegalArgumentException. Building the message for this final IAE throws a NPE when trying to call getClass() on the value returned from Flag.getValue(), since it's null.

      Any other flags for which a default value is not set (where Flag.getValue() returns null) will fail in the same way.

      This began failing in 6u10.




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      You can use the attached program to reproduce the problem.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
        Program should terminate normally.
      ACTUAL -
        Program terminates with NPE

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.NullPointerException
      at sun.management.HotSpotDiagnostic.setVMOption(HotSpotDiagnostic.java:93)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:167)
      at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:96)
      at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:33)
      at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
      at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
      at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
      at javax.management.StandardMBean.invoke(StandardMBean.java:391)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
      at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
      at com.sun.jmx.mbeanserver.MXBeanProxy$InvokeHandler.invoke(MXBeanProxy.java:134)
      at com.sun.jmx.mbeanserver.MXBeanProxy.invoke(MXBeanProxy.java:148)
      at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:248)
      at $Proxy0.setVMOption(Unknown Source)
      at scratch.SetVMOptionBug.main(SetVMOptionBug.java:20)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.IOException;
      import java.lang.management.ManagementFactory;

      import javax.management.MBeanServer;

      import com.sun.management.HotSpotDiagnosticMXBean;

      public class SetVMOptionBug
      {
          public static void main(String[] p_argv) throws IOException
          {
              MBeanServer server = ManagementFactory.getPlatformMBeanServer();
              String beanName = "com.sun.management:type=HotSpotDiagnostic";
              HotSpotDiagnosticMXBean bean =
                  ManagementFactory.newPlatformMXBeanProxy(server,
                                                           beanName,
                                                           HotSpotDiagnosticMXBean.class);
              bean.setVMOption("HeapDumpPath", "/tmp");
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Specify -XX:HeapDumpPath= on commandline.

      Release Regression From : 5.0u7
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

      Release Regression From : 6
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

      Release Regression From : 6u7
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            sjiang Shanliang Jiang (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: