use of com.ibm.dtfj.java.JavaVMOption in project openj9 by eclipse.
the class JavaVMOptionComparator method testEquals.
// getExtraInfo
// getOptionString
public void testEquals(Object ddrObject, Object jextractObject, int members) {
JavaVMOption ddrVMOption = (JavaVMOption) ddrObject;
JavaVMOption jextractVMOption = (JavaVMOption) jextractObject;
// getExtraInfo
if ((EXTRA_INFO & members) != 0)
new ImagePointerComparator().testComparatorEquals(ddrVMOption, jextractVMOption, "getExtraInfo");
// getOptionString
if ((OPTION_STRING & members) != 0)
testJavaEquals(ddrVMOption, jextractVMOption, "getOptionString");
}
use of com.ibm.dtfj.java.JavaVMOption in project openj9 by eclipse.
the class DTFJUnitTest method getVMoption.
public static final String getVMoption(JavaRuntime rt, String optionName) {
try {
JavaVMInitArgs args = rt.getJavaVMInitArgs();
Iterator<?> options = args.getOptions();
while (options.hasNext()) {
JavaVMOption option = (JavaVMOption) options.next();
String data = option.getOptionString();
if (data.startsWith(optionName)) {
return data.substring(optionName.length());
}
}
} catch (Exception e) {
throw new IllegalArgumentException("Cannot determine the value of " + optionName, e);
}
// no policy specified so using the default
return "default";
}
use of com.ibm.dtfj.java.JavaVMOption in project openj9 by eclipse.
the class J9DDRImageProcess method getExecutablePathFromSystemProperties.
private String getExecutablePathFromSystemProperties() {
Iterator<?> runtimeIt = getRuntimes();
while (runtimeIt.hasNext()) {
Object o = runtimeIt.next();
if (o instanceof JavaRuntime) {
JavaRuntime runtime = (JavaRuntime) o;
try {
JavaVMInitArgs args = runtime.getJavaVMInitArgs();
Iterator<?> optionsIt = args.getOptions();
Pattern javaHomePattern = Pattern.compile("-Djava.home=(.*)");
while (optionsIt.hasNext()) {
Object optionObj = optionsIt.next();
if (optionObj instanceof JavaVMOption) {
JavaVMOption option = (JavaVMOption) optionObj;
Matcher m = javaHomePattern.matcher(option.getOptionString());
if (m.find()) {
String javaHome = m.group(1);
// Note this method not used on Windows - don't have to worry about .exe or \
return javaHome + "/bin/java";
}
}
}
} catch (Exception e) {
// Ignore
}
}
}
return null;
}
use of com.ibm.dtfj.java.JavaVMOption in project openj9 by eclipse.
the class DTFJKickTyres method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
boolean useJExtract = false;
if (args.length > 1) {
if (args[1].toLowerCase().trim().equals("jextract")) {
useJExtract = true;
}
}
ImageFactory factory = null;
if (useJExtract) {
try {
Class<?> jxfactoryclass = Class.forName("com.ibm.dtfj.image.j9.ImageFactory");
factory = (ImageFactory) jxfactoryclass.newInstance();
} catch (Exception e) {
System.out.println("Could not create a jextract based implementation of ImageFactory");
e.printStackTrace();
System.exit(1);
}
} else {
factory = new J9DDRImageFactory();
}
Image img = factory.getImage(new File(args[0]));
Iterator<?> addressSpaceIt = img.getAddressSpaces();
while (addressSpaceIt.hasNext()) {
ImageAddressSpace as = (ImageAddressSpace) addressSpaceIt.next();
Iterator<?> processIt = as.getProcesses();
while (processIt.hasNext()) {
ImageProcess process = (ImageProcess) processIt.next();
System.err.println("Got process " + process);
try {
System.err.println("Command line was " + process.getCommandLine());
} catch (Throwable t) {
t.printStackTrace();
}
try {
System.err.println("Executable was: " + process.getExecutable());
} catch (Throwable t) {
t.printStackTrace();
}
try {
System.err.println("Modules were:");
Iterator<?> it = process.getLibraries();
if (!it.hasNext()) {
System.err.println("No modules!");
}
while (it.hasNext()) {
ImageModule module = (ImageModule) it.next();
System.err.println("* " + module.getName());
Iterator<?> symIt = module.getSymbols();
while (symIt.hasNext()) {
Object symObj = symIt.next();
if (symObj instanceof ImageSymbol) {
ImageSymbol sym = (ImageSymbol) symObj;
if (sym.getName().toLowerCase().contains("environ")) {
System.err.println("X sym " + sym.getName() + " = " + sym.getAddress());
}
}
}
}
} catch (Throwable t) {
t.printStackTrace();
}
try {
Properties env = process.getEnvironment();
System.err.println("Environment");
for (Object key : env.keySet()) {
System.err.println(key + " = " + env.getProperty((String) key));
}
} catch (Throwable t) {
t.printStackTrace();
}
Iterator<?> runtimeIt = process.getRuntimes();
while (runtimeIt.hasNext()) {
JavaRuntime runtime = (JavaRuntime) runtimeIt.next();
System.err.println("Got runtime: " + runtime);
JavaVMInitArgs initArgs = runtime.getJavaVMInitArgs();
Iterator<?> optionsIt = initArgs.getOptions();
System.err.println("Options:");
while (optionsIt.hasNext()) {
Object optionObj = optionsIt.next();
if (optionObj instanceof JavaVMOption) {
JavaVMOption option = (JavaVMOption) optionObj;
System.err.println("* " + option.getOptionString());
}
}
}
}
}
}
use of com.ibm.dtfj.java.JavaVMOption in project openj9 by eclipse.
the class InfoMemoryCommand method printDbgmallocWarning.
private void printDbgmallocWarning(PrintStream out, JavaRuntime runtime) {
try {
boolean dbgmalloc = false;
JavaVMInitArgs args = runtime.getJavaVMInitArgs();
if (args != null) {
Iterator<?> opts = args.getOptions();
while (opts.hasNext()) {
Object obj = opts.next();
if (obj instanceof JavaVMOption) {
JavaVMOption opt = (JavaVMOption) obj;
if (COM_IBM_DBGMALLOC_PROPERTY.equals(opt.getOptionString())) {
dbgmalloc = true;
}
}
}
}
if (!dbgmalloc) {
out.println();
out.printf("Note: %s was not found in the Java VM init options.\nMemory allocated by some class library components will not have been recorded.\n", COM_IBM_DBGMALLOC_PROPERTY);
}
} catch (DataUnavailable du) {
out.println("Java VM init options information unavailable.");
logger.log(Level.FINE, Exceptions.getDataUnavailableString(), du);
} catch (CorruptDataException cde) {
out.println("Corrupt Data encountered walking Java VM init options");
logger.log(Level.FINE, Exceptions.getCorruptDataExceptionString(), cde);
}
}
Aggregations