Search in sources :

Example 6 with J9DDRImageFactory

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");
    }
}
Also used : J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory) ImageFactory(com.ibm.dtfj.image.ImageFactory) ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) JavaRuntime(com.ibm.dtfj.java.JavaRuntime) ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) CorruptData(com.ibm.dtfj.image.CorruptData) Image(com.ibm.dtfj.image.Image) File(java.io.File) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory)

Example 7 with J9DDRImageFactory

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()));
    }
}
Also used : IOException(java.io.IOException) File(java.io.File) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory)

Aggregations

J9DDRImageFactory (com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory)7 Image (com.ibm.dtfj.image.Image)6 File (java.io.File)5 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)4 ImageFactory (com.ibm.dtfj.image.ImageFactory)4 IOException (java.io.IOException)4 ImageProcess (com.ibm.dtfj.image.ImageProcess)3 ImageModule (com.ibm.dtfj.image.ImageModule)2 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)2 Iterator (java.util.Iterator)2 CorruptData (com.ibm.dtfj.image.CorruptData)1 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)1 ImageSection (com.ibm.dtfj.image.ImageSection)1 ImageSymbol (com.ibm.dtfj.image.ImageSymbol)1 JavaVMInitArgs (com.ibm.dtfj.java.JavaVMInitArgs)1 JavaVMOption (com.ibm.dtfj.java.JavaVMOption)1 Method (java.lang.reflect.Method)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1