java.lang.ClassCastException: [Ljavax.management.openmbean.CompositeData; cannot be cast to java.util.List

JDK Bug System | J. Duke | 6 years ago
  1. 0

    FULL PRODUCT VERSION : java version "1.6.0_25" Java(TM) SE Runtime Environment (build 1.6.0_25-b06) Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows XP [Version 5.1.2600] A DESCRIPTION OF THE PROBLEM : If i use getDiagnoseOptions() of a HotSpotDiagnosticMXBean instance, a classcast exception occures. REGRESSION. Last worked in version 6u25 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : get HotSpotDiagnosticsMXBean instance and try to get diagnostic options EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - any output like 'options: [<vmoptions>]' ACTUAL - Exception in thread "main" java.lang.ClassCastException: [Ljavax.management.openmbean.CompositeData; cannot be cast to java.util.List at $Proxy0.getDiagnosticOptions(Unknown Source) at Dummy.main(Dummy.java:17) ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.ClassCastException: [Ljavax.management.openmbean.CompositeData; cannot be cast to java.util.List at $Proxy0.getDiagnosticOptions(Unknown Source) at Dummy.main(Dummy.java:17) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.lang.management.ManagementFactory; import java.util.List; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectName; import com.sun.management.HotSpotDiagnosticMXBean; import com.sun.management.VMOption; public class Dummy2 { public static void main(String[] args) throws Exception { ObjectName hsdObjectName = new ObjectName( "com.sun.management:type=HotSpotDiagnostic"); HotSpotDiagnosticMXBean hsdMXBean = MBeanServerInvocationHandler .newProxyInstance(ManagementFactory.getPlatformMBeanServer(), hsdObjectName, HotSpotDiagnosticMXBean.class, false); List<VMOption> options = hsdMXBean.getDiagnosticOptions(); System.out.printf("options: %1$s\n", options); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Get attribute directly from MBeanServer: import java.lang.management.ManagementFactory; import java.util.Arrays; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.openmbean.CompositeData; public class Dummy { public static void main(String[] args) throws Exception { ObjectName hsdObjectName = new ObjectName( "com.sun.management:type=HotSpotDiagnostic"); MBeanServer F_server = ManagementFactory.getPlatformMBeanServer(); CompositeData[] attribute = (CompositeData[]) F_server.getAttribute( hsdObjectName, "DiagnosticOptions"); System.out.printf("Options: %1$s\n", Arrays.toString(attribute)); } }

    JDK Bug System | 6 years ago | J. Duke
    java.lang.ClassCastException: [Ljavax.management.openmbean.CompositeData; cannot be cast to java.util.List
  2. 0

    How to return non openType in MXBean

    Coderanch | 2 years ago | Peter van Nes
    java.lang.ClassCastException: [Ljavax.management.openmbean.CompositeData; cannot be cast to javax.management.openmbean.CompositeData
  3. 0

    Cannot get high availability info via proxy mbean

    GitHub | 3 years ago | wouterv
    java.lang.ClassCastException: [Ljavax.management.openmbean.CompositeData; cannot be cast to [Lorg.neo4j.management.ClusterMemberInfo;
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    DefaultSqlSession returned by DefaultSqlSessionFactory is not Thread-Safe

    GitHub | 2 years ago | purijatin
    java.lang.ClassCastException: org.apache.ibatis.executor.ExecutionPlaceholder cannot be cast to java.util.List
  6. 0

    java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.List

    GitHub | 5 years ago | incubos
    java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.List

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      [Ljavax.management.openmbean.CompositeData; cannot be cast to java.util.List

      at $Proxy0.getDiagnosticOptions()
    2. Unknown
      Dummy.main
      1. $Proxy0.getDiagnosticOptions(Unknown Source)
      2. Dummy.main(Dummy.java:17)
      2 frames