use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.
the class DTFJHeapUnitTest method setUp.
@Before
public void setUp() throws Exception {
File core = parseCoreFilePath(getSystemProperty(PROPERTY_CORE_FILE_PATH));
File output = new File(getSystemProperty(PROPERTY_OUTPUT_PATH));
if (!output.exists()) {
output.mkdirs();
}
JavaRuntime rt = getRuntime(core);
File jxoutput = new File(output, "dtfj.xml");
filesToCompare[0] = jxoutput.getPath();
generateXML(jxoutput, rt);
testJ9DDR = true;
rt = getRuntime(core);
File ddroutput = new File(output, "ddr.xml");
filesToCompare[1] = ddroutput.getPath();
generateXML(ddroutput, rt);
}
use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.
the class JExtractXMLGenerator method generate.
/**
* Generate a JExtract compatible XML file
*/
public void generate() {
try {
xml.append("<j9dump>\n");
JavaRuntime rt = getRuntime();
generateJavaVM(rt);
xml.append("</j9dump>\n");
} catch (Exception e) {
// catch all errors and write out what data we have so far
System.err.println("Error generating XML : " + e.getMessage());
e.printStackTrace();
}
createOutputFile();
}
use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.
the class ImageFactory method hasJavaRuntime.
/**
* Checks to see if the supplied image has an available DTFJ Java Runtime. This is to force the parsing of the jextract XML
* for legacy DTFJ and blob parsing for DDR. It does not make any guarantees about the quality and availability of the
* run time data.
* @return true if a non-corrupt runtime is returned
*/
private static boolean hasJavaRuntime(ImageReference imageReference) {
if (null == imageReference || null == imageReference.image) {
return false;
}
Iterator<?> spaces = imageReference.image.getAddressSpaces();
while ((null != spaces) && spaces.hasNext()) {
// search address spaces
Object obj = spaces.next();
if ((null != obj) && (obj instanceof ImageAddressSpace)) {
ImageAddressSpace space = (ImageAddressSpace) obj;
Iterator<?> procs = space.getProcesses();
while ((null != procs) && procs.hasNext()) {
// search processes
Object procobj = procs.next();
if ((null != procobj) && (procobj instanceof ImageProcess)) {
ImageProcess proc = (ImageProcess) procobj;
Iterator<?> runtimes = proc.getRuntimes();
while ((null != runtimes) && runtimes.hasNext()) {
Object rtobj = runtimes.next();
if ((null != rtobj) && (rtobj instanceof JavaRuntime)) {
// found a non-corrupt java runtime
return true;
}
}
}
}
}
}
return false;
}
use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.
the class InfoThreadCommand method getJavaThreads.
private Map getJavaThreads(String id) {
Map threads = new HashMap();
ManagedRuntime mr = ctx.getRuntime();
if (mr instanceof JavaRuntime) {
JavaRuntime jr = (JavaRuntime) mr;
Iterator itThread = jr.getThreads();
while (itThread.hasNext()) {
Object next = itThread.next();
// skip any corrupt threads
if (next instanceof CorruptData)
continue;
JavaThread jt = (JavaThread) next;
// Obtain the native thread ID for this thread, and for zOS also obtain the TCB
String currentTID = null;
String currentTCB = null;
try {
ImageThread it = jt.getImageThread();
currentTID = it.getID();
if (_is_zOS) {
currentTCB = it.getProperties().getProperty("TCB");
}
} catch (DTFJException e) {
// Continue with what we have obtained so far
}
if (null == id) {
// save all orphaned java threads in a list within the hashmap
if (null == currentTID) {
if (threads.containsKey(null)) {
ArrayList ta = (ArrayList) threads.get(null);
ta.add(new ThreadData(jt, jr));
} else {
ArrayList ta = new ArrayList(1);
ta.add(new ThreadData(jt, jr));
threads.put(null, ta);
}
} else {
threads.put(currentTID, new ThreadData(jt, jr));
}
} else if (id.equalsIgnoreCase(currentTID) || id.equalsIgnoreCase(currentTCB)) {
// We just want the specific Java thread that matches the native thread ID or zOS TCB
threads.put(currentTID, new ThreadData(jt, jr));
}
}
}
return threads;
}
use of com.ibm.dtfj.java.JavaRuntime in project openj9 by eclipse.
the class JavaRuntimeComparator method testEquals.
// getCompiledMethods()
// getHeapRoots()
// getHeaps()
// getJavaClassLoaders()
// getJavaVM()
// getJavaVMInitArgs()
// getMonitors()
// getThreads()
public void testEquals(Object ddrObject, Object jextractObject, int members) {
JavaRuntime ddrJavaRuntime = (JavaRuntime) ddrObject;
JavaRuntime jextractJavaRuntime = (JavaRuntime) jextractObject;
// getCompiledMethods()
if ((COMPILED_METHODS & members) != 0)
new JavaMethodComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getCompiledMethods", JavaMethod.class);
// getHeaps()
if ((HEAPS & members) != 0)
new JavaHeapComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getHeaps", JavaHeap.class);
// getJavaClassLoaders()
if ((JAVA_CLASS_LOADERS & members) != 0)
new JavaClassLoaderComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getJavaClassLoaders", JavaClassLoader.class);
// getJavaVM()
if ((JAVA_VM & members) != 0)
new ImagePointerComparator().testComparatorEquals(ddrJavaRuntime, jextractJavaRuntime, "getJavaVM");
// getJavaVMInitArgs()
if ((JAVA_VM_INIT_ARGS & members) != 0)
new JavaVMInitArgsComparator().testComparatorEquals(ddrJavaRuntime, jextractJavaRuntime, "getJavaVMInitArgs");
// getMonitors()
if ((MONITORS & members) != 0)
new JavaMonitorComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getMonitors", JavaMonitor.class);
// getThreads()
if ((THREADS & members) != 0)
new JavaThreadComparator().testComparatorIteratorEquals(ddrJavaRuntime, jextractJavaRuntime, "getThreads", JavaThread.class);
}
Aggregations