use of com.ibm.dtfj.java.JavaThread in project openj9 by eclipse.
the class InfoLockCommand method showSystemLocks.
private void showSystemLocks() {
Vector vMonitorsWithLockedObjects = new Vector();
JavaRuntime jRuntime = ctx.getRuntime();
Iterator monitors = jRuntime.getMonitors();
out.println("\nSystem locks...");
while (monitors.hasNext()) {
JavaMonitor jMonitor = (JavaMonitor) monitors.next();
JavaObject jObject = jMonitor.getObject();
try {
String monitorName = jMonitor.getName().trim();
if (monitorName.equalsIgnoreCase("")) {
monitorName = "<un-named monitor>";
}
out.println("id: 0x" + jMonitor.getID() + " name: " + jMonitor.getName());
JavaThread owner = jMonitor.getOwner();
if (null != owner) {
try {
out.println("\towner thread id: " + owner.getImageThread().getID() + " name: " + owner.getName());
} catch (DataUnavailable e) {
out.println("\towner thread id: " + Exceptions.getDataUnavailableString());
logger.log(Level.FINE, Exceptions.getDataUnavailableString(), e);
}
}
showWaiters(jMonitor);
} catch (CorruptDataException cde) {
out.println("\nwarning, corrupt data encountered during scan for system locks...");
}
if (null != jObject) {
// Remember object monitors (flat or inflated) for later
vMonitorsWithLockedObjects.add(jMonitor);
}
}
showLockedObjects(vMonitorsWithLockedObjects);
}
use of com.ibm.dtfj.java.JavaThread in project openj9 by eclipse.
the class InfoLockCommand method showLockedObjects.
private void showLockedObjects(Vector vMonitorsWithLockedObjects) {
out.println("\nObject Locks in use...");
if (0 == vMonitorsWithLockedObjects.size()) {
out.println("\t...None.");
return;
}
Iterator lockedObjects = vMonitorsWithLockedObjects.iterator();
while (lockedObjects.hasNext()) {
JavaMonitor jMonitor = (JavaMonitor) lockedObjects.next();
JavaObject jObject = jMonitor.getObject();
try {
JavaThread owner = jMonitor.getOwner();
String className = "<unknown class>";
JavaClass jClass = jObject.getJavaClass();
if (null != jClass) {
className = jClass.getName();
}
String jObjectID = Long.toHexString(jObject.getID().getAddress());
if (null == owner) {
out.println(className + "@0x" + jObjectID);
} else {
String owningThreadID = null;
try {
owningThreadID = owner.getImageThread().getID();
} catch (DataUnavailable e) {
owningThreadID = Exceptions.getDataUnavailableString();
}
out.println(className + "@0x" + jObjectID);
out.println("\towner thread id: " + owningThreadID + " name: " + owner.getName());
}
showWaiters(jMonitor);
} catch (CorruptDataException cde) {
logger.log(Level.FINE, Exceptions.getCorruptDataExceptionString(), cde);
}
}
}
Aggregations