Iterator itObject = jh.getObjects().iterator();
boolean found = false;
if (objName != null)
{
JavaClass objClass = Utils.getClassGivenName(objName, jr, out);
// if we couldn't find a class of that name, return; the passed in class name could
// still be an array type or it might not exist
if (null == objClass)
{
out.print("\t could not find class with name \"" + objName + "\"\n\n");
return;
}
ClassOutput.printStaticFields(objClass, out);
while (itObject.hasNext())
{
jo = (JavaObject)itObject.next();
String className;
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)
{
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 (className.equals(objName))
{
found = 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);
}
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;
}
}
}
}
}
else // objAddress != null
{
boolean done = false;
while (itObject.hasNext() && !done)
{
jo = (JavaObject)itObject.next();
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(">");
}