use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class Utils method getStringVal.
private static String getStringVal(JavaObject jo) {
JavaClass jc;
try {
jc = jo.getJavaClass();
} catch (CorruptDataException e) {
return "<cannot get String class from String object (" + Exceptions.getCorruptDataExceptionString() + ")>";
}
Iterator itJavaField = jc.getDeclaredFields();
JavaField jf = null;
while (itJavaField.hasNext()) {
jf = (JavaField) itJavaField.next();
try {
if (jf.getSignature().equals("[C") && !Modifier.isStatic(jf.getModifiers()))
break;
} catch (CorruptDataException e) {
// if we have an exception, do nothing and go onto the next field
}
}
if (jf == null) {
// empty field iterator (occurs e.g. when reading PHD heapdumps), can't get the char array
return "<cannot get char array out of String>";
}
JavaObject charArray = null;
try {
charArray = (JavaObject) jf.get(jo);
} catch (CorruptDataException e) {
return "<cannot get char array out of String (" + Exceptions.getCorruptDataExceptionString() + ")>";
} catch (MemoryAccessException e) {
return "<cannot get char array out of String (" + Exceptions.getMemoryAccessExceptionString() + ")>";
}
int arraySize;
try {
arraySize = charArray.getArraySize();
} catch (CorruptDataException e) {
return "<cannot determine the size of the array (" + Exceptions.getCorruptDataExceptionString() + ")>";
}
char[] dst = new char[arraySize];
try {
charArray.arraycopy(0, dst, 0, arraySize);
} catch (CorruptDataException e) {
return "<cannot copy data from the array (" + Exceptions.getCorruptDataExceptionString() + ")>";
} catch (MemoryAccessException e) {
return "<cannot copy data from the array (" + Exceptions.getMemoryAccessExceptionString() + ")>";
}
return "\"" + Utils.getPrintable(new String(dst)) + "\"";
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class InfoProcCommand method printJITOptions.
private void printJITOptions() {
try {
if (ctx.getRuntime().isJITEnabled()) {
out.println("\t JIT was enabled for this runtime");
Properties props = ctx.getRuntime().getJITProperties();
StringBuilder options = new StringBuilder("\t ");
for (Object key : props.keySet()) {
options.append(" " + key + " " + props.get(key) + ",");
}
out.println(options.substring(0, options.length() - 1));
} else {
out.println("\t JIT was disabled for this runtime");
}
} catch (CorruptDataException e) {
out.println("\t JIT options\n");
} catch (DataUnavailable e) {
out.println("\t JIT options not supported by this implementation of DTFJ");
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class InfoProcCommand method printEnvironmentVariables.
private void printEnvironmentVariables() {
ImageProcess ip = ctx.getProcess();
out.print("\t Environment variables:");
out.print("\n");
Properties variables;
try {
variables = ip.getEnvironment();
} catch (CorruptDataException e) {
out.print("\t " + Exceptions.getCorruptDataExceptionString() + "\n");
return;
} catch (DataUnavailable e) {
out.print("\t " + Exceptions.getDataUnavailableString() + "\n");
return;
}
Enumeration<?> keys = variables.propertyNames();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
printVariableInfo(key, variables.getProperty(key));
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class InfoSymCommand method listModules.
private void listModules(String moduleName) {
ImageProcess ip = ctx.getProcess();
try {
Object e = ip.getExecutable();
if (e instanceof ImageModule) {
ImageModule exe = (ImageModule) e;
if (moduleName != null) {
if (checkModuleName(exe.getName(), moduleName)) {
printModule(exe, true);
}
} else {
printModule(exe, false);
}
} else if (e instanceof CorruptData) {
CorruptData corruptObj = (CorruptData) e;
// warn the user that this image library is corrupt
out.print("\t <corrupt executable encountered: " + corruptObj.toString() + ">\n\n");
}
} catch (DataUnavailable e) {
out.println(Exceptions.getDataUnavailableString());
} catch (CorruptDataException e) {
out.println(Exceptions.getCorruptDataExceptionString());
}
Iterator iLibs;
try {
iLibs = ip.getLibraries();
} catch (DataUnavailable du) {
iLibs = null;
out.println(Exceptions.getDataUnavailableString());
} catch (CorruptDataException cde) {
iLibs = null;
out.println(Exceptions.getCorruptDataExceptionString());
}
// iterate through the libraries
while (null != iLibs && iLibs.hasNext()) {
Object next = iLibs.next();
if (next instanceof ImageModule) {
ImageModule mod = (ImageModule) next;
String currentName = null;
try {
currentName = mod.getName();
} catch (CorruptDataException e) {
out.print("\t <corrupt library name: " + mod.toString() + ">\n\n");
}
if (moduleName != null) {
if (checkModuleName(currentName, moduleName)) {
printModule(mod, true);
}
} else {
printModule(mod, false);
}
} else if (next instanceof CorruptData) {
CorruptData corruptObj = (CorruptData) next;
// warn the user that this image library is corrupt
out.print("\t <corrupt library encountered: " + corruptObj.toString() + ">\n\n");
} else {
// unexpected type in iterator
out.print("\t <corrupt library encountered>\n\n");
}
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class InfoClassCommand method printClassDetails.
private void printClassDetails(JavaRuntime jr, String className, JavaClass jc) {
String spaces = " ";
String cdeInfo = "N/A (CorruptDataException occurred)";
try {
out.print("name = " + jc.getName());
} catch (CorruptDataException dce) {
out.print("name = " + cdeInfo);
}
out.print("\n\n\t");
out.print("ID = " + Utils.toHex(jc.getID()));
String superClassId;
try {
JavaClass superClass = jc.getSuperclass();
if (null == superClass) {
superClassId = "<no superclass>";
} else {
superClassId = Utils.toHex(superClass.getID());
}
} catch (CorruptDataException dce) {
superClassId = cdeInfo;
}
out.print(spaces);
out.print("superID = " + superClassId);
// Omitting size of class because that might differ between instances (i.e. arrays)
String classLoaderId;
try {
JavaClassLoader jClassLoader = jc.getClassLoader();
JavaObject jo = jClassLoader.getObject();
if (jo != null) {
classLoaderId = Utils.toHex(jo.getID());
} else {
classLoaderId = "<data unavailable>";
}
} catch (CorruptDataException cde) {
classLoaderId = cdeInfo;
}
out.print(spaces);
out.print("\n\t");
out.print("classLoader = " + classLoaderId);
String modifiersInfo;
try {
modifiersInfo = Utils.getClassModifierString(jc);
} catch (CorruptDataException cde) {
modifiersInfo = cdeInfo;
}
out.print(spaces);
out.print("modifiers: " + modifiersInfo);
out.print("\n\n");
ClassStatistics d = getClassStatisticsFor(jr, jc);
out.print("\tnumber of instances: " + d.getCount() + "\n");
out.print("\ttotal size of instances on the heap: " + d.getSize() + " bytes");
out.print("\n\n");
printClassHierarchy(jc);
out.print("\n");
printFields(jc);
out.print("\n");
printMethods(jc);
}
Aggregations