use of com.ibm.dtfj.image.ImageFactory in project openj9 by eclipse.
the class DTFJTest method getRuntime.
public JavaRuntime getRuntime(File core) throws Exception {
ImageFactory factory = getImageFactory();
Image image = factory.getImage(core);
log.finest("Image returned: " + image);
@SuppressWarnings("unchecked") Iterator addressSpaceIt = image.getAddressSpaces();
while (addressSpaceIt.hasNext()) {
Object asObj = addressSpaceIt.next();
if (asObj instanceof CorruptData) {
log.warning("Corrupt AddressSpace returned: " + asObj);
} else if (asObj instanceof ImageAddressSpace) {
ImageAddressSpace as = (ImageAddressSpace) asObj;
log.finest("Address Space: " + as + " found");
@SuppressWarnings("unchecked") Iterator processIterator = as.getProcesses();
while (processIterator.hasNext()) {
Object processObj = processIterator.next();
if (processObj instanceof CorruptData) {
log.warning("Corrupt ImageProcess returned: " + asObj);
} else if (processObj instanceof ImageProcess) {
ImageProcess process = (ImageProcess) processObj;
log.finest("ImageProcess: " + process + " found");
@SuppressWarnings("unchecked") Iterator runtimeIterator = process.getRuntimes();
while (runtimeIterator.hasNext()) {
Object runtimeObj = runtimeIterator.next();
if (runtimeObj instanceof CorruptData) {
log.warning("Corrupt ImageProcess returned: " + asObj);
} else if (runtimeObj instanceof JavaRuntime) {
JavaRuntime runtime = (JavaRuntime) runtimeObj;
log.finer("JavaRuntime found: " + runtime + ", was loaded by " + runtime.getClass().getClassLoader());
return runtime;
} else {
throw new ClassCastException("Unexpected type from Runtime iterator: " + runtimeObj.getClass() + ": " + runtimeObj);
}
}
} else {
throw new ClassCastException("Unexpected type from Process iterator: " + processObj.getClass() + ": " + processObj);
}
}
} else {
throw new ClassCastException("Unexpected type from AddressSpace iterator: " + asObj.getClass() + ": " + asObj);
}
}
throw new RuntimeException("Could not find a Java Runtime");
}
use of com.ibm.dtfj.image.ImageFactory in project openj9 by eclipse.
the class JExtractXMLGenerator method getRuntime.
@SuppressWarnings("unchecked")
private JavaRuntime getRuntime() throws Exception {
ImageFactory factory = new J9DDRImageFactory();
File core = new File(opts.get(OPT_CORE_FILE));
if (core.exists()) {
Image image = factory.getImage(core);
for (Iterator spaces = image.getAddressSpaces(); spaces.hasNext(); ) {
Object space = spaces.next();
if (!(space instanceof CorruptData)) {
for (Iterator processes = ((ImageAddressSpace) space).getProcesses(); processes.hasNext(); ) {
Object process = processes.next();
if (!(process instanceof CorruptData)) {
for (Iterator runtimes = ((ImageProcess) process).getRuntimes(); runtimes.hasNext(); ) {
Object runtime = runtimes.next();
if (runtime instanceof JavaRuntime) {
return (JavaRuntime) runtime;
}
}
}
}
}
}
writeComment("Could not find Java runtime in core file");
throw new IllegalArgumentException("Could not find Java runtime");
} else {
throw new IllegalArgumentException("The specified core file : " + core.getAbsolutePath() + " does not exist");
}
}
use of com.ibm.dtfj.image.ImageFactory in project openj9 by eclipse.
the class ImageFactoryTest method getDTFJMinorVersion.
@Test
public void getDTFJMinorVersion() {
for (int i = 0; i != ddrTestObjects.size(); i++) {
ImageFactory ddrFactory = (ImageFactory) ddrTestObjects.get(i);
ImageFactory jextractFactory = (ImageFactory) jextractTestObjects.get(i);
assertTrue(ddrFactory.getDTFJMinorVersion() >= jextractFactory.getDTFJMinorVersion());
}
}
use of com.ibm.dtfj.image.ImageFactory in project openj9 by eclipse.
the class ImageFactoryTest method getDTFJModificationLevel.
@Test
public void getDTFJModificationLevel() {
for (int i = 0; i != ddrTestObjects.size(); i++) {
ImageFactory ddrFactory = (ImageFactory) ddrTestObjects.get(i);
ImageFactory jextractFactory = (ImageFactory) jextractTestObjects.get(i);
assertEquals(jextractFactory.getDTFJModificationLevel(), ddrFactory.getDTFJModificationLevel());
}
}
use of com.ibm.dtfj.image.ImageFactory in project openj9 by eclipse.
the class ImageFactoryTest method getDTFJMajorVersion.
@Test
public void getDTFJMajorVersion() {
for (int i = 0; i != ddrTestObjects.size(); i++) {
ImageFactory ddrFactory = (ImageFactory) ddrTestObjects.get(i);
ImageFactory jextractFactory = (ImageFactory) jextractTestObjects.get(i);
assertEquals(jextractFactory.getDTFJMajorVersion(), ddrFactory.getDTFJMajorVersion());
}
}
Aggregations