public final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, HotSpotProxified
JavaType
for resolved non-primitive HotSpot classes.Modifier and Type | Class and Description |
---|---|
private class |
HotSpotResolvedObjectTypeImpl.FieldInfo
This class represents the field information for one field contained in the fields array of an
InstanceKlass . |
private static class |
HotSpotResolvedObjectTypeImpl.OffsetComparator |
Modifier and Type | Field and Description |
---|---|
private HotSpotResolvedObjectType |
arrayOfType |
private ConstantPool |
constantPool |
private HashMap<Long,HotSpotResolvedJavaField> |
fieldCache |
private HotSpotResolvedJavaField[] |
instanceFields |
private HotSpotResolvedObjectTypeImpl[] |
interfaces |
private Class<?> |
javaClass
The Java class this type represents.
|
private HashMap<Long,HotSpotResolvedJavaMethod> |
methodCache |
ANNOTATION, BRIDGE, ENUM, MANDATED, SYNTHETIC, VARARGS
Constructor and Description |
---|
HotSpotResolvedObjectTypeImpl(Class<?> javaClass)
Creates the JVMCI mirror for a
Class object. |
Modifier and Type | Method and Description |
---|---|
HotSpotResolvedObjectType |
asExactType()
Returns this type if it is an exact type otherwise returns null.
|
ConstantPool |
constantPool() |
HotSpotResolvedJavaField |
createField(String fieldName,
JavaType type,
long offset,
int rawFlags) |
HotSpotResolvedJavaMethod |
createMethod(long metaspaceMethod) |
ResolvedJavaField |
findInstanceFieldWithOffset(long offset,
Kind expectedEntryKind)
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.
|
HotSpotResolvedObjectType |
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.
|
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(). |
static HotSpotResolvedObjectTypeImpl |
fromMetaspaceKlass(long metaspaceKlass)
Gets the JVMCI mirror from a HotSpot metaspace Klass native object.
|
static HotSpotResolvedObjectTypeImpl |
fromObjectClass(Class<?> javaClass)
Gets the JVMCI mirror for a
Class object. |
int |
getAccessFlags() |
<T extends Annotation> |
getAnnotation(Class<T> annotationClass)
Returns the annotation for the specified type of this class, if such an annotation is
present.
|
HotSpotResolvedObjectType |
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.
|
HotSpotResolvedObjectTypeImpl |
getEnclosingType()
Returns the enclosing type of this type, if it exists, or
null . |
private int |
getFieldCount()
Returns the actual field count of this class's internal
InstanceKlass::_fields array
by walking the array and discounting the generic signature slots at the end of the array. |
private int |
getInitState()
Returns the value of the state field
InstanceKlass::_init_state of the metaspace
klass. |
ResolvedJavaField[] |
getInstanceFields(boolean includeSuperclasses)
Returns the instance fields of this class, including
internal fields.
|
HotSpotResolvedObjectTypeImpl[] |
getInterfaces()
Gets the interfaces implemented or extended by this type.
|
JavaConstant |
getJavaClass()
Gets the runtime representation of the Java class object of this type.
|
Kind |
getKind()
Gets the kind of this type.
|
long |
getMetaspaceKlass()
Gets the metaspace Klass for this type.
|
int |
getModifiers()
Returns the Java Virtual Machine modifiers for this element.
|
JavaConstant |
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.
|
private static String |
getSignatureName(Class<?> javaClass)
Returns the name of this type as it would appear in a signature.
|
HotSpotResolvedObjectTypeImpl |
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.
|
private long |
getSubklass()
Returns the
Klass::_subklass field of the underlying metaspace klass for the given
type type . |
HotSpotResolvedObjectTypeImpl |
getSuperclass()
Gets the super class of this type.
|
HotSpotResolvedObjectTypeImpl |
getSupertype() |
int |
getVtableLength() |
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.
|
int |
instanceSize()
Gets the instance size of 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 |
isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass)
Performs a fast-path check that this type is resolved in the context of a given accessing
class.
|
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.
|
boolean |
isJavaLangObject()
Returns true if this type is exactly the type
Object . |
private boolean |
isLeafClass()
Returns if type
type is a leaf class. |
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 |
isPrimaryType() |
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 . |
JavaConstant |
klass()
Gets the metaspace Klass boxed in a
JavaConstant . |
int |
layoutHelper() |
Class<?> |
mirror() |
long |
prototypeMarkWord() |
ResolvedJavaType |
resolve(ResolvedJavaType accessingClass)
Resolves this type to a
ResolvedJavaType . |
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.
|
int |
superCheckOffset() |
String |
toString() |
equals, fromClass, hashCode
getName
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
findMethod, getElementalType, isLeaf
getName, getUnqualifiedName, toClassName, toJavaName, toJavaName
isAbstract, isConcrete, isFinalFlagSet, isNative, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isStrict, isSynchronized, isTransient, isVolatile, jvmClassModifiers, jvmFieldModifiers, jvmMethodModifiers
private HashMap<Long,HotSpotResolvedJavaField> fieldCache
private HashMap<Long,HotSpotResolvedJavaMethod> methodCache
private HotSpotResolvedJavaField[] instanceFields
private HotSpotResolvedObjectTypeImpl[] interfaces
private ConstantPool constantPool
private HotSpotResolvedObjectType arrayOfType
public HotSpotResolvedObjectTypeImpl(Class<?> javaClass)
Class
object.
NOTE: Creating an instance of this class does not install the mirror for the
Class
type. Use fromObjectClass(Class)
or fromMetaspaceKlass(long)
instead.
javaClass
- the Class to create the mirror forpublic static HotSpotResolvedObjectTypeImpl fromObjectClass(Class<?> javaClass)
Class
object.HotSpotResolvedJavaType
corresponding to javaClass
public static HotSpotResolvedObjectTypeImpl fromMetaspaceKlass(long metaspaceKlass)
metaspaceKlass
- a metaspace Klass objectResolvedJavaType
corresponding to metaspaceKlass
private static String getSignatureName(Class<?> javaClass)
public long getMetaspaceKlass()
public int getModifiers()
ResolvedJavaType
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
getModifiers
in interface ResolvedJavaType
public int getAccessFlags()
public HotSpotResolvedObjectType getArrayClass()
JavaType
getArrayClass
in interface HotSpotResolvedObjectType
getArrayClass
in interface JavaType
getArrayClass
in interface ResolvedJavaType
public ResolvedJavaType getComponentType()
JavaType
null
if this is not an array
type. This method is analogous to Class.getComponentType()
.getComponentType
in interface HotSpotResolvedObjectType
getComponentType
in interface JavaType
getComponentType
in interface ResolvedJavaType
public Assumptions.AssumptionResult<ResolvedJavaType> findLeafConcreteSubtype()
ResolvedJavaType
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.
findLeafConcreteSubtype
in interface HotSpotResolvedObjectType
findLeafConcreteSubtype
in interface ResolvedJavaType
Assumptions.AssumptionResult
containing the leaf concrete subclass for this type as
described aboveprivate boolean isLeafClass()
type
is a leaf class. This is the case if the
Klass::_subklass
field of the underlying class is zero.private long getSubklass()
Klass::_subklass
field of the underlying metaspace klass for the given
type type
.public HotSpotResolvedObjectTypeImpl getSuperclass()
ResolvedJavaType
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.getSuperclass
in interface HotSpotResolvedObjectType
getSuperclass
in interface ResolvedJavaType
public HotSpotResolvedObjectTypeImpl[] getInterfaces()
ResolvedJavaType
Class.getInterfaces()
and as such, only returns the interfaces directly implemented
or extended by this type.getInterfaces
in interface HotSpotResolvedObjectType
getInterfaces
in interface ResolvedJavaType
public HotSpotResolvedObjectTypeImpl getSingleImplementor()
ResolvedJavaType
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.
getSingleImplementor
in interface ResolvedJavaType
null
if there is no implementor, the implementor if there is only one, or
this
if there are more than one.public HotSpotResolvedObjectTypeImpl getSupertype()
getSupertype
in interface HotSpotResolvedObjectType
public HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType)
ResolvedJavaType
findLeastCommonAncestor
in interface HotSpotResolvedObjectType
findLeastCommonAncestor
in interface ResolvedJavaType
null
if primitive types are involved.public HotSpotResolvedObjectType asExactType()
ResolvedJavaType
asExactType
in interface HotSpotResolvedObjectType
asExactType
in interface ResolvedJavaType
null
otherwisepublic JavaConstant getJavaClass()
ResolvedJavaType
getJavaClass
in interface ResolvedJavaType
public JavaConstant getObjectHub()
ResolvedJavaType
getObjectHub
in interface ResolvedJavaType
public Assumptions.AssumptionResult<Boolean> hasFinalizableSubclass()
ResolvedJavaType
hasFinalizableSubclass
in interface ResolvedJavaType
true
if this class has any subclasses with finalizerspublic boolean hasFinalizer()
ResolvedJavaType
hasFinalizer
in interface ResolvedJavaType
true
if this class has a finalizerpublic boolean isPrimitive()
ResolvedJavaType
isPrimitive
in interface HotSpotResolvedObjectType
isPrimitive
in interface ResolvedJavaType
true
if this type is primitivepublic boolean isArray()
ResolvedJavaType
isArray
in interface ResolvedJavaType
true
if this type is an array classpublic boolean isInitialized()
ResolvedJavaType
linked
and that the static initializer has run.isInitialized
in interface ResolvedJavaType
true
if this type is initializedpublic boolean isLinked()
ResolvedJavaType
initialized
type is always linked.isLinked
in interface ResolvedJavaType
true
if this type is linkedprivate int getInitState()
InstanceKlass::_init_state
of the metaspace
klass.public void initialize()
ResolvedJavaType
initialize
in interface ResolvedJavaType
public boolean isInstance(JavaConstant obj)
ResolvedJavaType
isInstance
in interface ResolvedJavaType
obj
- the object to testtrue
if the object is an instance of this typepublic boolean isInstanceClass()
ResolvedJavaType
isInstanceClass
in interface ResolvedJavaType
true
if this type is an instance classpublic boolean isInterface()
ResolvedJavaType
isInterface
in interface ModifiersProvider
isInterface
in interface ResolvedJavaType
true
if this type is an interfaceModifier.isInterface(int)
public boolean isAssignableFrom(ResolvedJavaType other)
ResolvedJavaType
Class.isAssignableFrom(Class)
in terms of the value return for this type.isAssignableFrom
in interface ResolvedJavaType
public boolean isJavaLangObject()
ResolvedJavaType
Object
.isJavaLangObject
in interface ResolvedJavaType
public Kind getKind()
JavaType
getKind
in interface HotSpotResolvedObjectType
getKind
in interface JavaType
public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType)
ResolvedJavaType
ResolvedJavaType.findUniqueConcreteMethod(ResolvedJavaMethod)
.resolveConcreteMethod
in interface ResolvedJavaType
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 superclassespublic ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType)
ResolvedJavaType
resolveMethod
in interface ResolvedJavaType
method
- the method to select the implementation ofcallerType
- the caller or context type used to perform access checksnull
if it can not be
linkedpublic ConstantPool constantPool()
constantPool
in interface HotSpotResolvedObjectType
public int instanceSize()
instanceSize
in interface HotSpotResolvedObjectType
public int layoutHelper()
layoutHelper
in interface HotSpotResolvedObjectType
public HotSpotResolvedJavaMethod createMethod(long metaspaceMethod)
public int getVtableLength()
getVtableLength
in interface HotSpotResolvedObjectType
public HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags)
createField
in interface HotSpotResolvedObjectType
public Assumptions.AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method)
ResolvedJavaType
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.
findUniqueConcreteMethod
in interface HotSpotResolvedObjectType
findUniqueConcreteMethod
in interface ResolvedJavaType
method
- the method A for which a unique concrete target is searchednull
if no such target exists or assumptions
are not supported by this runtimepublic ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses)
ResolvedJavaType
getInstanceFields
in interface ResolvedJavaType
includeSuperclasses
- if true, then instance fields for the complete hierarchy of this
type are included in the resultpublic ResolvedJavaField[] getStaticFields()
ResolvedJavaType
getStaticFields
in interface ResolvedJavaType
private int getFieldCount()
InstanceKlass::_fields
array
by walking the array and discounting the generic signature slots at the end of the array.
See FieldStreamBase::init_generic_signature_start_slot
public Class<?> mirror()
mirror
in class HotSpotResolvedJavaType
public String getSourceFileName()
ResolvedJavaType
getSourceFileName
in interface ResolvedJavaType
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
ResolvedJavaType
getAnnotation
in interface ResolvedJavaType
annotationClass
- the Class object corresponding to the annotation typenull
public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass)
accessingClass
. That can only be determined by
re-resolving the type.isDefinitelyResolvedWithRespectTo
in interface HotSpotResolvedObjectType
public ResolvedJavaType resolve(ResolvedJavaType accessingClass)
JavaType
ResolvedJavaType
.public JavaConstant klass()
JavaConstant
.klass
in interface HotSpotResolvedObjectType
public boolean isPrimaryType()
isPrimaryType
in interface HotSpotResolvedObjectType
public int superCheckOffset()
superCheckOffset
in interface HotSpotResolvedObjectType
public long prototypeMarkWord()
prototypeMarkWord
in interface HotSpotResolvedObjectType
public ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind expectedEntryKind)
ResolvedJavaType
null
if there is no such field.findInstanceFieldWithOffset
in interface ResolvedJavaType
offset
- the offset of the field to look fornull
if there is no such field.public URL getClassFilePath()
ResolvedJavaType
null
.getClassFilePath
in interface ResolvedJavaType
public boolean isLocal()
ResolvedJavaType
true
if the type is a local type.isLocal
in interface ResolvedJavaType
public boolean isMember()
ResolvedJavaType
true
if the type is a member type.isMember
in interface ResolvedJavaType
public HotSpotResolvedObjectTypeImpl getEnclosingType()
ResolvedJavaType
null
.getEnclosingType
in interface HotSpotResolvedObjectType
getEnclosingType
in interface ResolvedJavaType
public ResolvedJavaMethod[] getDeclaredConstructors()
ResolvedJavaType
Class.getDeclaredConstructors()
in terms of returned constructors.getDeclaredConstructors
in interface ResolvedJavaType
public ResolvedJavaMethod[] getDeclaredMethods()
ResolvedJavaType
Class.getDeclaredMethods()
in terms of returned methods.getDeclaredMethods
in interface ResolvedJavaType
public ResolvedJavaMethod getClassInitializer()
ResolvedJavaType
<clinit>
method for this class if there is one.getClassInitializer
in interface HotSpotResolvedObjectType
getClassInitializer
in interface ResolvedJavaType
public boolean isTrustedInterfaceType()
ResolvedJavaType
Object
.isTrustedInterfaceType
in interface ResolvedJavaType