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();
}
}
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);
}
}
}
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);
}
}
}
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();
}
}
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());
}
Aggregations