Search in sources :

Example 11 with JavaField

use of com.ibm.dtfj.java.JavaField in project openj9 by eclipse.

the class ClassOutput method printStaticFields.

public static void printStaticFields(JavaClass jc, PrintStream out) {
    // if the class name refers to an array, return because there are no fields
    try {
        if (jc.isArray()) {
            return;
        }
    } catch (CorruptDataException cde) {
        out.print("\t  <can't determine if class is array; assuming it's not>\n\n");
    }
    String className;
    try {
        className = jc.getName();
    } catch (CorruptDataException cde) {
        className = null;
    }
    // we've found a class, so we'll print out its static fields
    boolean found = false;
    Iterator itField = jc.getDeclaredFields();
    while (itField.hasNext()) {
        JavaField jf = (JavaField) itField.next();
        boolean isStatic;
        try {
            isStatic = Modifier.isStatic(jf.getModifiers());
        } catch (CorruptDataException e) {
            out.print("\t   <error while getting modifier for field \"");
            try {
                out.print(jf.getName());
            } catch (CorruptDataException d) {
                out.print(Exceptions.getCorruptDataExceptionString());
            }
            out.print("\", " + Exceptions.getCorruptDataExceptionString() + ">");
            isStatic = false;
        }
        if (isStatic) {
            if (!found) {
                out.print("\t  static fields for \"" + className + "\"\n");
            }
            found = true;
            printStaticFieldData(jf, out);
        }
    }
    if (found)
        out.print("\n");
    else
        out.print("\t  \"" + className + "\" has no static fields\n\n");
}
Also used : JavaField(com.ibm.dtfj.java.JavaField) Iterator(java.util.Iterator) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Aggregations

JavaField (com.ibm.dtfj.java.JavaField)11 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)7 JavaObject (com.ibm.dtfj.java.JavaObject)7 Iterator (java.util.Iterator)7 JavaClass (com.ibm.dtfj.java.JavaClass)5 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)3 CorruptData (com.ibm.dtfj.image.CorruptData)2 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)2 J9Object (com.ibm.j9ddr.vm29.structure.J9Object)2 CorruptJavaObject (com.ibm.j9ddr.vm29.view.dtfj.java.corrupt.CorruptJavaObject)2 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)1 IDTFJJavaField (com.ibm.j9ddr.view.dtfj.java.IDTFJJavaField)1 StateToString (com.ibm.jvm.dtfjview.commands.helpers.StateToString)1 LongListReferenceIterator (com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator)1 ReferenceIterator (com.ibm.jvm.dtfjview.heapdump.ReferenceIterator)1 ArrayList (java.util.ArrayList)1