use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class PHDJavaRuntime method prepClassLoaders.
/**
* Remember objects associated with class loaders
* Performance optimization - we can then find these objects on a scan through the heap
* and remember them, saving a fruitless search of the heap if they only exist in a javacore.
*/
private void prepClassLoaders() {
if (metaJavaRuntime != null) {
final PHDJavaClassLoader boot = loaders.get(null);
for (Iterator it = metaJavaRuntime.getJavaClassLoaders(); it.hasNext(); ) {
Object next = it.next();
if (next instanceof CorruptData)
continue;
JavaClassLoader load = (JavaClassLoader) next;
try {
JavaObject jo = load.getObject();
saveExtraObject(boot, jo);
} catch (CorruptDataException e) {
}
}
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class PHDJavaRuntime method saveExtraObject.
private void saveExtraObject(final PHDJavaClassLoader boot, JavaObject jo) {
if (jo != null) {
long addr = jo.getID().getAddress();
JavaClass cls;
try {
cls = boot.findClassUnique(jo.getJavaClass().getName());
} catch (CorruptDataException e) {
cls = null;
}
// Construct a dummy object with little information in case the object is not in the heap
JavaObject jo2 = new PHDJavaObject.Builder(heaps.get(0), addr, cls, PHDJavaObject.NO_HASHCODE, -1).refsAsArray(NOREFS, 0).length(PHDJavaObject.UNKNOWN_TYPE).build();
extraObjectsCache.put(addr, jo2);
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class Utils method getClassGivenName.
public static JavaClass[] getClassGivenName(String className, JavaRuntime jr, PrintStream out) {
Iterator itJavaClassLoader = jr.getJavaClassLoaders();
List classes = new ArrayList();
while (itJavaClassLoader.hasNext()) {
Object nextCl = itJavaClassLoader.next();
if (!(nextCl instanceof JavaClassLoader)) {
continue;
}
JavaClassLoader jcl = (JavaClassLoader) nextCl;
Iterator itJavaClass = jcl.getDefinedClasses();
while (itJavaClass.hasNext()) {
Object next = itJavaClass.next();
if (!(next instanceof JavaClass)) {
continue;
}
JavaClass jc = (JavaClass) next;
String currClassName;
try {
currClassName = jc.getName();
if (currClassName.equals(className)) {
classes.add(jc);
}
} catch (CorruptDataException e) {
out.print("\t <error getting class name while traversing classes: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">\n");
currClassName = null;
}
}
}
if (classes.size() > 0) {
return (JavaClass[]) classes.toArray(new JavaClass[0]);
} else {
return null;
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class Utils method getVal.
// note: this method lets you pass in a null JavaObject, but it _will_ throw a
// NullPointerException if the JavaField is not a static field when you pass it
// a null JavaObject; this is the behavior of jf.get() and jf.getString()
public static String getVal(JavaObject jo, JavaField jf) {
Object o;
String s;
if (null == jf) {
o = jo;
s = null;
} else {
try {
o = jf.get(jo);
} catch (CorruptDataException e) {
return "<corrupt data>";
} catch (MemoryAccessException d) {
return "<invalid memory address>";
} catch (NumberFormatException nfe) {
return "<invalid number>";
}
try {
s = jf.getString(jo);
} catch (CorruptDataException e) {
s = null;
} catch (MemoryAccessException e) {
s = null;
} catch (IllegalArgumentException e) {
s = null;
}
}
return getVal(o, s, jf);
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class Utils method getVal.
public static String getVal(Object o, String str, JavaField jf) {
String val = "";
Long value = null;
boolean object = false;
if (null == o) {
val += "null";
} else {
if (o instanceof Boolean) {
val += ((Boolean) o).toString();
} else if (o instanceof Byte) {
byte b = ((Byte) o).byteValue();
val += String.valueOf(b);
value = new Long((new Byte(b)).longValue());
} else if (o instanceof Character) {
char c = ((Character) o).charValue();
val += Utils.getPrintableWithQuotes(c);
value = new Long((new Integer((int) c).longValue()));
} else if (o instanceof Double) {
double d = ((Double) o).doubleValue();
val += String.valueOf(d);
value = new Long(Double.doubleToRawLongBits(d));
} else if (o instanceof Float) {
float f = ((Float) o).floatValue();
val += String.valueOf(f);
value = new Long(Float.floatToRawIntBits(f));
} else if (o instanceof Integer) {
int i = ((Integer) o).intValue();
val += String.valueOf(i);
value = new Long((new Integer(i)).longValue());
} else if (o instanceof Long) {
long l = ((Long) o).longValue();
val += String.valueOf(l);
value = new Long(l);
} else if (o instanceof Short) {
short s = ((Short) o).shortValue();
val += String.valueOf(s);
value = new Long((new Short(s)).longValue());
} else if (o instanceof String) {
val += (String) o;
} else if (o instanceof JavaObject) {
if (Utils.isNull((JavaObject) o)) {
val += "null";
} else {
object = true;
}
} else {
// FIXME
}
// because we want control over the exceptions that are thrown
if (object) {
JavaObject joField = (JavaObject) o;
JavaClass jcField;
String jcName;
try {
jcField = joField.getJavaClass();
} catch (CorruptDataException e) {
jcField = null;
}
try {
if (null != jcField) {
jcName = jcField.getName();
} else {
jcName = null;
}
} catch (CorruptDataException e) {
jcName = null;
}
if (null != jcName && jcName.equals("java/lang/String")) {
if (null == str) {
val += getStringVal(joField);
} else {
val += "\"" + Utils.getPrintable(str) + "\"";
}
val += " @ ";
val += Utils.toHex(joField.getID().getAddress());
} else {
val += "<object>" + " @ " + Utils.toHex(joField.getID().getAddress());
}
}
}
if (null != value) {
val += " (";
val += Utils.toHex(value.longValue());
val += ")";
}
return val;
}
Aggregations