com.ibm.dtfj.java

Interface JavaClass


  1. public interface JavaClass
Represents a Java class.

Method Summary

Modifier and Type Method and Description
  1. boolean
equals(java.lang.Object obj)
  1. JavaClassLoader
getClassLoader()
Fetch the class loader associated with this class.
  1. JavaClass
getComponentType()
For array classes, returns a JavaClass representing the component type of this array class.
  1. java.util.Iterator
getConstantPoolReferences()
Java classes may refer to other classes and to String objects via the class's constant pool.
  1. java.util.Iterator
getDeclaredFields()
Get the set of fields declared in this class.
  1. java.util.Iterator
getDeclaredMethods()
Get the set of methods declared in this class.
  1. ImagePointer
getID()
The ID of a class is a pointer to a section of memory which identifies the class.
  1. long
getInstanceSize()
Returns the size in bytes of an instance of this class on the heap.
  1. java.util.Iterator
getInterfaces()
Get the set of names of interfaces directly implemented by this class.
  1. int
getModifiers()
Return the Java language modifiers for this class.
  1. java.lang.String
getName()
Get the name of the class.
  1. JavaObject
getObject()
Fetch the java.lang.Class object associated with this class.
  1. java.util.Iterator
getReferences()
Get the set of references from this class.
  1. JavaClass
getSuperclass()
Get the immediate superclass of this class.
  1. int
hashCode()
  1. boolean
isArray()
Is this an array class ?

Method Detail

getObject

  1. JavaObject getObject()
  2. throws CorruptDataException
Fetch the java.lang.Class object associated with this class.

In some implementations this may be null if no object has been created to represent this class, or if the class is synthetic.

Returns:
the java.lang.Class object associated with this class
Throws:
See Also:

getClassLoader

  1. JavaClassLoader getClassLoader( )
  2. throws CorruptDataException
Fetch the class loader associated with this class. Classes defined in the bootstrap class loader (including classes representing primitive types or void) will always return a JavaClassLoader representing the bootstrap class loader. This asymmetry with java.lang.Class#getClassLoader() is intentional.
Returns:
the JavaClassLoader in which this class was defined
Throws:
CorruptDataException - if the class loader for this class cannot be found (a class cannot exist without a loader so this implies corruption)

getName

  1. java.lang.String getName()
  2. throws CorruptDataException
Get the name of the class.
Returns:
the name of the class in the form: "full/package/class$innerclass"
Throws:

getSuperclass

  1. JavaClass getSuperclass()
  2. throws CorruptDataException
Get the immediate superclass of this class.
Returns:
the immediate superclass of this class, or null if this class has no superclass. For interfaces, Object, primitive types and void null is always returned.
Throws:

getInterfaces

  1. java.util.Iterator getInterfaces( )
Get the set of names of interfaces directly implemented by this class.
Returns:
an iterator over the collection of the names of interfaces directly implemented by this class. Some JVM implementations may choose to load interfaces lazily, so only the names are returned. The JavaClass objects may be found through the defining class loader.
See Also:

getModifiers

  1. int getModifiers()
  2. throws CorruptDataException
Return the Java language modifiers for this class.

The modifiers are defined by the JVM Specification.

Note that, for inner classes, the actual modifiers are returned, not the synthetic modifiers. For instance, a class will never have its 'protected' modifier set, even if the inner class was a protected member, since 'protected' is not a legal modifier for a class file.

Returns:
the modifiers for this class
Throws:

isArray

  1. boolean isArray()
  2. throws CorruptDataException
Is this an array class ?
Returns:
true if this class is an array class
Throws:

getComponentType

  1. JavaClass getComponentType()
  2. throws CorruptDataException
For array classes, returns a JavaClass representing the component type of this array class.
Returns:
a JavaClass representing the component type of this array class
Throws:
java.lang.IllegalArgumentException - if this JavaClass does not represent an array class

getDeclaredFields

  1. java.util.Iterator getDeclaredFields( )
Get the set of fields declared in this class.
Returns:
an iterator over the collection of fields declared in this class.
See Also:

getDeclaredMethods

  1. java.util.Iterator getDeclaredMethods( )
Get the set of methods declared in this class.
Returns:
an iterator over the collection of methods declared in this class.
See Also:

getConstantPoolReferences

  1. java.util.Iterator getConstantPoolReferences( )
Java classes may refer to other classes and to String objects via the class's constant pool. These references are followed by the garbage collector, forming edges on the graph of reachable objects. This getConstantPoolReferences() may be used to determine which objects are referred to by the receiver's constant pool.

Although Java VMs typically permit only Class and String objects in the constant pool, some esoteric or future virtual machines may permit other types of objects to occur in the constant pool. This API imposes no restrictions on the types of JavaObjects which might be included in the Iterator.

No assumption should be made about the order in which constant pool references are returned.

Classes may also refer to objects through static variables. These may be found with the getDeclaredFields() API. Objects referenced by static variables are not returned by getConstantPoolReferences() unless the object is also referenced by the constant pool.

Returns:
an iterator over the collection of JavaObjects which are referred to by the constant pool of this class
See Also:

getID

  1. ImagePointer getID()
The ID of a class is a pointer to a section of memory which identifies the class. The contents of this memory are implementation defined.

In some implementations getID() and getObject().getID() may return the same value. This implies that the class object is also the primary internal representation of the class. DTFJ users should not rely on this behaviour.

In some implementations, getID() may return null for some classes. This indicates that the class is a synthetic class which has been constructed for DTFJ purposes only. The class has no physical representation in the VM.

Returns:
a pointer to the class

getReferences

  1. java.util.Iterator getReferences( )
Get the set of references from this class.
Returns:
an iterator of JavaReferences
See Also:

equals

  1. boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
True if the given object refers to the same Java Class in the image

getInstanceSize

  1. long getInstanceSize()
  2. throws DataUnavailable
  3. CorruptDataException
Returns the size in bytes of an instance of this class on the heap.

The call is only meaningful for a non-array JavaClass, where all instances of the class are of the same size. If this method is called on a JavaArrayClass, where instances can be of different sizes, an UnsupportedOperationException will be thrown. DataUnavailable can be thrown if no value is available: for example when DTFJ is examining a javacore, where the instance size for a class is not recorded.

Returns:
size in bytes of an instance
Throws:
DataUnavailable, - CorruptDataException
java.lang.UnsupportedOperationException - if the JavaClass is an instance of JavaArrayClass
Since:
1.6

hashCode

  1. int hashCode()
Overrides:
hashCode in class java.lang.Object