jdk/src/share/classes/sun/management/ThreadInfoCompositeData.java
changeset 13803 889df16bef60
parent 11530 a9d059c15b80
child 14342 8435a30053c1
equal deleted inserted replaced
13802:7e765d50416f 13803:889df16bef60
    83             StackTraceElement ste = stackTrace[i];
    83             StackTraceElement ste = stackTrace[i];
    84             stackTraceData[i] = StackTraceElementCompositeData.toCompositeData(ste);
    84             stackTraceData[i] = StackTraceElementCompositeData.toCompositeData(ste);
    85         }
    85         }
    86 
    86 
    87         // Convert MonitorInfo[] and LockInfo[] to CompositeData[]
    87         // Convert MonitorInfo[] and LockInfo[] to CompositeData[]
    88         LockDataConverter converter = new LockDataConverter(threadInfo);
    88         CompositeData lockInfoData =
    89         CompositeData lockInfoData = converter.toLockInfoCompositeData();
    89             LockInfoCompositeData.toCompositeData(threadInfo.getLockInfo());
    90         CompositeData[] lockedSyncsData = converter.toLockedSynchronizersCompositeData();
    90 
    91 
    91         // Convert LockInfo[] and MonitorInfo[] to CompositeData[]
    92         // Convert MonitorInfo[] to CompositeData[]
    92         LockInfo[] lockedSyncs = threadInfo.getLockedSynchronizers();
       
    93         CompositeData[] lockedSyncsData =
       
    94             new CompositeData[lockedSyncs.length];
       
    95         for (int i = 0; i < lockedSyncs.length; i++) {
       
    96             LockInfo li = lockedSyncs[i];
       
    97             lockedSyncsData[i] = LockInfoCompositeData.toCompositeData(li);
       
    98         }
       
    99 
    93         MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors();
   100         MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors();
    94         CompositeData[] lockedMonitorsData =
   101         CompositeData[] lockedMonitorsData =
    95             new CompositeData[lockedMonitors.length];
   102             new CompositeData[lockedMonitors.length];
    96         for (int i = 0; i < lockedMonitors.length; i++) {
   103         for (int i = 0; i < lockedMonitors.length; i++) {
    97             MonitorInfo mi = lockedMonitors[i];
   104             MonitorInfo mi = lockedMonitors[i];
    98             lockedMonitorsData[i] = MonitorInfoCompositeData.toCompositeData(mi);
   105             lockedMonitorsData[i] = MonitorInfoCompositeData.toCompositeData(mi);
    99         }
   106         }
   100 
       
   101 
   107 
   102         // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
   108         // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
   103         // threadInfoItemNames!
   109         // threadInfoItemNames!
   104         final Object[] threadInfoItemValues = {
   110         final Object[] threadInfoItemValues = {
   105             new Long(threadInfo.getThreadId()),
   111             new Long(threadInfo.getThreadId()),
   214 
   220 
   215         // Each CompositeData object has its CompositeType associated
   221         // Each CompositeData object has its CompositeType associated
   216         // with it.  So we can get the CompositeType representing LockInfo
   222         // with it.  So we can get the CompositeType representing LockInfo
   217         // from a mapped CompositeData for any LockInfo object.
   223         // from a mapped CompositeData for any LockInfo object.
   218         // Thus we construct a random LockInfo object and pass it
   224         // Thus we construct a random LockInfo object and pass it
   219         // to LockDataConverter to do the conversion.
   225         // to LockInfoCompositeData to do the conversion.
   220         Object o = new Object();
   226         Object o = new Object();
   221         LockInfo li = new LockInfo(o.getClass().getName(),
   227         LockInfo li = new LockInfo(o.getClass().getName(),
   222                                    System.identityHashCode(o));
   228                                    System.identityHashCode(o));
   223         CompositeData cd = LockDataConverter.toLockInfoCompositeData(li);
   229         CompositeData cd = LockInfoCompositeData.toCompositeData(li);
   224         lockInfoCompositeType = cd.getCompositeType();
   230         lockInfoCompositeType = cd.getCompositeType();
   225     }
   231     }
   226 
   232 
   227     private static boolean isV5Attribute(String itemName) {
   233     private static boolean isV5Attribute(String itemName) {
   228         for (String n : threadInfoV6Attributes) {
   234         for (String n : threadInfoV6Attributes) {
   313         return stackTrace;
   319         return stackTrace;
   314     }
   320     }
   315 
   321 
   316     // 6.0 new attributes
   322     // 6.0 new attributes
   317     public LockInfo lockInfo() {
   323     public LockInfo lockInfo() {
   318         LockDataConverter converter = new LockDataConverter();
       
   319         CompositeData lockInfoData = (CompositeData) cdata.get(LOCK_INFO);
   324         CompositeData lockInfoData = (CompositeData) cdata.get(LOCK_INFO);
   320         return converter.toLockInfo(lockInfoData);
   325         return LockInfo.from(lockInfoData);
   321     }
   326     }
   322 
   327 
   323     public MonitorInfo[] lockedMonitors() {
   328     public MonitorInfo[] lockedMonitors() {
   324         CompositeData[] lockedMonitorsData =
   329         CompositeData[] lockedMonitorsData =
   325             (CompositeData[]) cdata.get(LOCKED_MONITORS);
   330             (CompositeData[]) cdata.get(LOCKED_MONITORS);
   334         }
   339         }
   335         return monitors;
   340         return monitors;
   336     }
   341     }
   337 
   342 
   338     public LockInfo[] lockedSynchronizers() {
   343     public LockInfo[] lockedSynchronizers() {
   339         LockDataConverter converter = new LockDataConverter();
       
   340         CompositeData[] lockedSyncsData =
   344         CompositeData[] lockedSyncsData =
   341             (CompositeData[]) cdata.get(LOCKED_SYNCS);
   345             (CompositeData[]) cdata.get(LOCKED_SYNCS);
   342 
   346 
   343         // The LockedSynchronizers item cannot be null, but if it is we will
   347         // The LockedSynchronizers item cannot be null, but if it is we will
   344         // get a NullPointerException when we ask for its length.
   348         // get a NullPointerException when we ask for its length.
   345         return converter.toLockedSynchronizers(lockedSyncsData);
   349         LockInfo[] locks = new LockInfo[lockedSyncsData.length];
       
   350         for (int i = 0; i < lockedSyncsData.length; i++) {
       
   351             CompositeData cdi = lockedSyncsData[i];
       
   352             locks[i] = LockInfo.from(cdi);
       
   353         }
       
   354         return locks;
   346     }
   355     }
   347 
   356 
   348     /** Validate if the input CompositeData has the expected
   357     /** Validate if the input CompositeData has the expected
   349      * CompositeType (i.e. contain all attributes with expected
   358      * CompositeType (i.e. contain all attributes with expected
   350      * names and types).
   359      * names and types).