use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class JExtractXMLGenerator method generateClassloaders.
@SuppressWarnings("unchecked")
private void generateClassloaders(JavaRuntime rt) throws Exception {
for (Iterator loaders = rt.getJavaClassLoaders(); loaders.hasNext(); ) {
JavaClassLoader loader = (JavaClassLoader) loaders.next();
xml.append("<classloader id=\"");
// xml.append(loader.getID());
xml.append("\" obj=\"0x");
xml.append(Long.toHexString(loader.getObject().getID().getAddress()));
xml.append("\">\n");
for (Iterator classes = loader.getCachedClasses(); classes.hasNext(); ) {
JavaClass clazz = (JavaClass) classes.next();
xml.append("<class id=\"0x");
xml.append(Long.toHexString(clazz.getID().getAddress()));
xml.append("\" />\n");
}
xml.append("</classloader>\n");
}
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class ClassLoaderSectionParser method processClassLoaders.
/**
* Grammar subsection 2CLTEXTCLLOAD
* Although classes must be associated with classloaders in DTFJ, if a class loader
* is not built due to corruption of data, yet a class list still exists for it,
* the parser still has to process the class data from the buffer any way,
* even though it may not be added to
* DTFJ by the builder.
*/
private void processClassLoaders(IAttributeValueMap results) throws ParserException {
JavaClassLoader loader = null;
String cl_name = results.getTokenValue(CL_ATT__NAME);
long cl_address = results.getLongValue(CL_ATT_ADDRESS);
try {
loader = fRuntimeBuilder.addClassLoader(cl_name, cl_address, cl_address);
} catch (BuilderFailureException e) {
handleError("Failed to add class loader: " + cl_name + " " + cl_address + " ", e);
}
while ((results = processTagLineOptional(T_3CLTEXTCLASS)) != null) {
String className = results.getTokenValue(CLASS_ATT_NAME);
long classID = results.getLongValue(CLASS_ATT_ADDRESS);
try {
fRuntimeBuilder.addClass(loader, className, classID, IBuilderData.NOT_AVAILABLE, null);
} catch (BuilderFailureException e) {
handleError("Failed to add class: " + className + " " + classID + " ", e);
}
}
}
use of com.ibm.dtfj.java.JavaClassLoader 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.JavaClassLoader in project openj9 by eclipse.
the class DTFJJavaClass method addClassLoaderReference.
private void addClassLoaderReference(List<Object> coll) {
JavaReference jRef = null;
try {
JavaClassLoader classLoader = this.getClassLoader();
if (null != classLoader) {
JavaObject classLoaderObject = classLoader.getObject();
if (null != classLoaderObject) {
jRef = new DTFJJavaReference(this, classLoaderObject, "Classloader", JavaReference.REFERENCE_CLASS_LOADER, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
coll.add(jRef);
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
coll.add(cd);
}
}
use of com.ibm.dtfj.java.JavaClassLoader in project openj9 by eclipse.
the class DTFJJavaFieldInstance method _findClassForName.
/**
* private method to search all classloaders for a given class
*/
private JavaClass _findClassForName(String candidateClass) throws CorruptDataException {
DTFJJavaRuntime rt = DTFJContext.getRuntime();
Iterator allLoaders = rt.getJavaClassLoaders();
JavaClass subclass = null;
while (allLoaders.hasNext() && (null == subclass)) {
JavaClassLoader loader = (JavaClassLoader) allLoaders.next();
Iterator classes = loader.getDefinedClasses();
while (classes.hasNext() && (null == subclass)) {
JavaClass oneClass = (JavaClass) classes.next();
if (oneClass.getName().equals(candidateClass)) {
subclass = oneClass;
break;
}
}
}
return subclass;
}
Aggregations