use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class WhatisCommand method checkClassInRange.
/* TODO: need to implement some output for this method and use it
private void checkMonitorInRange(Iterator monitors){
while(monitors.hasNext()){
JavaMonitor jMonitor = (JavaMonitor)monitors.next();
//TODO: need API for retrieving monitor ID (address)
//sb.append("\n" + "monitor object id: " + jMonitor.getObject().getID().getAddress());
}
}
*/
private void checkClassInRange(Iterator objects, long bound, long address) {
long startAddress, endAddress;
while (objects.hasNext()) {
JavaObject jObject = (JavaObject) objects.next();
JavaClass jClass;
String className;
try {
jClass = jObject.getJavaClass();
className = jClass.getName();
} catch (CorruptDataException cde) {
// TODO exception handling
continue;
}
startAddress = jClass.getID().getAddress();
endAddress = startAddress + bound;
if (address == startAddress) {
out.print("\t0x" + Long.toHexString(address) + " is the address of the java/lang/Class object for " + className);
return;
}
if (isWithinRange(startAddress, endAddress, address)) {
out.print("0x" + Long.toHexString(address) + " is within the java/lang/Class object for " + className);
return;
}
}
}
use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class InfoJitmCommand method showJITdMethods.
private void showJITdMethods() {
JavaRuntime jr = ctx.getRuntime();
Iterator itJavaClassLoader = jr.getJavaClassLoaders();
while (itJavaClassLoader.hasNext()) {
JavaClassLoader jcl = (JavaClassLoader) itJavaClassLoader.next();
Iterator itJavaClass = jcl.getDefinedClasses();
while (itJavaClass.hasNext()) {
JavaClass jc = (JavaClass) itJavaClass.next();
Iterator itJavaMethod = jc.getDeclaredMethods();
String jcName;
try {
jcName = jc.getName();
} catch (CorruptDataException e) {
jcName = Exceptions.getCorruptDataExceptionString();
}
while (itJavaMethod.hasNext()) {
JavaMethod jm = (JavaMethod) itJavaMethod.next();
String name;
String sig;
try {
name = jm.getName();
} catch (CorruptDataException e) {
name = Exceptions.getCorruptDataExceptionString();
}
try {
sig = jm.getSignature();
} catch (CorruptDataException e) {
sig = Exceptions.getCorruptDataExceptionString();
}
if (jm.getCompiledSections().hasNext()) {
Iterator itImageSection = jm.getCompiledSections();
while (itImageSection.hasNext()) {
ImageSection is = (ImageSection) itImageSection.next();
long startAddr = is.getBaseAddress().getAddress();
long size = is.getSize();
long endAddr = startAddr + size;
out.print("\n\t" + "start=" + Utils.toHex(startAddr) + " " + "end=" + Utils.toHex(endAddr) + " " + jcName + "::" + name + sig);
}
}
}
}
}
out.print("\n");
}
use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class InfoLockCommand method showLockedObjects.
private void showLockedObjects(Vector vMonitorsWithLockedObjects) {
out.println("\nObject Locks in use...");
if (0 == vMonitorsWithLockedObjects.size()) {
out.println("\t...None.");
return;
}
Iterator lockedObjects = vMonitorsWithLockedObjects.iterator();
while (lockedObjects.hasNext()) {
JavaMonitor jMonitor = (JavaMonitor) lockedObjects.next();
JavaObject jObject = jMonitor.getObject();
try {
JavaThread owner = jMonitor.getOwner();
String className = "<unknown class>";
JavaClass jClass = jObject.getJavaClass();
if (null != jClass) {
className = jClass.getName();
}
String jObjectID = Long.toHexString(jObject.getID().getAddress());
if (null == owner) {
out.println(className + "@0x" + jObjectID);
} else {
String owningThreadID = null;
try {
owningThreadID = owner.getImageThread().getID();
} catch (DataUnavailable e) {
owningThreadID = Exceptions.getDataUnavailableString();
}
out.println(className + "@0x" + jObjectID);
out.println("\towner thread id: " + owningThreadID + " name: " + owner.getName());
}
showWaiters(jMonitor);
} catch (CorruptDataException cde) {
logger.log(Level.FINE, Exceptions.getCorruptDataExceptionString(), cde);
}
}
}
use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class XJCommand method printObjectsFromName.
private void printObjectsFromName(JavaHeap jh, String objName, PrintStream out, boolean supers, JavaRuntime jr) {
if (objName != null) {
JavaClass[] classes = Utils.getClassGivenName(objName, jr, out);
// still be an array type or it might not exist
if (classes == null || classes.length == 0) {
out.print("\t could not find class with name \"" + objName + "\"\n\n");
return;
}
for (int i = 0; i < classes.length; i++) {
boolean foundInstance = false;
JavaClass objClass = classes[i];
if (classes.length > 1) {
ClassOutput.printRuntimeClassAndLoader(objClass, out);
}
ClassOutput.printStaticFields(objClass, out);
Iterator<?> itObject = jh.getObjects();
int corruptObjectCount = 0;
while (itObject.hasNext()) {
Object obj = itObject.next();
if (obj instanceof CorruptData) {
// skip the corrupt object
corruptObjectCount++;
continue;
}
JavaObject jo = (JavaObject) obj;
String hierarchy = "";
JavaClass jc;
try {
jc = jo.getJavaClass();
} catch (CorruptDataException e) {
out.print("\t <error getting class while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">\n");
jc = null;
}
boolean foundSuperclass = false;
while (jc != null && !foundSuperclass) {
String className;
try {
className = jc.getName();
} catch (CorruptDataException e) {
out.print("\t <error getting class name while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">\n");
jc = null;
continue;
}
if (hierarchy.equals("")) {
hierarchy = className;
} else {
hierarchy = className + " => " + hierarchy;
}
if (jc.equals(objClass)) {
foundInstance = true;
foundSuperclass = true;
out.print("\t ");
out.print(hierarchy);
out.print(" @ ");
out.print(Utils.toHex(jo.getID().getAddress()));
out.print("\n");
ClassOutput.printFields(jo, jc, jr, out);
printReferences(jo, out);
} else {
if (supers) {
try {
jc = jc.getSuperclass();
} catch (CorruptDataException e) {
out.print("\t <error getting superclass while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">\n");
jc = null;
}
} else {
jc = null;
}
}
}
}
if (!foundInstance) {
out.print("\t <no object of class \"");
out.print(objName);
out.print("\" exists>\n\n");
}
if (corruptObjectCount != 0) {
out.println("\t Warning : " + corruptObjectCount + " corrupt objects were skipped\n");
}
}
}
}
use of com.ibm.dtfj.java.JavaClass in project openj9 by eclipse.
the class XJCommand method printObjectsFromAddress.
private void printObjectsFromAddress(JavaHeap jh, Long objAddress, PrintStream out, JavaRuntime jr) {
JavaObject jo;
Iterator<?> itObject = jh.getObjects();
boolean found = false;
boolean done = false;
int corruptObjectCount = 0;
while (itObject.hasNext() && !done) {
Object obj = itObject.next();
if (obj instanceof CorruptData) {
// skip the corrupt object
corruptObjectCount++;
continue;
}
jo = (JavaObject) obj;
if (jo.getID().getAddress() == objAddress.longValue()) {
JavaClass jc;
found = true;
out.print("\t ");
try {
jc = jo.getJavaClass();
} catch (CorruptDataException e) {
out.print("\t <error getting class while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">");
jc = null;
}
if (null != jc) {
try {
out.print(jc.getName());
} catch (CorruptDataException e) {
out.print("\t <error getting class name while traversing objects: ");
out.print(Exceptions.getCorruptDataExceptionString());
out.print(">");
}
out.print(" @ ");
out.print(Utils.toHex(objAddress.longValue()));
out.print("\n");
ClassOutput.printFields(jo, jc, jr, out);
printReferences(jo, out);
// assumes only one object can exist at a specific memory address
done = true;
}
}
}
if (!found) {
out.print("\t <no object found at address ");
out.print(Utils.toHex(objAddress.longValue()));
out.print(">\n\n");
}
if (corruptObjectCount != 0) {
out.println("\t Warning : " + corruptObjectCount + " corrupt objects were skipped\n");
}
}
Aggregations