use of com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory 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.j9ddr.view.dtfj.image.J9DDRImageFactory in project openj9 by eclipse.
the class DTFJUnitTest method initFactories.
private static void initFactories() {
fixClassPath();
ddrImageFactory = new J9DDRImageFactory();
Class<?> jxfactoryclass = null;
try {
jxfactoryclass = Class.forName("com.ibm.dtfj.image.j9.ImageFactory");
} catch (ClassNotFoundException e) {
e.printStackTrace();
fail("Could not create a jextract based implementation of ImageFactory");
}
try {
jextractImageFactory = (ImageFactory) jxfactoryclass.newInstance();
} catch (InstantiationException e1) {
e1.printStackTrace();
fail("Could not create a jextract based implementation of ImageFactory");
} catch (IllegalAccessException e1) {
e1.printStackTrace();
fail("Could not create a jextract based implementation of ImageFactory");
}
try {
// allow DDR to specify it's own core file so that jextract can use zip files to work around a defect with zip handling on linux
File coreFile = new File(System.getProperty("ddr.core.file.name", System.getProperty("core")));
TestContext ctx = getDDRContext(coreFile);
ddrJavaRuntime = ctx.getRuntime();
ddrAddressSpace = ctx.getSpace();
ddrProcess = ctx.getProcess();
ddrImage = ctx.getImage();
coreFile = new File(System.getProperty("core"));
ctx = getJExtractContext(coreFile);
jextractJavaRuntime = ctx.getRuntime();
jextractAddressSpace = ctx.getSpace();
jextractProcess = ctx.getProcess();
jextractImage = ctx.getImage();
} catch (IOException e) {
e.printStackTrace();
fail(String.format("Could not retrieve JavaRuntime: %s", e.getMessage()));
}
}
Aggregations