Class JCJavaClass

java.lang.Object
com.ibm.dtfj.java.javacore.JCJavaClass
All Implemented Interfaces:
JavaClass

public class JCJavaClass extends Object implements JavaClass
  • Constructor Details

  • Method Details

    • getClassLoader

      public JavaClassLoader getClassLoader() throws CorruptDataException
      Description copied from interface: JavaClass
      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.
      Specified by:
      getClassLoader in interface JavaClass
      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)
    • getComponentType

      public JavaClass getComponentType() throws CorruptDataException
      component type only for arrays
      Specified by:
      getComponentType in interface JavaClass
      Returns:
      a JavaClass representing the component type of this array class
      Throws:
      CorruptDataException
    • getConstantPoolReferences

      public Iterator getConstantPoolReferences()
      Description copied from interface: JavaClass
      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.

      Specified by:
      getConstantPoolReferences in interface JavaClass
      Returns:
      an iterator over the collection of JavaObjects which are referred to by the constant pool of this class
      See Also:
    • getDeclaredFields

      public Iterator getDeclaredFields()
      Description copied from interface: JavaClass
      Get the set of fields declared in this class.
      Specified by:
      getDeclaredFields in interface JavaClass
      Returns:
      an iterator over the collection of fields declared in this class.
      See Also:
    • getDeclaredMethods

      public Iterator getDeclaredMethods()
      Description copied from interface: JavaClass
      Get the set of methods declared in this class.
      Specified by:
      getDeclaredMethods in interface JavaClass
      Returns:
      an iterator over the collection of methods declared in this class.
      See Also:
    • getID

      public ImagePointer getID()
      Description copied from interface: JavaClass
      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.

      Specified by:
      getID in interface JavaClass
      Returns:
      a pointer to the class
    • getInterfaces

      public Iterator getInterfaces()
      Description copied from interface: JavaClass
      Get the set of names of interfaces directly implemented by this class.
      Specified by:
      getInterfaces in interface JavaClass
      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

      public int getModifiers() throws CorruptDataException
      Description copied from interface: JavaClass
      Return the Java language modifiers for this class.

      The modifiers are defined by the JVM Specification.

      Return MODIFIERS_UNAVAILABLE if the modifiers are unavailable. This might be the case if DTFJ is operating against an artefact such as a portable heap dump that does not contain information about a class's modifiers.

      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.

      Specified by:
      getModifiers in interface JavaClass
      Returns:
      the modifiers for this class
      Throws:
      CorruptDataException - if modifiers not set
      See Also:
    • getName

      public String getName() throws CorruptDataException
      Description copied from interface: JavaClass
      Get the name of the class.
      Specified by:
      getName in interface JavaClass
      Returns:
      the name of the class in the form: "full/package/class$innerclass"
      Throws:
      CorruptDataException - if class name is not set
      See Also:
    • getObject

      public JavaObject getObject() throws CorruptDataException
      Instance object of this class
      Specified by:
      getObject in interface JavaClass
      Returns:
      the java.lang.Class object associated with this class
      Throws:
      CorruptDataException - if no instance of this class is set
      See Also:
    • getSuperclass

      public JavaClass getSuperclass() throws CorruptDataException
      Returning null is permissable for cases like Object, primitives, interfaces, etc..
      Specified by:
      getSuperclass in interface JavaClass
      Returns:
      JavaClass of this class's superclass.
      Throws:
      CorruptDataException - if super class not found.
      See Also:
    • getInstanceSize

      public long getInstanceSize() throws DataUnavailable, CorruptDataException
      Description copied from interface: JavaClass
      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.

      Specified by:
      getInstanceSize in interface JavaClass
      Returns:
      size in bytes of an instance
      Throws:
      DataUnavailable
      CorruptDataException
    • isArray

      public boolean isArray() throws CorruptDataException
      Same as the J9 System Core implementation for DTFJ.
      Specified by:
      isArray in interface JavaClass
      Returns:
      true if an array
      Throws:
      CorruptDataException
      See Also:
    • setID

      public void setID(long classID) throws JCInvalidArgumentsException
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      classID - which is a valid hexadecimal address
      Throws:
      JCInvalidArgumentsException - if invalid address is passed as an ID
    • internalGetName

      public String internalGetName()
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Returns:
      class Name
    • setClassLoader

      public void setClassLoader(JavaClassLoader classLoader)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      classLoader -
    • setJavaSuperClass

      public void setJavaSuperClass(long superClassID)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      superClassID -
    • setJavaObject

      public void setJavaObject(JavaObject javaObject)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      javaObject -
    • setModifiers

      public void setModifiers(int modifiers)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      java - class modifiers
    • getReferences

      public Iterator getReferences()
      Description copied from interface: JavaClass
      Get the set of references from this class.
      Specified by:
      getReferences in interface JavaClass
      Returns:
      an iterator of JavaReferences
      See Also:
    • addMethod

      public void addMethod(JavaMethod method)
      NON-DTFJ
      For internal building purposes only. Do not call outside the DTFJ implementation.

      Parameters:
      java - method - a method declared by this class
    • getProtectionDomain

      public JavaObject getProtectionDomain() throws DataUnavailable, CorruptDataException
      Description copied from interface: JavaClass
      Returns the protection domain for this class.
      Specified by:
      getProtectionDomain in interface JavaClass
      Returns:
      the protection domain or null for the default protection domain
      Throws:
      DataUnavailable
      CorruptDataException