use of com.ibm.dtfj.java.JavaMonitor in project openj9 by eclipse.
the class NodeJavaVM method didFinishParsing.
public void didFinishParsing() {
Iterator classLoaders = _runtime.getJavaClassLoaders();
while (classLoaders.hasNext()) {
Object potentialClassLoader = classLoaders.next();
if (potentialClassLoader instanceof JavaClassLoader) {
JavaClassLoader loader = (JavaClassLoader) potentialClassLoader;
// sets the associated object
try {
Object potentialLoaderObject = loader.getObject();
if (null != potentialLoaderObject && potentialLoaderObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
JavaObject loaderObject = (com.ibm.dtfj.java.j9.JavaObject) potentialLoaderObject;
loaderObject.setAssociatedClassLoader(loader);
_runtime.addSpecialObject(loaderObject);
Iterator classes = loader.getDefinedClasses();
while (classes.hasNext()) {
Object potentialClass = classes.next();
if (potentialClass instanceof JavaClass) {
JavaClass theClass = (JavaClass) potentialClass;
try {
Object potentialClassObject = theClass.getObject();
if (null != potentialClassObject && potentialClassObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
JavaObject classObject = (com.ibm.dtfj.java.j9.JavaObject) potentialClassObject;
classObject.setAssociatedClass(theClass);
_runtime.addSpecialObject(classObject);
}
} catch (CorruptDataException e) {
// no reason to skip the other classloaders/classes just because an exception is thrown on one class
} catch (IllegalArgumentException e) {
// CMVC 173262 : JavaClass.getObject() uses JavaHeap.getObjectAtAddress() which can throw this exception
}
}
}
}
} catch (CorruptDataException e) {
// associated object not set
}
}
}
Iterator monitors = _runtime.getMonitors();
while (monitors.hasNext()) {
Object potentialMonitor = monitors.next();
if (potentialMonitor instanceof JavaMonitor) {
JavaMonitor monitor = (JavaMonitor) potentialMonitor;
// sets the associated object
Object potentialMonitorObject = monitor.getObject();
if (null != potentialMonitorObject && potentialMonitorObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
JavaObject monitorObject = (com.ibm.dtfj.java.j9.JavaObject) potentialMonitorObject;
monitorObject.setAssociatedMonitor(monitor);
_runtime.addSpecialObject(monitorObject);
}
}
}
Iterator threads = _runtime.getThreads();
while (threads.hasNext()) {
Object potentialThread = threads.next();
if (potentialThread instanceof JavaThread) {
JavaThread thread = (JavaThread) potentialThread;
// sets the associated object
try {
Object potentialThreadObject = thread.getObject();
if (null != potentialThreadObject && potentialThreadObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
JavaObject threadObject = (com.ibm.dtfj.java.j9.JavaObject) potentialThreadObject;
threadObject.setAssociatedThread(thread);
_runtime.addSpecialObject(threadObject);
}
} catch (CorruptDataException e) {
// associated object not set
}
}
}
}
use of com.ibm.dtfj.java.JavaMonitor in project openj9 by eclipse.
the class InfoThreadCommand method getMonitors.
@SuppressWarnings("rawtypes")
private void getMonitors(JavaRuntime jr) {
int corruptThreadCount = 0;
int corruptMonitorCount = 0;
Iterator itMonitor = jr.getMonitors();
while (itMonitor.hasNext()) {
Object obj = itMonitor.next();
if (obj instanceof CorruptData) {
corruptMonitorCount++;
continue;
}
JavaMonitor jm = (JavaMonitor) obj;
Iterator itEnterWaiter = jm.getEnterWaiters();
while (itEnterWaiter.hasNext()) {
obj = itEnterWaiter.next();
if (obj instanceof CorruptData) {
corruptThreadCount++;
continue;
}
JavaThread jt = (JavaThread) obj;
monitors.put(jt, new MonitorState(jm, MonitorState.WAITING_TO_ENTER));
}
if (corruptThreadCount > 0) {
String msg = String.format("Warning : %d corrupt thread(s) were found waiting to enter monitor %s", corruptThreadCount, getMonitorName(jm));
logger.fine(msg);
}
corruptThreadCount = 0;
Iterator itNotifyWaiter = jm.getNotifyWaiters();
while (itNotifyWaiter.hasNext()) {
obj = itNotifyWaiter.next();
if (obj instanceof CorruptData) {
corruptThreadCount++;
continue;
}
JavaThread jt = (JavaThread) obj;
monitors.put(jt, new MonitorState(jm, MonitorState.WAITING_TO_BE_NOTIFIED_ON));
}
if (corruptThreadCount > 0) {
String msg = String.format("Warning : %d corrupt thread(s) were found waiting to be notified on monitor %s", corruptThreadCount, getMonitorName(jm));
logger.fine(msg);
}
}
if (corruptMonitorCount > 0) {
String msg = String.format("Warning : %d corrupt monitor(s) were found", corruptMonitorCount);
logger.fine(msg);
}
}
use of com.ibm.dtfj.java.JavaMonitor in project openj9 by eclipse.
the class JavaMonitorComparator method testEquals.
// getEnterWaiters
// getID
// getName
// getNotifyWaiters
// getObject
// getOwner
public void testEquals(Object ddrObject, Object jextractObject, int members) {
JavaMonitor ddrJavaMonitor = (JavaMonitor) ddrObject;
JavaMonitor jextractJavaMonitor = (JavaMonitor) jextractObject;
JavaThreadComparator javaThreadComparator = new JavaThreadComparator();
// getEnterWaiters
if ((ENTER_WAITERS & members) != 0)
javaThreadComparator.testComparatorIteratorEquals(ddrJavaMonitor, jextractJavaMonitor, "getEnterWaiters", JavaThread.class, JavaThreadComparator.JNI_ENV);
// getID
if ((ID & members) != 0)
new ImagePointerComparator().testComparatorEquals(ddrJavaMonitor, jextractJavaMonitor, "getID");
// getName()
if ((NAME & members) != 0)
testJavaEquals(ddrJavaMonitor, jextractJavaMonitor, "getName");
// getNotifyWaiters
if ((NOTIFY_WAITERS & members) != 0)
javaThreadComparator.testComparatorIteratorEquals(ddrJavaMonitor, jextractJavaMonitor, "getNotifyWaiters", JavaThread.class, JavaThreadComparator.JNI_ENV);
// getObject
if ((OBJECT & members) != 0)
new JavaObjectComparator().testComparatorEquals(ddrJavaMonitor, jextractJavaMonitor, "getObject");
// getOwner
if ((OWNER & members) != 0)
javaThreadComparator.testComparatorEquals(ddrJavaMonitor, jextractJavaMonitor, "getOwner", JavaThreadComparator.JNI_ENV);
}
use of com.ibm.dtfj.java.JavaMonitor in project openj9 by eclipse.
the class MonitorSectionParser method generateMonitor.
/**
* Must pass a valid monitor ID in order to successfully create a monitor object.
*
* @param monitorName optional
* @param monitorID required: must pass a valid ID or exception is thrown.
* @param objectID optional
* @param className optional
* @param owningThread optional
*
* @throws ParserException
* @throws BuilderFailureException if invalid monitorID is passed.
*/
private JavaMonitor generateMonitor(String monitorName, long monitorID, long objectID, String className, long owningThread) throws ParserException, BuilderFailureException {
JavaMonitor monitor = fRuntimeBuilder.addJavaMonitor(monitorName, monitorID, objectID, className, owningThread);
waitOnNotifyOrEnter(monitor);
return monitor;
}
use of com.ibm.dtfj.java.JavaMonitor in project openj9 by eclipse.
the class PHDJavaRuntime method prepMonitors.
/**
* Remember objects associated with monitors.
* Performance optimization - we can then find these objects on a scan through the heap
* and remember them, saving a fruitless search of the heap if they only exist in a javacore.
*/
private void prepMonitors() {
if (metaJavaRuntime != null) {
final PHDJavaClassLoader boot = loaders.get(null);
for (Iterator it = metaJavaRuntime.getMonitors(); it.hasNext(); ) {
Object next = it.next();
if (next instanceof CorruptData)
continue;
JavaMonitor mon = (JavaMonitor) next;
JavaObject jo = mon.getObject();
saveExtraObject(boot, jo);
}
}
}
Aggregations