public interface ResolvedJavaType extends JavaType, ModifiersProvider
void
, and arrays
thereof. Types, like fields and methods, are resolved through constant pools
.ANNOTATION, BRIDGE, ENUM, MANDATED, SYNTHETIC, VARARGS
Modifier and Type | Method and Description |
---|---|
ResolvedJavaType |
asExactType()
Returns this type if it is an exact type otherwise returns null.
|
ResolvedJavaField |
findInstanceFieldWithOffset(long offset,
Kind expectedKind)
Returns the instance field of this class (or one of its super classes) at the given offset,
or
null if there is no such field. |
Assumptions.AssumptionResult<ResolvedJavaType> |
findLeafConcreteSubtype()
Attempts to get a leaf concrete subclass of this type.
|
ResolvedJavaType |
findLeastCommonAncestor(ResolvedJavaType otherType)
Walks the class hierarchy upwards and returns the least common class that is a superclass of
both the current and the given type.
|
default ResolvedJavaMethod |
findMethod(String name,
Signature signature) |
Assumptions.AssumptionResult<ResolvedJavaMethod> |
findUniqueConcreteMethod(ResolvedJavaMethod method)
Given a
ResolvedJavaMethod A, returns a concrete ResolvedJavaMethod B that is
the only possible unique target for a virtual call on A(). |
<T extends Annotation> |
getAnnotation(Class<T> annotationClass)
Returns the annotation for the specified type of this class, if such an annotation is
present.
|
ResolvedJavaType |
getArrayClass()
Gets the array class type representing an array with elements of this type.
|
URL |
getClassFilePath()
Returns the class file path - if available - of this type, or
null . |
ResolvedJavaMethod |
getClassInitializer()
Returns the
<clinit> method for this class if there is one. |
ResolvedJavaType |
getComponentType()
For array types, gets the type of the components, or
null if this is not an array
type. |
ResolvedJavaMethod[] |
getDeclaredConstructors()
Returns an array reflecting all the constructors declared by this type.
|
ResolvedJavaMethod[] |
getDeclaredMethods()
Returns an array reflecting all the methods declared by this type.
|
default ResolvedJavaType |
getElementalType()
Gets the elemental type for this given type.
|
ResolvedJavaType |
getEnclosingType()
Returns the enclosing type of this type, if it exists, or
null . |
ResolvedJavaField[] |
getInstanceFields(boolean includeSuperclasses)
Returns the instance fields of this class, including
internal fields.
|
ResolvedJavaType[] |
getInterfaces()
Gets the interfaces implemented or extended by this type.
|
JavaConstant |
getJavaClass()
Gets the runtime representation of the Java class object of this type.
|
int |
getModifiers()
Returns the Java Virtual Machine modifiers for this element.
|
Constant |
getObjectHub()
Gets the runtime representation of the "hub" of this type--that is, the closest part of the
type representation which is typically stored in the object header.
|
ResolvedJavaType |
getSingleImplementor()
Gets the single implementor of this type.
|
String |
getSourceFileName()
Returns name of source file of this type.
|
ResolvedJavaField[] |
getStaticFields()
Returns the static fields of this class, including
internal fields.
|
ResolvedJavaType |
getSuperclass()
Gets the super class of this type.
|
Assumptions.AssumptionResult<Boolean> |
hasFinalizableSubclass()
Checks whether this type has any finalizable subclasses so far.
|
boolean |
hasFinalizer()
Checks whether this type has a finalizer method.
|
void |
initialize()
Initializes this type.
|
boolean |
isArray()
Checks whether this type is an array class.
|
boolean |
isAssignableFrom(ResolvedJavaType other)
Determines if this type is either the same as, or is a superclass or superinterface of, the
type represented by the specified parameter.
|
boolean |
isInitialized()
Checks whether this type is initialized.
|
boolean |
isInstance(JavaConstant obj)
Checks whether the specified object is an instance of this type.
|
boolean |
isInstanceClass()
Checks whether this type is an instance class.
|
boolean |
isInterface()
Checks whether this type is an interface.
|
default boolean |
isJavaLangObject()
Returns true if this type is exactly the type
Object . |
default boolean |
isLeaf() |
boolean |
isLinked()
Checks whether this type is linked and verified.
|
boolean |
isLocal()
Returns
true if the type is a local type. |
boolean |
isMember()
Returns
true if the type is a member type. |
boolean |
isPrimitive()
Checks whether this type is primitive.
|
boolean |
isTrustedInterfaceType()
Returns true if this type represents an interface and it should be trusted even in places
where the JVM verifier would not give any guarantees other than
Object . |
ResolvedJavaMethod |
resolveConcreteMethod(ResolvedJavaMethod method,
ResolvedJavaType callerType)
Resolves the method implementation for virtual dispatches on objects of this dynamic type.
|
ResolvedJavaMethod |
resolveMethod(ResolvedJavaMethod method,
ResolvedJavaType callerType)
Resolves the method implementation for virtual dispatches on objects of this dynamic type.
|
getKind, getName, getUnqualifiedName, resolve, toClassName, toJavaName, toJavaName
isAbstract, isConcrete, isFinalFlagSet, isNative, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isStrict, isSynchronized, isTransient, isVolatile, jvmClassModifiers, jvmFieldModifiers, jvmMethodModifiers
JavaConstant getJavaClass()
Constant getObjectHub()
boolean hasFinalizer()
true
if this class has a finalizerAssumptions.AssumptionResult<Boolean> hasFinalizableSubclass()
true
if this class has any subclasses with finalizersboolean isInterface()
isInterface
in interface ModifiersProvider
true
if this type is an interfaceModifier.isInterface(int)
boolean isInstanceClass()
true
if this type is an instance classboolean isArray()
true
if this type is an array classboolean isPrimitive()
true
if this type is primitiveint getModifiers()
ResolvedJavaType
) can not be private or protected.
Only the flags specified in the JVM specification will be included in the returned mask. This
method is identical to Class.getModifiers()
in terms of the value return for this
type.
getModifiers
in interface ModifiersProvider
default boolean isLeaf()
boolean isInitialized()
linked
and that the static initializer has run.true
if this type is initializedvoid initialize()
boolean isLinked()
initialized
type is always linked.true
if this type is linkedboolean isAssignableFrom(ResolvedJavaType other)
Class.isAssignableFrom(Class)
in terms of the value return for this type.default boolean isJavaLangObject()
Object
.boolean isInstance(JavaConstant obj)
obj
- the object to testtrue
if the object is an instance of this typeResolvedJavaType asExactType()
null
otherwiseResolvedJavaType getSuperclass()
Object
class,
an interface, a primitive type, or void, then null is returned. If this object represents an
array class then the type object representing the Object
class is returned.ResolvedJavaType[] getInterfaces()
Class.getInterfaces()
and as such, only returns the interfaces directly implemented
or extended by this type.ResolvedJavaType getSingleImplementor()
If the compiler uses the result of this method for its compilation, the usage must be guarded because the verifier can not guarantee that the assigned type really implements this interface. Additionally, class loading can invalidate the result of this method.
null
if there is no implementor, the implementor if there is only one, or
this
if there are more than one.ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType)
null
if primitive types are involved.Assumptions.AssumptionResult<ResolvedJavaType> findLeafConcreteSubtype()
For an array type A, the leaf concrete subclass is A if the
elemental type of A is final (which includes primitive
types). Otherwise null
is returned for A.
For a non-array type T, the result is the leaf concrete type in the current hierarchy of T.
A runtime may decide not to manage or walk a large hierarchy and so the result is conservative. That is, a non-null result is guaranteed to be the leaf concrete class in T's hierarchy at the current point in time but a null result does not necessarily imply that there is no leaf concrete class in T's hierarchy.
If the compiler uses the result of this method for its compilation, it must register the
Assumptions.AssumptionResult
in its Assumptions
because dynamic class loading can
invalidate the result of this method.
Assumptions.AssumptionResult
containing the leaf concrete subclass for this type as
described aboveResolvedJavaType getComponentType()
JavaType
null
if this is not an array
type. This method is analogous to Class.getComponentType()
.getComponentType
in interface JavaType
default ResolvedJavaType getElementalType()
JavaType
int[][][]
is
int
. A non-array type is its own elemental type.getElementalType
in interface JavaType
ResolvedJavaType getArrayClass()
JavaType
getArrayClass
in interface JavaType
ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType)
method
- the method to select the implementation ofcallerType
- the caller or context type used to perform access checksnull
if it can not be
linkedResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType)
findUniqueConcreteMethod(ResolvedJavaMethod)
.method
- the method to select the implementation ofcallerType
- the caller or context type used to perform access checksnull
if there is no
concrete implementation of method
in this type or any of its superclassesAssumptions.AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method)
ResolvedJavaMethod
A, returns a concrete ResolvedJavaMethod
B that is
the only possible unique target for a virtual call on A(). Returns null
if either no
such concrete method or more than one such method exists. Returns the method A if A is a
concrete method that is not overridden.
If the compiler uses the result of this method for its compilation, it must register an assumption because dynamic class loading can invalidate the result of this method.
method
- the method A for which a unique concrete target is searchednull
if no such target exists or assumptions
are not supported by this runtimeResolvedJavaField[] getInstanceFields(boolean includeSuperclasses)
includeSuperclasses
- if true, then instance fields for the complete hierarchy of this
type are included in the resultResolvedJavaField[] getStaticFields()
<T extends Annotation> T getAnnotation(Class<T> annotationClass)
annotationClass
- the Class object corresponding to the annotation typenull
ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind expectedKind)
null
if there is no such field.offset
- the offset of the field to look fornull
if there is no such field.String getSourceFileName()
URL getClassFilePath()
null
.boolean isLocal()
true
if the type is a local type.boolean isMember()
true
if the type is a member type.ResolvedJavaType getEnclosingType()
null
.ResolvedJavaMethod[] getDeclaredConstructors()
Class.getDeclaredConstructors()
in terms of returned constructors.ResolvedJavaMethod[] getDeclaredMethods()
Class.getDeclaredMethods()
in terms of returned methods.ResolvedJavaMethod getClassInitializer()
<clinit>
method for this class if there is one.boolean isTrustedInterfaceType()
Object
.default ResolvedJavaMethod findMethod(String name, Signature signature)