Search in sources :

Example 1 with ICoreFileReader

use of com.ibm.dtfj.corereaders.ICoreFileReader in project openj9 by eclipse.

the class DTFJLibraryAdapter method getLibraryList.

public ArrayList<String> getLibraryList(final File coreFile) {
    if (moduleNames == null) {
        moduleNames = new ArrayList<String>();
        try {
            _parentDir = coreFile.getParentFile();
            logger.fine("Creating DTFJ core file reader");
            ClosingFileReader closingFile = new ClosingFileReader(coreFile);
            ICoreFileReader reader = DumpFactory.createDumpForCore(closingFile);
            isAIX = (reader instanceof NewAixDump);
            logger.fine("Extracting modules");
            reader.extract(this);
        } catch (FileNotFoundException e) {
            logger.log(SEVERE, "Could not open core file " + coreFile.getAbsolutePath(), e);
            errorMessages.add(e.getMessage());
        } catch (IOException e) {
            logger.log(SEVERE, "Error processing core file " + coreFile.getAbsolutePath(), e);
            errorMessages.add(e.getMessage());
        }
    }
    return moduleNames;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) IOException(java.io.IOException) NewAixDump(com.ibm.dtfj.corereaders.NewAixDump) ICoreFileReader(com.ibm.dtfj.corereaders.ICoreFileReader)

Example 2 with ICoreFileReader

use of com.ibm.dtfj.corereaders.ICoreFileReader in project openj9 by eclipse.

the class DTFJLibraryAdapter method isLibraryCollectionRequired.

public boolean isLibraryCollectionRequired(File coreFile) {
    ICoreFileReader reader = null;
    try {
        ClosingFileReader closingFile = new ClosingFileReader(coreFile);
        reader = DumpFactory.createDumpForCore(closingFile);
    } catch (Exception e) {
        logger.log(SEVERE, "Could not determine if library collection is required for " + coreFile.getAbsolutePath(), e);
        errorMessages.add(e.getMessage());
        // if this fails, then so would any collection attempt as well
        return false;
    }
    if (reader instanceof NewElfDump) {
        return true;
    }
    if (reader instanceof NewAixDump) {
        return true;
    }
    return false;
}
Also used : NewElfDump(com.ibm.dtfj.corereaders.NewElfDump) ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) NewAixDump(com.ibm.dtfj.corereaders.NewAixDump) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ICoreFileReader(com.ibm.dtfj.corereaders.ICoreFileReader)

Example 3 with ICoreFileReader

use of com.ibm.dtfj.corereaders.ICoreFileReader in project openj9 by eclipse.

the class DTFJImageFactory method getImage.

private ReleasingImage getImage(File imageFile, InputStream metadata, IFileLocationResolver resolver) throws IOException {
    ClosingFileReader reader = new ClosingFileReader(imageFile);
    ICoreFileReader core = DumpFactory.createDumpForCore(reader);
    XMLIndexReader indexData = new XMLIndexReader();
    // CMVC 154851 : pass the metadata stream through the new XML cleanup class
    XMLInputStream in = new XMLInputStream(metadata);
    ReleasingImage image = indexData.parseIndexWithDump(in, core, reader, resolver);
    image.addReleasable(in);
    image.addReleasable(reader);
    image.addReleasable(core);
    if (resolver instanceof ResourceReleaser) {
        image.addReleasable((ResourceReleaser) resolver);
    }
    return image;
}
Also used : ResourceReleaser(com.ibm.dtfj.corereaders.ResourceReleaser) XMLInputStream(com.ibm.jvm.j9.dump.indexsupport.XMLInputStream) ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) ICoreFileReader(com.ibm.dtfj.corereaders.ICoreFileReader) XMLIndexReader(com.ibm.jvm.j9.dump.indexsupport.XMLIndexReader)

Example 4 with ICoreFileReader

use of com.ibm.dtfj.corereaders.ICoreFileReader in project openj9 by eclipse.

the class DTFJImageFactory method getImage.

public Image getImage(final ImageInputStream in, final ImageInputStream meta, URI sourceID) throws IOException {
    /*
		 * Legacy core readers implement the ImageInputStream interface, but are backed by an implementation which
		 * is based around reading bytes directly from the stream without honouring the ByteOrder setting of the stream.
		 * This has the consequence that the readers expect all streams passes to them to be in BIG_ENDIAN order and
		 * then internally provide wrapper classes when LITTLE_ENDIAN is required. This is why the stream being
		 * passed has it's byte order fixed to BIG_ENDIAN.
		 */
    in.setByteOrder(ByteOrder.BIG_ENDIAN);
    ICoreFileReader core = DumpFactory.createDumpForCore(in);
    XMLIndexReader indexData = new XMLIndexReader();
    // downcast the image input stream to an input stream
    InputStream stream = new InputStream() {

        @Override
        public int read() throws IOException {
            return meta.read();
        }
    };
    // CMVC 154851 : pass the metadata stream through the new XML cleanup class
    XMLInputStream xmlstream = new XMLInputStream(stream);
    IFileLocationResolver resolver = null;
    File source = null;
    if ((sourceID.getFragment() != null) && (sourceID.getFragment().length() != 0)) {
        // need to strip any fragments from the URI which point to the core in the zip file
        try {
            URI uri = new URI(sourceID.getScheme() + "://" + sourceID.getPath());
            source = new File(uri);
        } catch (URISyntaxException e) {
        // if the URL cannot be constructed then assume it does not point to a file
        }
    } else {
        source = new File(sourceID);
    }
    if (source.exists()) {
        if (FileManager.isArchive(source)) {
            ZipFile zip = new ZipFile(source);
            resolver = new ZipExtractionResolver(zip);
        } else {
            resolver = new DefaultFileLocationResolver(source.getParentFile());
        }
    }
    ReleasingImage image = indexData.parseIndexWithDump(xmlstream, core, in, resolver);
    // close access to the XML file as we won't be needing it again
    meta.close();
    // because the IIS is used to derive the core reader only the reader needs to be added as a ReleasingResource
    image.addReleasable(core);
    if (image instanceof com.ibm.dtfj.image.j9.Image) {
        ((com.ibm.dtfj.image.j9.Image) image).SetSource(sourceID);
    }
    return image;
}
Also used : XMLInputStream(com.ibm.jvm.j9.dump.indexsupport.XMLInputStream) FileInputStream(java.io.FileInputStream) XMLInputStream(com.ibm.jvm.j9.dump.indexsupport.XMLInputStream) ImageInputStream(javax.imageio.stream.ImageInputStream) InputStream(java.io.InputStream) URISyntaxException(java.net.URISyntaxException) Image(com.ibm.dtfj.image.Image) URI(java.net.URI) ICoreFileReader(com.ibm.dtfj.corereaders.ICoreFileReader) XMLIndexReader(com.ibm.jvm.j9.dump.indexsupport.XMLIndexReader) ZipFile(java.util.zip.ZipFile) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Aggregations

ICoreFileReader (com.ibm.dtfj.corereaders.ICoreFileReader)4 ClosingFileReader (com.ibm.dtfj.corereaders.ClosingFileReader)3 NewAixDump (com.ibm.dtfj.corereaders.NewAixDump)2 XMLIndexReader (com.ibm.jvm.j9.dump.indexsupport.XMLIndexReader)2 XMLInputStream (com.ibm.jvm.j9.dump.indexsupport.XMLInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 NewElfDump (com.ibm.dtfj.corereaders.NewElfDump)1 ResourceReleaser (com.ibm.dtfj.corereaders.ResourceReleaser)1 Image (com.ibm.dtfj.image.Image)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ZipFile (java.util.zip.ZipFile)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1