ClassType for classes,
InterfaceType for interfaces, and
ArrayType for arrays.
Note that primitive classes (for example, the
reflected type of
Integer.TYPE )
are represented as ClassType.
The VM creates Class objects for all three, so from the VM perspective,
each ReferenceType maps to a distinct Class object.
ReferenceTypes can
be obtained by querying a particular ObjectReference for its
type or by getting a list of all reference types from the
VirtualMachine.
ReferenceType provides access to static type information such as methods and fields and provides access to dynamic type information such as the corresponding Class object and the classloader.
Any method on ReferenceType which directly or
indirectly takes ReferenceType as an parameter may throw
VMDisconnectedException if the target VM is
disconnected and the VMDisconnectEvent has been or is
available to be read from the EventQueue.
Any method on ReferenceType which directly or
indirectly takes ReferenceType as an parameter may throw
VMOutOfMemoryException if the target VM has run out of memory.
Any method on ReferenceType or which directly or indirectly takes
ReferenceType as parameter may throw
ObjectCollectedException if the mirrored type has been unloaded.
ObjectReference, ObjectReference#referenceType, VirtualMachine, VirtualMachine#allClasses
| Modifier and Type | Method and Description |
|---|---|
| public List | |
| public List | allLineLocations()
Returns a list containing a |
| public List | Returns: a List of all source lineLocation objects.The stratum to retrieve information from
or stratum, String null for the defaultStratum().Return locations only within this
source file or sourceName)null to return locations.Returns a list containing a |
| public List | Returns: a List ofMethod objects; the list has length
0 if no methods exist.Returns a list containing each |
| public List | Returns: List ofjava.lang.String, each
representing a stratumReturn the available strata for this reference type. |
| public ClassLoaderReference | Returns: aClassLoaderReference which mirrors the classloader,
or null if the class was loaded through the bootstrap class
loader.Gets the classloader object which loaded the class corresponding to this type. |
| public ClassObjectReference | Returns: theClassObjectReference for this reference type
in the target VM.Returns the class object that corresponds to this type in the target VM. |
| public byte[] | Returns: the raw bytes of constant pool.Returns the raw bytes of the constant pool in the format of the constant_pool item of the Class File Format in the Java Virtual Machine Specification. |
| public int | Returns: total number of constant pool entries for a class plus one.Returns the number of entries in the constant pool plus one. |
| public String | |
| public boolean | Returns: true if the Object is aReferenceType, if the
ReferenceTypes belong to the same VM, and if they mirror classes
which correspond to the same instance of java.lang.Class in that VM.Compares the specified Object with this ReferenceType for equality. |
| public boolean | Returns: true if initialization was attempted and
failed; false otherwise.Determines if initialization failed for this class. |
| public Field | Returns: aField object which mirrors the found field, or
null if there is no field with the given name or if the given
name is ambiguous.a String containing the name of desired field. fieldName)Finds the visible |
| public List | |
| public String | Returns: a string containing the generic signature, ornull
if there is no generic signature.Gets the generic signature for this type if there is one. |
| public Value | |
| public Map | |
| public int | |
| public List | Returns: a List ofObjectReference objects. If there are
no instances of this ReferenceType, a zero-length list is returned.the maximum number of instances to return.
Must be non-negative. If zero, all instances are returned. maxInstances)Returns instances of this ReferenceType. |
| public boolean | Returns: true if this type is abstract; false otherwise.Determines if this type was declared abstract. |
| public boolean | Returns: true if this type is final; false otherwise.Determines if this type was declared final. |
| public boolean | Returns: true if this type is initialized; false otherwise.Determines if this type has been initialized. |
| public boolean | Returns: true if this type is prepared; false otherwise.Determines if this type has been prepared. |
| public boolean | Returns: true if this type is static; false otherwise.Determines if this type was declared static. |
| public boolean | Returns: true if this type is verified; false otherwise.Determines if this type has been verified. |
| public List | Returns: a List of allLocation objects that map to
the given line.the line number lineNumber)Returns a List containing all |
| public List | Returns: a List of allLocation objects that map
to the given line.the stratum to use for comparing line number
and source name, or stratum, String null to
use the defaultStratum().the source name containing the line
number, or sourceName, int null to match
all source namesthe line number lineNumber)Returns a List containing all |
| public int | Returns: the major version number of the class.Returns the class major version number, as defined in the class file format of the Java Virtual Machine Specification. |
| public List | |
| public List | Returns: a List ofMethod objects that match the given
name; the list has length 0 if no matching methods are found.the name of the method to find. name)Returns a List containing each visible |
| public List | Returns: a List ofMethod objects that match the given
name and signature; the list has length 0 if no matching methods
are found.the name of the method to find. name, String the signature of the method to find signature)Returns a List containing each visible |
| public int | Returns: the minor version number of the class.Returns the class minor version number, as defined in the class file format of the Java Virtual Machine Specification. |
| public default ModuleReference | Returns: aModuleReference which mirrors the module in the target VM.Gets the module object which contains the class corresponding to this type. |
| public String | Returns: a string containing the type name.Redeclares com. Returns the name of this |
| public List | Returns: a List of nestedReferenceType objects; the list
has 0 length if there are no nested types.Returns a List containing |
| public String | Returns: as a string the source debug extension attributeGet the source debug extension of this type. |
| public String | Returns: the string source file nameGets an identifying name for the source corresponding to the declaration of this type. |
| public List | Returns: a List of String objects each representing a source nameThe stratum to retrieve information from
or stratum)null for the declaring type's
default stratum.Gets the identifying names for all the source corresponding to the declaration of this type. |
| public List | Returns: a List of String objects each representing a source pathThe stratum to retrieve information from
or stratum)null for the declaring type's
default stratum.Gets the paths to the source corresponding to the declaration of this type. |
| public List | Returns: a List ofField objects; the list has length
0 if no visible fields exist.Returns a list containing each unhidden and unambiguous |
| public List | Returns: a List ofMethod objects; the list has length
0 if no visible methods exist.Returns a list containing each |
| allFields | back to summary |
|---|---|
| public List Returns a list containing each
For arrays (
| |
| allLineLocations | back to summary |
|---|---|
| public List Returns a list containing a
This method is equivalent to
| |
| allLineLocations | back to summary |
|---|---|
| public List Returns a list containing a
For arrays (
Returned list is for the specified stratum
(see
| |
| allMethods | back to summary |
|---|---|
| public List Returns a list containing each
For arrays (
| |
| availableStrata | back to summary |
|---|---|
| public List Return the available strata for this reference type.
See the | |
| classLoader | back to summary |
|---|---|
| public ClassLoaderReference classLoader() Gets the classloader object which loaded the class corresponding to this type.
| |
| classObject | back to summary |
|---|---|
| public ClassObjectReference classObject() Returns the class object that corresponds to this type in the target VM. The VM creates class objects for every kind of ReferenceType: classes, interfaces, and array types.
| |
| constantPool | back to summary |
|---|---|
| public byte[] constantPool() Returns the raw bytes of the constant pool in the format of the
constant_pool item of the Class File Format in the Java Virtual
Machine Specification. The format of the constant pool may
differ between versions of the Class File Format, so, the
minor and major class version numbers should be checked for
compatibility.
For arrays (
| |
| constantPoolCount | back to summary |
|---|---|
| public int constantPoolCount() Returns the number of entries in the constant pool plus one.
This corresponds to the constant_pool_count item of the Class File Format
in the Java Virtual Machine Specification.
For arrays (
| |
| defaultStratum | back to summary |
|---|---|
| public String defaultStratum() Returns the default stratum for this reference type.
This value is specified in the class file and cannot
be set by the user. If the class file does not
specify a default stratum the base stratum
(
See the
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Compares the specified Object with this ReferenceType for equality.
| |
| failedToInitialize | back to summary |
|---|---|
| public boolean failedToInitialize() Determines if initialization failed for this class. See the JVM specification for details on class initialization.
For arrays (
| |
| fieldByName | back to summary |
|---|---|
| public Field fieldByName(String fieldName) Finds the visible
For arrays (
| |
| fields | back to summary |
|---|---|
| public List Returns a list containing each
For arrays (
| |
| genericSignature | back to summary |
|---|---|
| public String genericSignature() Gets the generic signature for this type if there is one. Generic signatures are described in the The Java Virtual Machine Specification.
| |
| getValue | back to summary |
|---|---|
| public Value getValue(Field field) Gets the
| |
| getValues | back to summary |
|---|---|
| public Map Returns a map containing the
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Returns the hash code value for this ObjectReference.
| |
| instances | back to summary |
|---|---|
| public List Returns instances of this ReferenceType. Only instances that are reachable for the purposes of garbage collection are returned.
Not all target virtual machines support this operation.
Use
| |
| isAbstract | back to summary |
|---|---|
| public boolean isAbstract() Determines if this type was declared abstract.
For arrays (
| |
| isFinal | back to summary |
|---|---|
| public boolean isFinal() Determines if this type was declared final.
For arrays (
| |
| isInitialized | back to summary |
|---|---|
| public boolean isInitialized() Determines if this type has been initialized. See the JVM
specification for a definition of class verification.
For
For arrays (
| |
| isPrepared | back to summary |
|---|---|
| public boolean isPrepared() Determines if this type has been prepared. See the JVM specification for a definition of class preparation.
For arrays (
| |
| isStatic | back to summary |
|---|---|
| public boolean isStatic() Determines if this type was declared static. Only nested types,
can be declared static, so
| |
| isVerified | back to summary |
|---|---|
| public boolean isVerified() Determines if this type has been verified. See the JVM specification for a definition of class verification.
For arrays (
| |
| locationsOfLine | back to summary |
|---|---|
| public List Returns a List containing all
This method is equivalent to
| |
| locationsOfLine | back to summary |
|---|---|
| public List Returns a List containing all
For arrays (
Returned list is for the specified stratum
(see
| |
| majorVersion | back to summary |
|---|---|
| public int majorVersion() Returns the class major version number, as defined in the class file format
of the Java Virtual Machine Specification.
For arrays (
| |
| methods | back to summary |
|---|---|
| public List Returns a list containing each
For arrays (
| |
| methodsByName | back to summary |
|---|---|
| public List Returns a List containing each visible Overridden and hidden methods are not included. See JLS (8.4.8) for details.
For arrays (
| |
| methodsByName | back to summary |
|---|---|
| public List Returns a List containing each visible
At most one method in the list is a concrete method and a
component of
For arrays (
| |
| minorVersion | back to summary |
|---|---|
| public int minorVersion() Returns the class minor version number, as defined in the class file format
of the Java Virtual Machine Specification.
For arrays (
| |
| module | back to summary |
|---|---|
| public default ModuleReference module() Gets the module object which contains the class corresponding
to this type.
Not all target virtual machines support this operation.
Use Implementation Specification The default implementation throws
| |
| name | back to summary |
|---|---|
| public String name() Redeclares com. Returns the name of this
| |
| nestedTypes | back to summary |
|---|---|
| public List Returns a List containing
For arrays (
| |
| sourceDebugExtension | back to summary |
|---|---|
| public String sourceDebugExtension() throws AbsentInformationException Get the source debug extension of this type.
Not all target virtual machines support this operation.
Use
| |
| sourceName | back to summary |
|---|---|
| public String sourceName() throws AbsentInformationException Gets an identifying name for the source corresponding to the declaration of this type. Interpretation of this string is the responsibility of the source repository mechanism.
The returned name is dependent on VM's default stratum
(
For arrays (
| |
| sourceNames | back to summary |
|---|---|
| public List Gets the identifying names for all the source corresponding to the declaration of this type. Interpretation of these names is the responsibility of the source repository mechanism.
The returned names are for the specified stratum
(see
| |
| sourcePaths | back to summary |
|---|---|
| public List Gets the paths to the source corresponding to the declaration of this type. Interpretation of these paths is the responsibility of the source repository mechanism.
The returned paths are for the specified stratum
(see
| |
| visibleFields | back to summary |
|---|---|
| public List Returns a list containing each unhidden and unambiguous
For arrays (
| |
| visibleMethods | back to summary |
|---|---|
| public List Returns a list containing each
Note that despite this exclusion, multiple inherited methods
with the same signature can be present in the returned list, but
at most one can be a member of a
For arrays (
| |