use of com.ibm.dtfj.image.Image in project openj9 by eclipse.
the class ImageCreator method createProcessImage.
/* (non-Javadoc)
* @see com.ibm.dtfj.tck.api.IImageCreator#createProcessImage(com.ibm.dtfj.tck.api.TCKConfiguration)
*/
public Image createProcessImage(TCKConfiguration conf) throws IOException {
fixClassPath();
String systemDump = System.getProperty("system.dump");
if (systemDump == null) {
throw new IllegalArgumentException("You need to specify a system dump with -Dsystem.dump=");
}
J9DDRImageFactory factory = new J9DDRImageFactory();
Image image = factory.getImage(new File(systemDump));
if (null == image) {
throw new IOException("Cannot get DTFJ image from " + systemDump);
}
return image;
}
use of com.ibm.dtfj.image.Image 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.Image in project openj9 by eclipse.
the class DTFJUnitTest method buildContext.
private static TestContext buildContext(ImageFactory imageFactory, File coreFile) throws IOException {
TestContext ctx = new DTFJUnitTest.TestContext();
Image image = imageFactory.getImage(coreFile);
ctx.setImage(image);
Iterator<?> addressSpaceIt = image.getAddressSpaces();
while (addressSpaceIt.hasNext()) {
Object asObj = addressSpaceIt.next();
if (asObj instanceof CorruptData) {
System.err.println("Corrupt AddressSpace returned: " + asObj);
} else if (asObj instanceof ImageAddressSpace) {
ImageAddressSpace as = (ImageAddressSpace) asObj;
ctx.setSpace(as);
Iterator<?> processIterator = as.getProcesses();
while (processIterator.hasNext()) {
Object processObj = processIterator.next();
if (processObj instanceof CorruptData) {
System.err.println("Corrupt ImageProcess returned: " + asObj);
} else if (processObj instanceof ImageProcess) {
ImageProcess process = (ImageProcess) processObj;
ctx.setProcess(process);
Iterator<?> runtimeIterator = process.getRuntimes();
while (runtimeIterator.hasNext()) {
Object runtimeObj = runtimeIterator.next();
if (runtimeObj instanceof CorruptData) {
System.err.println("Corrupt ImageProcess returned: " + asObj);
} else if (runtimeObj instanceof JavaRuntime) {
JavaRuntime runtime = (JavaRuntime) runtimeObj;
ctx.setRuntime(runtime);
return ctx;
} 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.Image in project openj9 by eclipse.
the class ImageTest method getProcessorSubTypeTest.
@Test
public void getProcessorSubTypeTest() {
for (int i = 0; i != ddrTestObjects.size(); i++) {
Image ddrImg = (Image) ddrTestObjects.get(i);
Image jextractImg = (Image) jextractTestObjects.get(i);
imageComparator.testEquals(ddrImg, jextractImg, ImageComparator.PROCESSOR_SUB_TYPE);
}
}
use of com.ibm.dtfj.image.Image in project openj9 by eclipse.
the class ImageTest method getSystemSubTypeTest.
@Test
public void getSystemSubTypeTest() {
for (int i = 0; i != ddrTestObjects.size(); i++) {
Image ddrImg = (Image) ddrTestObjects.get(i);
Image jextractImg = (Image) jextractTestObjects.get(i);
imageComparator.testEquals(ddrImg, jextractImg, ImageComparator.SYSTEM_SUB_TYPE);
}
}
Aggregations