|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JavaClass
Represents a Java class.
A Java Class can have fields and methods. It is a shallow model of a loaded class file or special types such as array types or primitive types in the Java Virtual Machine.
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
|
JavaClassLoader |
getClassLoader()
Fetch the class loader associated with this class. |
JavaClass |
getComponentType()
For array classes, returns a JavaClass representing the component type of this array class. |
java.util.List<JavaObject> |
getConstantPoolReferences()
Returns the list of constant pool references defined by this class. |
java.util.List<JavaField> |
getDeclaredFields()
Get the set of fields declared in this class. |
java.util.List<JavaMethod> |
getDeclaredMethods()
Get the set of methods declared in this class. |
ImagePointer |
getID()
The ID of a class is a pointer to a section of memory which identifies the class. |
java.util.List<java.lang.String> |
getInterfaces()
Get the set of names of interfaces directly implemented by the class represented by this JavaClass. |
int |
getModifiers()
Return the Java language modifiers for this class. |
java.lang.String |
getName()
Get the name of the class in a form that follows the Class.getName() definition. |
JavaObject |
getObject()
Fetch the Class object associated with this class. |
java.util.List<JavaReference> |
getReferences()
Get the set of references from this class. |
JavaClass |
getSuperclass()
Get the super class of this class. |
int |
hashCode()
|
boolean |
isArray()
This method returns true if the class represented by this JavaClass is an array class. |
Method Detail |
---|
JavaObject getObject() throws CorruptDataException
Fetch the 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.
CorruptDataException
- if the underlying data is in an unexpected stategetID()
JavaClassLoader getClassLoader() throws CorruptDataException
CorruptDataException
- if the class loader for this class cannot
be found (a class cannot exist without a loader so this implies corruption)java.lang.String getName() throws CorruptDataException
Get the name of the class in a form that follows the Class.getName()
definition.
This method will always return a valid class name.
CorruptDataException
- if the underlying data is in an unexpected stateJavaClass getSuperclass() throws CorruptDataException
Get the super class of this class.
Will return the superclass of this class or null if no superclass exists.
For JavaClass instances representing interfaces, java.lang.Object, primitive types ( int,boolean,char etc) and void, calling this method will return null.
CorruptDataException
- if the underlying data is in an unexpected statejava.util.List<java.lang.String> getInterfaces()
Get the set of names of interfaces directly implemented by the class represented by this JavaClass.
Some JVM implementations may choose to load interfaces lazily, so only the names are returned.
The returned list follows the standard semantics for javax.tools.diagnostics collections.
The returned list is never null but could be empty.
String
,
JavaClassLoader.findClass(String)
,
CorruptData
int getModifiers() 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.
CorruptDataException
- if the underlying data is in an unexpected stateboolean isArray() throws CorruptDataException
CorruptDataException
- if the underlying data is in an unexpected stateJavaClass getComponentType() throws CorruptDataException
CorruptDataException
- if the underlying data is in an unexpected state
java.lang.IllegalArgumentException
- if this JavaClass does not represent an array classjava.util.List<JavaField> getDeclaredFields()
Get the set of fields declared in this class.
Fields declared in any superclass of this class are not returned.
The returned list follows the standard semantics for javax.tools.diagnostics collections.
The returned list is never null but could be empty.
JavaField
,
CorruptData
java.util.List<JavaMethod> getDeclaredMethods()
Get the set of methods declared in this class.
Methods declared in any superclass of this class are not returned.
The returned list follows the standard semantics for javax.tools.diagnostics collections.
The returned list is never null but could be empty.
JavaMethod
,
CorruptData
java.util.List<JavaObject> getConstantPoolReferences()
Returns the list of constant pool references defined by this class.
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 list.
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.
The returned list follows the standard semantics for javax.tools.diagnostics collections.
The returned list is never null but could be empty.
JavaObject
,
CorruptData
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. API users should not rely on this behaviour.
In some implementations, getID() may return null for some classes.
java.util.List<JavaReference> getReferences()
Get the set of references from this class.
A reference is a object that represents the uni-directional relationship between objects and classes.
Objects and classes cannot be reclaimed by the Java Virtual Machine garbage collector if references exist
that can ultimately be traced back to root references. see JavaReference
for more detailed information.
Since this API can present entities that exist at any point in their lifecycle, it is possible to encounter an
JavaClass that is eligible for collection and thus no JavaReference
can be found that refers to it.
The returned list follows the standard semantics for javax.tools.diagnostics collections.
The returned list is never null but could be empty.
JavaReference
,
CorruptData
boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
-
int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |