use of java.lang.management.LockInfo in project openj9 by eclipse.
the class TestLockInfo method testGetClassName.
/*
* Test method for 'java.lang.management.LockInfo.getClassName()'
*/
@Test
public void testGetClassName() {
LockInfo li = new LockInfo("foo.Bar", 0);
AssertJUnit.assertEquals("foo.Bar", li.getClassName());
// Verify that case matters
AssertJUnit.assertTrue(!li.getClassName().equals("foo.bar"));
// Even an empty string is allowed for the class name
li = new LockInfo("", 0);
AssertJUnit.assertEquals("", li.getClassName());
}
use of java.lang.management.LockInfo in project openj9 by eclipse.
the class TestLockInfo method testGetIdentityHashCode.
/*
* Test method for 'java.lang.management.LockInfo.getIdentityHashCode()'
*/
@Test
public void testGetIdentityHashCode() {
LockInfo li = new LockInfo("foo.Bar", 42);
AssertJUnit.assertEquals(42, li.getIdentityHashCode());
// Negative identity hash codes are allowed
li = new LockInfo("foo.Bar", -222);
AssertJUnit.assertEquals(-222, li.getIdentityHashCode());
}
use of java.lang.management.LockInfo in project openj9 by eclipse.
the class TestLockInfo method setUp.
@BeforeClass
protected void setUp() throws Exception {
lock = new Object();
idHashCode = System.identityHashCode(lock);
lockName = lock.getClass().getName();
goodLI = new LockInfo(lock.getClass().getName(), System.identityHashCode(lock));
logger.info("Starting TestLockInfo tests ...");
}
use of java.lang.management.LockInfo in project openj9 by eclipse.
the class ThreadInfoUtil method toCompositeData.
/**
* @param info a {@link ThreadInfo} object
* @return a {@link CompositeData} object that represents the supplied <code>info</code> object
*/
public static CompositeData toCompositeData(ThreadInfo info) {
CompositeData result = null;
if (info != null) {
// deal with the array types first
StackTraceElement[] st = info.getStackTrace();
CompositeData[] stArray = new CompositeData[st.length];
for (int i = 0; i < stArray.length; ++i) {
stArray[i] = StackTraceElementUtil.toCompositeData(st[i]);
}
MonitorInfo[] lockedMonitors = info.getLockedMonitors();
CompositeData[] lmArray = new CompositeData[lockedMonitors.length];
for (int i = 0; i < lmArray.length; ++i) {
lmArray[i] = MonitorInfoUtil.toCompositeData(lockedMonitors[i]);
}
LockInfo[] lockedSynchronizers = info.getLockedSynchronizers();
CompositeData[] lsArray = new CompositeData[lockedSynchronizers.length];
for (int i = 0; i < lsArray.length; ++i) {
lsArray[i] = LockInfoUtil.toCompositeData(lockedSynchronizers[i]);
}
CompositeType type = ThreadInfoUtil.getCompositeType();
String[] names = { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"threadId", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"threadName", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"threadState", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"suspended", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"inNative", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"blockedCount", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"blockedTime", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"waitedCount", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"waitedTime", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"lockInfo", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"lockName", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"lockOwnerId", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"lockOwnerName", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"stackTrace", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"lockedMonitors", // $NON-NLS-1$
"lockedSynchronizers", // $NON-NLS-1$ //$NON-NLS-2$
"daemon", // $NON-NLS-1$ //$NON-NLS-2$
"priority" /*[ENDIF]*/
};
Object[] values = { Long.valueOf(info.getThreadId()), info.getThreadName(), info.getThreadState().name(), Boolean.valueOf(info.isSuspended()), Boolean.valueOf(info.isInNative()), Long.valueOf(info.getBlockedCount()), Long.valueOf(info.getBlockedTime()), Long.valueOf(info.getWaitedCount()), Long.valueOf(info.getWaitedTime()), LockInfoUtil.toCompositeData(info.getLockInfo()), info.getLockName(), Long.valueOf(info.getLockOwnerId()), info.getLockOwnerName(), stArray, lmArray, lsArray, /*[IF Sidecar19-SE]*/
Boolean.valueOf(info.isDaemon()), Integer.valueOf(info.getPriority()) /*[ENDIF]*/
};
try {
result = new CompositeDataSupport(type, names, values);
} catch (OpenDataException e) {
if (ManagementUtils.VERBOSE_MODE) {
e.printStackTrace(System.err);
}
}
}
return result;
}
Aggregations