< prev index next >
src/java.management/share/classes/sun/management/ThreadInfoCompositeData.java
Print this page
*** 73,84 ****
}
protected CompositeData getCompositeData() {
// Convert StackTraceElement[] to CompositeData[]
StackTraceElement[] stackTrace = threadInfo.getStackTrace();
! CompositeData[] stackTraceData =
! new CompositeData[stackTrace.length];
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement ste = stackTrace[i];
stackTraceData[i] = StackTraceElementCompositeData.toCompositeData(ste);
}
--- 73,83 ----
}
protected CompositeData getCompositeData() {
// Convert StackTraceElement[] to CompositeData[]
StackTraceElement[] stackTrace = threadInfo.getStackTrace();
! CompositeData[] stackTraceData = new CompositeData[stackTrace.length];
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement ste = stackTrace[i];
stackTraceData[i] = StackTraceElementCompositeData.toCompositeData(ste);
}
*** 86,137 ****
CompositeData lockInfoData =
LockInfoCompositeData.toCompositeData(threadInfo.getLockInfo());
// Convert LockInfo[] and MonitorInfo[] to CompositeData[]
LockInfo[] lockedSyncs = threadInfo.getLockedSynchronizers();
! CompositeData[] lockedSyncsData =
! new CompositeData[lockedSyncs.length];
for (int i = 0; i < lockedSyncs.length; i++) {
LockInfo li = lockedSyncs[i];
lockedSyncsData[i] = LockInfoCompositeData.toCompositeData(li);
}
MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors();
! CompositeData[] lockedMonitorsData =
! new CompositeData[lockedMonitors.length];
for (int i = 0; i < lockedMonitors.length; i++) {
MonitorInfo mi = lockedMonitors[i];
lockedMonitorsData[i] = MonitorInfoCompositeData.toCompositeData(mi);
}
! // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
! // THREAD_INFO_ATTRIBUTES!
! final Object[] threadInfoItemValues = {
! threadInfo.getThreadId(),
! threadInfo.getThreadName(),
! threadInfo.getThreadState().name(),
! threadInfo.getBlockedTime(),
! threadInfo.getBlockedCount(),
! threadInfo.getWaitedTime(),
! threadInfo.getWaitedCount(),
! lockInfoData,
! threadInfo.getLockName(),
! threadInfo.getLockOwnerId(),
! threadInfo.getLockOwnerName(),
! stackTraceData,
! threadInfo.isSuspended(),
! threadInfo.isInNative(),
! lockedMonitorsData,
! lockedSyncsData,
! threadInfo.isDaemon(),
! threadInfo.getPriority(),
! };
try {
! return new CompositeDataSupport(compositeType(),
! THREAD_INFO_ATTRIBTUES,
! threadInfoItemValues);
} catch (OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
--- 85,130 ----
CompositeData lockInfoData =
LockInfoCompositeData.toCompositeData(threadInfo.getLockInfo());
// Convert LockInfo[] and MonitorInfo[] to CompositeData[]
LockInfo[] lockedSyncs = threadInfo.getLockedSynchronizers();
! CompositeData[] lockedSyncsData = new CompositeData[lockedSyncs.length];
for (int i = 0; i < lockedSyncs.length; i++) {
LockInfo li = lockedSyncs[i];
lockedSyncsData[i] = LockInfoCompositeData.toCompositeData(li);
}
MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors();
! CompositeData[] lockedMonitorsData = new CompositeData[lockedMonitors.length];
for (int i = 0; i < lockedMonitors.length; i++) {
MonitorInfo mi = lockedMonitors[i];
lockedMonitorsData[i] = MonitorInfoCompositeData.toCompositeData(mi);
}
! // values may be null; can't use Map.of
! Map<String,Object> items = new HashMap<>();
! items.put(THREAD_ID, threadInfo.getThreadId());
! items.put(THREAD_NAME, threadInfo.getThreadName());
! items.put(THREAD_STATE, threadInfo.getThreadState().name());
! items.put(BLOCKED_TIME, threadInfo.getBlockedTime());
! items.put(BLOCKED_COUNT, threadInfo.getBlockedCount());
! items.put(WAITED_TIME, threadInfo.getWaitedTime());
! items.put(WAITED_COUNT, threadInfo.getWaitedCount());
! items.put(LOCK_INFO, lockInfoData);
! items.put(LOCK_NAME, threadInfo.getLockName());
! items.put(LOCK_OWNER_ID, threadInfo.getLockOwnerId());
! items.put(LOCK_OWNER_NAME, threadInfo.getLockOwnerName());
! items.put(STACK_TRACE, stackTraceData);
! items.put(SUSPENDED, threadInfo.isSuspended());
! items.put(IN_NATIVE, threadInfo.isInNative());
! items.put(LOCKED_MONITORS, lockedMonitorsData);
! items.put(LOCKED_SYNCS, lockedSyncsData);
! items.put(DAEMON, threadInfo.isDaemon());
! items.put(PRIORITY, threadInfo.getPriority());
try {
! return new CompositeDataSupport(ThreadInfoCompositeTypes.ofVersion(RUNTIME_VERSION), items);
} catch (OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
*** 181,194 ****
private static final String[] V9_ATTRIBUTES = {
DAEMON,
PRIORITY,
};
- private static final String[] THREAD_INFO_ATTRIBTUES =
- Stream.of(V5_ATTRIBUTES, V6_ATTRIBUTES, V9_ATTRIBUTES)
- .flatMap(Arrays::stream).toArray(String[]::new);
-
public long threadId() {
return getLong(cdata, THREAD_ID);
}
public String threadName() {
--- 174,183 ----
*** 363,378 ****
throw new IllegalArgumentException(
"Unexpected composite type for ThreadInfo of version " + version);
}
}
! public static CompositeType compositeType() {
! return ThreadInfoCompositeTypes.compositeTypes.get(0);
! }
!
static class ThreadInfoCompositeTypes {
- static final int CURRENT = Runtime.version().feature();
static final Map<Integer, CompositeType> compositeTypes = initCompositeTypes();
/*
* Returns CompositeType of the given runtime version
*/
static CompositeType ofVersion(int version) {
--- 352,363 ----
throw new IllegalArgumentException(
"Unexpected composite type for ThreadInfo of version " + version);
}
}
! static final int RUNTIME_VERSION = Runtime.version().feature();
static class ThreadInfoCompositeTypes {
static final Map<Integer, CompositeType> compositeTypes = initCompositeTypes();
/*
* Returns CompositeType of the given runtime version
*/
static CompositeType ofVersion(int version) {
*** 380,390 ****
}
static Map<Integer, CompositeType> initCompositeTypes() {
Map<Integer, CompositeType> types = new HashMap<>();
CompositeType ctype = initCompositeType();
! types.put(CURRENT, ctype);
types.put(5, initV5CompositeType(ctype));
types.put(6, initV6CompositeType(ctype));
return types;
}
--- 365,375 ----
}
static Map<Integer, CompositeType> initCompositeTypes() {
Map<Integer, CompositeType> types = new HashMap<>();
CompositeType ctype = initCompositeType();
! types.put(RUNTIME_VERSION, ctype);
types.put(5, initV5CompositeType(ctype));
types.put(6, initV6CompositeType(ctype));
return types;
}
< prev index next >