public interface JavaType extends JavaMember, JavaIsGeneric
Modifier and Type | Field and Description |
---|---|
static JavaType[] |
EMPTY_ARRAY |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
int |
getArrayDimensions() |
JavaType |
getBaseComponentType() |
JavaClass |
getClass(java.lang.String name)
Iteratively retrieves all member classes declared in this class or its hierarchy.
|
java.util.Collection<JavaClass> |
getClasses()
Iteratively retrieves all member classes declared in this class or its hierarchy.
|
JavaMethod |
getClinitMethod() |
JavaClass |
getClosestClass()
Deprecated.
Please use
getTypeErasure() . |
JavaType |
getComponentType() |
java.util.Collection<JavaClass> |
getDeclaredAnonymousClasses()
Get the anonymous classes in this type.
|
JavaClass |
getDeclaredClass(java.lang.String name)
Get the direct member class that has the incoming name.
|
java.util.Collection<JavaClass> |
getDeclaredClasses()
Get the direct member classes of this type.
|
JavaMethod |
getDeclaredConstructor(JavaType[] parameters) |
java.util.Collection<JavaMethod> |
getDeclaredConstructors() |
JavaField |
getDeclaredField(java.lang.String name) |
java.util.Collection<JavaField> |
getDeclaredFields() |
java.util.Collection<JavaClass> |
getDeclaredLocalClasses()
Get the local classes in this type.
|
JavaMethod |
getDeclaredMethod(java.lang.String name, JavaType[] parameters) |
java.util.Collection<JavaMethod> |
getDeclaredMethods() |
java.util.Collection<JavaMethod> |
getDeclaredMethods(java.lang.String name) |
java.lang.String |
getDescriptor()
Gets the descriptor for this type, as defined by the JVMS2.
|
JavaField |
getField(java.lang.String name)
Iteratively searches for a field declared in this class or its hierarchy.
|
java.util.Collection<JavaField> |
getFields()
Iteratively retrieves all fields declared in this class and its hierarchy.
|
java.util.Set<JavaType> |
getHierarchy()
Recursively gets the full list of all resolved superclasses and super-interfaces.
|
java.util.Collection<JavaType> |
getInterfaces()
The name "getInterfaces" was chosen to be consistent with java/lang/Class.
|
JavaMethod |
getMethod(java.lang.String name, JavaType[] parameters)
Iteratively searches for a method declared in this class or its hierarchy.
|
java.util.Collection<JavaMethod> |
getMethods()
Iteratively retrieves all methods declared in this class or its hierarchy.
|
java.util.Collection<JavaMethod> |
getMethods(java.lang.String name)
Iteratively retrieves all methods declared in this class or its hierarchy.
|
java.lang.String |
getName()
Gets the simplest name of this type with "[]"s if present.
|
JavaPackage |
getPackage()
Gets the owning package, null if N/A.
|
java.lang.String |
getPackageName()
Gets the qualified name of the owning package.
|
java.lang.String |
getQualifiedName()
Gets the fully qualified name of this type in source format.
|
java.lang.String |
getRawName()
Gets the raw name of this type.
|
java.lang.String |
getSignature()
Gets the "Signature" attribute of this type, as defined by the JVMS3.
|
JavaType |
getSuperclass()
The name "getSuperclass" was chosen to be consistent with java/lang/Class.
|
CompiledTmpVariable |
getThisValue()
In the interest of minimizing the number of tmp variables floating around in the heap, each type may create a value object (when needed) and store it (with a weak reference) for later use.
|
java.util.Collection<JavaAnnotation> |
getTypeAnnotations()
Applies to elements that are used as a type reference which since JDK8 can be annotated.
|
JavaClass |
getTypeErasure()
Gets the type erasure of this type, as defined by the JLS3.
|
java.lang.String |
getTypeSignature()
Gets the type signature for this type, as defined by the JVMS3.
|
java.lang.String |
getUniqueIdentifier()
Gets a unique identifier for this type.
|
java.lang.String |
getUnqualifiedName()
Gets the name of this type in its unqualified form.
|
java.util.Collection<UnresolvedType> |
getUnresolvedInterfaces()
When reverse engineering bytecode, some types cannot be resolved if the correct owning project is not associated to the JavaProvider.
|
UnresolvedType |
getUnresolvedSuperclass()
When reverse engineering bytecode, some types cannot be resolved if the correct owning project is not associated to the JavaProvider.
|
java.net.URL |
getURL()
If the input for this type is a *.class file, the returned URL will be for the *.class file.
|
java.lang.String |
getVMName()
Gets the VM name for this type.
|
boolean |
isAnnotation() |
boolean |
isAnonymousClass()
Determine if this is an anonymous class type.
|
boolean |
isArray() |
boolean |
isAssignableFrom(JavaType subject)
Consider the following expression where S (subject) represents another type and T (this) represents this type.
|
boolean |
isEnum() |
boolean |
isErasedType()
Is this a class with type parameters instantiated without any type arguments? For instance, the type of 'new ArrayList()' would be an erased type.
|
boolean |
isExported() |
boolean |
isInterface() |
boolean |
isLocalClass()
Determine if this is a local (to a method) class type.
|
boolean |
isMemberClass()
Determine if this is a member class type.
|
boolean |
isPrimitive()
Determine if this type is a primitive type.
|
boolean |
isSubtypeOf(JavaType supertype)
True if this is a subtype of the indicated argument.
|
getActualTypeArguments, getTypeParameter, getTypeParameters, hasActualTypeArguments, hasTypeParameters
getOwningClass, isAbstract, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
getResolvedType, getUnresolvedType
getAnnotation, getAnnotations, getDeclaredAnnotation, getDeclaredAnnotations
getElementKind, getFile, getModifiers, getOwner, getSourceElement, isDeprecated, isFinal, isHidden, isSourceElement, isSynthetic, printCompiledInfo
static final JavaType[] EMPTY_ARRAY
@Deprecated JavaClass getClosestClass()
getTypeErasure()
.getTypeErasure()
. If this type is a ...
... JavaClass, then it is returned.
... JavaTypeVariable, then the first bound is returned. There is always at least one bound.
... JavaWildcardType, then the lower bound is returned. There is always at least one lower bound.
JavaClass getTypeErasure()
CompiledTmpVariable getThisValue()
EXPERIMENTAL.
boolean isPrimitive()
boolean isArray()
JavaType getComponentType()
int getArrayDimensions()
JavaType getBaseComponentType()
boolean isInterface()
boolean isEnum()
boolean isAnnotation()
boolean isExported()
boolean isMemberClass()
boolean isAnonymousClass()
boolean isLocalClass()
java.lang.String getName()
The name of a non-parameterized top-level type of the form "pkg.Cls" is "Cls".
The name of a non-parameterized member type of the form "pkg.Cls.InnerClass" is "InnerClass".
The name of an array type T[] is the name of T suffixed by the appropriate number of "[]"s.
The name of a parameterized type is the same as the name of its raw type. That is, the name of "pkg.Cls<String>" is simply "Cls".
The name of a wildcard type is always "?".
The name of a type parameter type is the type parameter name.
The name of a primitive type is the primitive type name.
The name of a local inner class type is just its name.
The name of an anonymous class type is the empty String.
getName
in interface JavaHasName
java.lang.String getUnqualifiedName()
Unlike getName(), this will contain type parameters in their unqualified form. In other words, for types containing no type parameterization, the behavior is the same as getName().
java.lang.String getQualifiedName()
The source name of a non-parameterized top-level type of the form "pkg.Cls" is "pkg.Cls".
The source name of a non-parameterized member type of the form T.InnerClass (that is, a member type InnerClass that is a member of type T) is the source name of T suffixed with by ".InnerClass", e.g. "java.util.Map.Entry", "pkg.Cls<?>.InnerClass".
The source name of a parameterized type starts with the source name of the raw type and lists the source name of all of its actual type argumenths, e.g. "java.util.List<java.lang.String>". The source name of an array type T[] is the source name of T suffixed by the appropriate number of "[]"s.
The source name of a wildcard type is the string with which it would appear in a source file. The three possible forms this can take are: "?", "? extends T", "? super T".
The source name of a type parameter type is just its name.
The source name of a primitive type is the primitive type name.
The source name of a local inner class type is just its name because a local inner class is referenced, in a source file, by its name.
The name of an anonymous class type is the empty String.
java.lang.Object
java.util.Map<String,String>
java.lang.String[][]
java.lang.String getRawName()
The raw name of a parameterized top-level or member or local inner type is the source name of its type erasure, as defined by the JLS3. Think of the raw name as the source name with all parameterization stripped out.
The raw name of an array type T[] is the raw name of T suffixed by the appropriate number of "[]"s.
The raw name for any other type is the same as its source name.
java.lang.String getVMName()
The VM name of a non-parameterized top-level type of the form "pkg.Cls" is "pkg/Cls".
The VM name of a non-parameterized member-level type of the form "pkg.Cls.InnerClass" is "pkg/Cls$InnerClass".
The VM name of a parameterized type is the VM name of the raw type. Because parameterization is stripped at run-time, we will omit it from the VM name.
The VM name of an array type T[] is the VM name of T suffixed by the appropriate number of "[]"s.
The VM name of a local inner class or anonymous inner class is a string that uniquely identifies it from all other types and is usually prefixed with the VM name of its directly enclosing class. For example, the VM name for an anonymous inner class belonging to the type "pkg.Cls" may be "pkg/Cls$1" and the VM name for a local class of that type may be "pkg/Cls$1foo.
The VM name of any other type is the same as its source name.
java.lang.String getDescriptor()
For jdk < 1.5, the "FieldDescriptor" is returned (JVMS2). For jdk < 1.5, descriptors and signatures are the same thing.
For jdk >= 1.5, a type signature of the type erasure is returned.
Note: Do not confuse a type's descriptor with a method's descriptor. The descriptor of the type of a method is the field descriptor describing its return type. The descriptor of a method describes parameter types.
java.lang.String getTypeSignature()
A JavaClass returns its "ClassTypeSignature" (JVMS3). A JavaClass is uniquely identified by its type signature. Example value: Ljava/util/List<Ljava/lang/Object;>;
A JavaTypeVariable returns its "TypeVariableSignature" (JVMS3). A type variable is uniquely identified by the combination of its owning declaration AND its type signature. Example value: TE;
A WildcardType returns its "TypeArgument" value (JVMS3). A wildcard type is uniquely identified by its type signature. Example values: *
+Ljava/lang/Object;
.
java.lang.String getSignature()
The "Signature" attribute for a field is the "ClassTypeSignature" for its type.
The "Signature" attribute for a method involves the "ClassSignature"s for its type parameters and the "ClassTypeSignature"s of its remaining constituent types.
A JavaClass returns its "ClassSignature" (JVMS3).
A JavaTypeVariable does not have a class signature, but will return a string for use in a class signature or a method signature.
A WildcardType does not have a class signature and may not part of a class signature. Its return value is undefined.
java.lang.String getUniqueIdentifier()
getUniqueIdentifier
in interface JavaMember
JavaPackage getPackage()
java.lang.String getPackageName()
JavaType getSuperclass()
If this is a JavaClass: Null for java/lang/Object and primitive types, non-null otherwise. Where no base class was declared, java/lang/Object is returned, even for interfaces.
If this is a JavaType: Null if no superclass was declared AND an interface was declared.
If this is a JavaWildcardType: Always null.
UnresolvedType getUnresolvedSuperclass()
java.util.Collection<JavaType> getInterfaces()
java.util.Collection<UnresolvedType> getUnresolvedInterfaces()
java.util.Set<JavaType> getHierarchy()
boolean isAssignableFrom(JavaType subject)
void method( S subject ) { T variable = subject; }Notice that because the parameter subject is not a constant-value, the assignment conversion will not perform the implicit narrowing conversion.
NOTE: isAssignableFrom will do auto-boxing IFF a JavaProvider can be retrieved from the subject or target, otherwise auto-boxing cannot be performed. Consider using one of the Conversions.applyAssignmentConversion methods which allow specification of a JavaProvider. SourceFile has a method to retrieve a JavaProvider.
boolean isSubtypeOf(JavaType supertype)
java.util.Collection<JavaField> getDeclaredFields()
JavaField getDeclaredField(java.lang.String name)
name
- Require non-null.java.util.Collection<JavaMethod> getDeclaredConstructors()
JavaMethod getDeclaredConstructor(JavaType[] parameters)
parameters
- Null indicates an empty parameter list.java.util.Collection<JavaMethod> getDeclaredMethods()
java.util.Collection<JavaMethod> getDeclaredMethods(java.lang.String name)
JavaMethod getDeclaredMethod(java.lang.String name, JavaType[] parameters)
parameters
- Null indicates an empty parameter list.java.util.Collection<JavaClass> getDeclaredClasses()
JavaClass getDeclaredClass(java.lang.String name)
java.util.Collection<JavaClass> getDeclaredAnonymousClasses()
java.util.Collection<JavaClass> getDeclaredLocalClasses()
JavaMethod getClinitMethod()
java.util.Collection<JavaField> getFields()
The implicit length field for array types is not reflected by this method.
JavaField getField(java.lang.String name)
The implicit length field for array types is not reflected by this method.
name
- Require non-null.java.util.Collection<JavaMethod> getMethods()
java.util.Collection<JavaMethod> getMethods(java.lang.String name)
name
- Require non-null.JavaMethod getMethod(java.lang.String name, JavaType[] parameters)
name
- Require non-null.parameters
- Null indicates an empty parameter list.java.util.Collection<JavaClass> getClasses()
JavaClass getClass(java.lang.String name)
Note: Be careful not to get this confused with JavaProvider.getClass( String ).
java.net.URL getURL()
boolean equals(java.lang.Object o)
equals
in class java.lang.Object
java.util.Collection<JavaAnnotation> getTypeAnnotations()
boolean isErasedType()