Search in sources :

Example 1 with J9DDRStructureStore

use of com.ibm.j9ddr.tools.store.J9DDRStructureStore in project openj9 by eclipse.

the class J9DDRStructureStoreTest method add.

@Test
public void add() {
    // Test
    J9DDRStructureStore store = null;
    try {
        store = new J9DDRStructureStore("newDir", "superset.dat");
    } catch (IOException e) {
        e.printStackTrace();
        fail("Could not open store");
    }
    String original = "E:\\workspaces\\j9ddr\\DDR_VM\\data\\structure blobs\\j9ddr.dat";
    String newOne = "E:\\workspaces\\j9ddr\\DDR_VM\\data\\structure blobs\\newj9ddr.dat";
    StructureKey keyOne = new StructureKey("windows", "foo");
    StructureKey keyTwo = new StructureKey("windows", "bar");
    // String structureFileName = original;
    // StructureKey key = keyOne;
    String structureFileName = newOne;
    StructureKey key = keyTwo;
    try {
        store.add(key, structureFileName, true);
        store.close();
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    } catch (StructureMismatchError e) {
        e.printStackTrace();
        fail(e.getMessage());
    } finally {
        try {
            store.close();
        } catch (IOException e) {
            fail("Could not close store");
        }
    }
    // TODO: Open file and make sure it is good.
    try {
        store.close();
        store = null;
        store = new J9DDRStructureStore("newDir", "superset.dat");
        ImageInputStream is = store.get(key);
        FileInputStream fis = new FileInputStream(structureFileName);
        assertTrue("Files where not the same", compare(is, fis));
    } catch (IOException e) {
        fail();
    }
}
Also used : StructureKey(com.ibm.j9ddr.tools.store.StructureKey) J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) ImageInputStream(javax.imageio.stream.ImageInputStream) StructureMismatchError(com.ibm.j9ddr.tools.store.StructureMismatchError) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with J9DDRStructureStore

use of com.ibm.j9ddr.tools.store.J9DDRStructureStore in project openj9 by eclipse.

the class PointerGenerator method generateClasses.

private void generateClasses() {
    String fileName = opts.get("-f");
    String supersetFileName = opts.get("-s");
    try {
        J9DDRStructureStore store = new J9DDRStructureStore(fileName, supersetFileName);
        System.out.println("superset directory name : " + fileName);
        System.out.println("superset file name : " + store.getSuperSetFileName());
        InputStream inputStream = store.getSuperset();
        structureReader = new StructureReader(inputStream);
        inputStream.close();
    } catch (IOException e) {
        System.out.println("Problem with file: " + fileName);
        e.printStackTrace();
        return;
    }
    outputDir = getOutputDir("-p");
    if (opts.get("-h") != null) {
        // where to write the helpers to if the option is set
        outputDirHelpers = getOutputDir("-h");
    }
    typeManager = new StructureTypeManager(structureReader.getStructures());
    for (StructureDescriptor structure : structureReader.getStructures()) {
        try {
            if (FlagStructureList.isFlagsStructure(structure.getName())) {
                generateBuildFlags(structure);
            } else {
                generateClass(structure);
            }
        } catch (FileNotFoundException e) {
            String error = String.format("File Not Found processing: %s: %s", structure.getPointerName(), e.getMessage());
            System.out.println(error);
        } catch (IOException e) {
            String error = String.format("IOException processing: %s: %s", structure.getPointerName(), e.getMessage());
            System.out.println(error);
        }
    }
}
Also used : StructureTypeManager(com.ibm.j9ddr.StructureTypeManager) J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) StructureReader(com.ibm.j9ddr.StructureReader) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) StructureDescriptor(com.ibm.j9ddr.StructureReader.StructureDescriptor)

Example 3 with J9DDRStructureStore

use of com.ibm.j9ddr.tools.store.J9DDRStructureStore in project openj9 by eclipse.

the class StructureStubGenerator method generateClasses.

private void generateClasses() {
    String supersetDirectoryName = opts.get("-f");
    String supersetFileName = opts.get("-s");
    try {
        J9DDRStructureStore store = new J9DDRStructureStore(supersetDirectoryName, supersetFileName);
        System.out.println("superset directory name : " + supersetDirectoryName);
        System.out.println("superset file name : " + store.getSuperSetFileName());
        InputStream inputStream = store.getSuperset();
        structureReader = new StructureReader(inputStream);
        inputStream.close();
    } catch (IOException e) {
        System.out.println("Could not find file: " + supersetDirectoryName + "/" + supersetFileName);
        return;
    }
    outputDir = getOutputDir();
    for (StructureDescriptor structure : structureReader.getStructures()) {
        try {
            if (FlagStructureList.isFlagsStructure(structure.getName())) {
            // generateBuildFlags(structure);
            } else {
                generateClass(structure);
            }
        } catch (FileNotFoundException e) {
            String error = String.format("File Not Found processing: %s: %s", structure.getName(), e.getMessage());
            System.out.println(error);
        } catch (IOException e) {
            String error = String.format("IOException processing: %s: %s", structure.getName(), e.getMessage());
            System.out.println(error);
        }
    }
}
Also used : J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) StructureReader(com.ibm.j9ddr.StructureReader) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) StructureDescriptor(com.ibm.j9ddr.StructureReader.StructureDescriptor)

Example 4 with J9DDRStructureStore

use of com.ibm.j9ddr.tools.store.J9DDRStructureStore in project openj9 by eclipse.

the class AddStructureBlob method run.

private void run() {
    String directoryName = opts.get("-d");
    String supersetName = opts.get("-s");
    if (supersetName == null) {
        supersetName = J9DDRStructureStore.DEFAULT_SUPERSET_FILE_NAME;
    }
    try {
        J9DDRStructureStore store = new J9DDRStructureStore(directoryName, supersetName);
        String path = opts.get("-c");
        if ((null == path) || (path.length() == 0)) {
            // path for properties file not specified so default to adding from a single file or directory
            addFromFile(store);
        } else {
            // a property file controls the order in which blobs are processed
            addFromPropertiesFile(store);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (StructureMismatchError e) {
        e.printStackTrace();
    }
}
Also used : J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) StructureMismatchError(com.ibm.j9ddr.tools.store.StructureMismatchError) IOException(java.io.IOException)

Example 5 with J9DDRStructureStore

use of com.ibm.j9ddr.tools.store.J9DDRStructureStore in project openj9 by eclipse.

the class J9DDRStructureStoreTest method testOpenNonStoreDirectory.

@Test
public void testOpenNonStoreDirectory() {
    // Make a directory
    File dir = new File("bogusDir");
    boolean result = false;
    dir.delete();
    assertTrue("Could not set up test", dir.mkdir());
    try {
        new J9DDRStructureStore("bogusDir", "bogusSupersetFilename");
    } catch (IOException e) {
        result = true;
    }
    assertTrue("Should have thrown IOException when opening on non-store directory", result);
    assertTrue("Could not tear down test", dir.delete());
}
Also used : J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) IOException(java.io.IOException) File(java.io.File) Test(org.junit.Test)

Aggregations

J9DDRStructureStore (com.ibm.j9ddr.tools.store.J9DDRStructureStore)5 IOException (java.io.IOException)5 FileInputStream (java.io.FileInputStream)3 StructureReader (com.ibm.j9ddr.StructureReader)2 StructureDescriptor (com.ibm.j9ddr.StructureReader.StructureDescriptor)2 StructureMismatchError (com.ibm.j9ddr.tools.store.StructureMismatchError)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 Test (org.junit.Test)2 StructureTypeManager (com.ibm.j9ddr.StructureTypeManager)1 StructureKey (com.ibm.j9ddr.tools.store.StructureKey)1 File (java.io.File)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1