oracle.javatools.parser.java.v2.common
Class AbstractType
java.lang.Object
oracle.javatools.parser.java.v2.common.AbstractElement
oracle.javatools.parser.java.v2.common.AbstractType
- All Implemented Interfaces:
- JavaConstants, JavaErrors, JavaOperators, JavaPreferences, JavaTokens, Element, JavaElement, JavaHasAnnotations, JavaHasName, JavaHasType, JavaIsGeneric, JavaMember, JavaType
- Direct Known Subclasses:
- AbstractClass
public abstract class AbstractType
- extends AbstractElement
- implements JavaType
An abstract implementation of JavaType. Provided so that all
implementations have a consistent behavior for equals(O) and
hashCode(). If you want to implement JavaClass, then you should
extend AbstractClass instead.
Fields inherited from interface oracle.javatools.parser.java.v2.JavaConstants |
ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_none, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICTFP, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACCX_DEPRECATED, ACCX_HIDDEN, ARRAY_implements, BOUND_EXTENDS, BOUND_NARROW, BOUND_NONE, BOUND_SUPER, ELEM_ANNOTATION, ELEM_base, ELEM_CLASS, ELEM_COMPONENT, ELEM_EXPRESSION, ELEM_FIELD, ELEM_FILE, ELEM_IMPORT, ELEM_invalid, ELEM_LOCAL_VARIABLE, ELEM_max, ELEM_METHOD, ELEM_NOTHING, ELEM_PACKAGE, ELEM_SELF_VARIABLE, ELEM_STATEMENT_LABEL, ELEM_TMP_VARIABLE, ELEM_TYPE_VARIABLE, ELEM_WILDCARD_TYPE, ELEM_words, EMPTY_OBJECT_ARRAY, EMPTY_STRING_ARRAY, FOR_ENHANCED, FOR_EXPRESSION, FOR_VARIABLE_D, kEmptyCollection, opt2srcTable, PACKAGE_INFO, PRIMITIVE_autoboxes, PRIMITIVE_binary, PRIMITIVE_BOOLEAN, PRIMITIVE_BYTE, PRIMITIVE_CHAR, PRIMITIVE_descriptors, PRIMITIVE_DOUBLE, PRIMITIVE_FLOAT, PRIMITIVE_INT, PRIMITIVE_invalid, PRIMITIVE_LONG, PRIMITIVE_max, PRIMITIVE_NULL, PRIMITIVE_SHORT, PRIMITIVE_tokens, PRIMITIVE_unary, PRIMITIVE_VOID, SRC_ANNOTATION, SRC_base, SRC_BLOCK, SRC_CATCH_PARAMETER, SRC_CLASS, SRC_CLASS_BODY, SRC_CLASS_INITIALIZER, SRC_CONSTRUCTOR_D, SRC_DOC_base, SRC_DOC_BLOCK_TAG, SRC_DOC_COMMENT, SRC_DOC_DESCRIPTION, SRC_DOC_INLINE_TAG, SRC_DOC_max, SRC_DOC_REFERENCE, SRC_DOC_TAG_NAME, SRC_DOC_TEXT, SRC_ENUM_CONSTANT_D, SRC_ERROR, SRC_EXPR_ANNOTATION, SRC_EXPR_ARRAY_ACCESS, SRC_EXPR_ASSIGNMENT, SRC_EXPR_base, SRC_EXPR_DOT, SRC_EXPR_INFIX, SRC_EXPR_LIST, SRC_EXPR_LITERAL, SRC_EXPR_max, SRC_EXPR_METHOD_CALL, SRC_EXPR_NEW_ARRAY, SRC_EXPR_NEW_CLASS, SRC_EXPR_QUESTION, SRC_EXPR_SIMPLE_NAME, SRC_EXPR_TYPE, SRC_EXPR_TYPECAST, SRC_EXPR_UNARY, SRC_EXPR_WRAPPER, SRC_FIELD_D, SRC_FIELD_VARIABLE, SRC_FILE, SRC_FORMAL_PARAMETER, SRC_FORMAL_PARAMETER_LIST, SRC_IMPORT_D, SRC_INTERFACES_CLAUSE, SRC_invalid, SRC_LABEL, SRC_LEX_base, SRC_LEX_BLANKLINE, SRC_LEX_COMMENT, SRC_LEX_max, SRC_LEX_SQLJ, SRC_LOCAL_VARIABLE, SRC_LOCAL_VARIABLE_D, SRC_max, SRC_METHOD_D, SRC_NAME, SRC_PACKAGE_D, SRC_STMT_ASSERT, SRC_STMT_base, SRC_STMT_BLOCK, SRC_STMT_BREAK, SRC_STMT_CATCH, SRC_STMT_CONTINUE, SRC_STMT_DO, SRC_STMT_ELSE, SRC_STMT_EMPTY, SRC_STMT_EXPRESSION, SRC_STMT_FINALLY, SRC_STMT_FOR, SRC_STMT_IF, SRC_STMT_max, SRC_STMT_RETURN, SRC_STMT_SWITCH, SRC_STMT_SYNCH, SRC_STMT_THROW, SRC_STMT_TRY, SRC_STMT_WHILE, SRC_SUPERCLASS_CLAUSE, SRC_SWITCH_LABEL, SRC_THROWS_CLAUSE, SRC_TYPE_ARGUMENT, SRC_TYPE_PARAMETER, SRC_TYPE_REF, SRC_words, TY_ANNOTATE, TY_CLASS, TY_ENUM, TY_INTERFACE, TY_invalid, TY_max, TY_words |
Fields inherited from interface oracle.javatools.parser.java.v2.JavaErrors |
ERROR_ABSTRACT_CLASS, ERROR_AMBIGUOUS_IMPORT, ERROR_AMBIGUOUS_REF, ERROR_ASSERT_IDENTIFIER, ERROR_base, ERROR_BREAK_OUTSIDE_SWITCH_OR_LOOP, ERROR_CANCELLED, ERROR_CANT_ASSIGN, ERROR_CANT_EXTEND_ENUM, ERROR_CANT_EXTEND_FINAL, ERROR_CANT_EXTEND_INTERFACE, ERROR_CANT_IMPLEMENT_CLASS, ERROR_CANT_TYPECAST, ERROR_CATEGORY_ALL, ERROR_CATEGORY_COMPILE, ERROR_CATEGORY_PARSE, ERROR_CATEGORY_SCAN, ERROR_CATEGORY_unclassified, ERROR_CHECK_EXCEPTION, ERROR_CLASS_CIRCULARITY, ERROR_COMPILE_base, ERROR_COMPILE_GENERIC, ERROR_COMPILE_max, ERROR_CONSTRUCTOR_NAME, ERROR_CONTINUE_OUTSIDE_OF_LOOP, ERROR_DUPLICATE, ERROR_EMPTY_CHAR_LITERAL, ERROR_EMPTY_EXPRESSION, ERROR_EXPECTING_ONE, ERROR_EXPECTING_TWO, ERROR_EXPECTING_TYPE, ERROR_EXTENDS_NOT_ALLOWED, ERROR_EXTENDS_TOO_MANY, ERROR_FORWARD_REFERENCE, ERROR_ILLEGAL_ANNOTATION, ERROR_ILLEGAL_DEFAULT, ERROR_ILLEGAL_LABEL, ERROR_ILLEGAL_START_OF_EXPR, ERROR_ILLEGAL_TYPE_PARAMETERS, ERROR_ILLEGAL_VARARGS, ERROR_IMPLEMENTS_NOT_ALLOWED, ERROR_IMPORT_NOT_FOUND, ERROR_INTERNAL, ERROR_INVALID_CHAR_LITERAL, ERROR_INVALID_ESCAPE_SEQUENCE, ERROR_INVALID_EXPR_STMT, ERROR_INVALID_NAME, ERROR_INVALID_OPERATION, ERROR_INVALID_STRING_LITERAL, ERROR_INVALID_SUPERTYPE, ERROR_keys, ERROR_LONE_CATCH, ERROR_LONE_ELSE, ERROR_LONE_FINALLY, ERROR_LONE_TRY, ERROR_max, ERROR_MEMBER_NOT_FOUND, ERROR_METHOD_NOT_FOUND, ERROR_MISSING_CASE_OR_DEFAULT_LABEL, ERROR_MISSING_CONDITION, ERROR_MISSING_METHOD_BODY, ERROR_MODIFIER_REPEATED, ERROR_MULTIPLE_COMPONENTS, ERROR_NAME_NOT_FOUND, ERROR_none, ERROR_NOT_ACCESSIBLE, ERROR_NOT_ANNOTATION_TYPE, ERROR_NOT_ASSIGNABLE, ERROR_NOT_GENERIC_TYPE, ERROR_NOT_IMPLEMENTED_YET, ERROR_NOT_THROWABLE, ERROR_NUMBER_FORMAT, ERROR_NUMERIC_OVERFLOW, ERROR_NUMERIC_UNDERFLOW, ERROR_ONLY_STATIC_ACCESS, ERROR_PARSE_base, ERROR_PARSE_GENERIC, ERROR_PARSE_max, ERROR_REQUIRE_ARRAY, ERROR_REQUIRE_BLOCK, ERROR_REQUIRE_FINAL, ERROR_REQUIRE_OBJECT, ERROR_REQUIRE_OUTER_CLASS, ERROR_SCAN_base, ERROR_SCAN_GENERIC, ERROR_SCAN_max, ERROR_TYPE_ARGUMENT_MISMATCH, ERROR_TYPE_IS_NOT_AUTOCLOSEABLE, ERROR_TYPE_IS_NOT_DISJUNCTIVE, ERROR_TYPE_NOT_ALLOWED, ERROR_TYPE_NOT_FOUND, ERROR_UNEXPECTED, ERROR_UNKNOWN, ERROR_VOID_RETURN, ERROR_warnings, ERROR_words, SEVERITY_ERROR, SEVERITY_FATAL, SEVERITY_LINT, SEVERITY_WARNING, SEVERITY_ZERO, WARNING_AMBIGUOUS_DOC_REFERENCE, WARNING_ASSERT_IDENTIFIER, WARNING_DOC_REFERENCE_NOT_FOUND, WARNING_IMPORT_UNUSED, WARNING_INVALID_NAME, WARNING_METHOD_NAME |
Fields inherited from interface oracle.javatools.parser.java.v2.JavaOperators |
OPT_ADD, OPT_ADDASG, OPT_AND, OPT_ANNOTATION, OPT_ARRAYCONST, OPT_ASG, OPT_base, OPT_BITAND, OPT_BITANDASG, OPT_BITNOT, OPT_BITOR, OPT_BITORASG, OPT_BITXOR, OPT_BITXORASG, OPT_CLASS_LITERAL, OPT_COND, OPT_DEREF, OPT_DIV, OPT_DIVASG, OPT_DOT, OPT_EQ, OPT_GE, OPT_GT, OPT_INSTANCEOF, OPT_invalid, OPT_INVOKE, OPT_LE, OPT_LIST, OPT_LITERAL, OPT_LSH, OPT_LSHASG, OPT_LT, OPT_max, OPT_MINUS, OPT_MINUSASG, OPT_MOD, OPT_MODASG, OPT_MUL, OPT_MULASG, OPT_NEGATIVE, OPT_NESTEXP, OPT_NEWARRAY, OPT_NEWOBJECT, OPT_NOT, OPT_NOTEQ, OPT_OR, OPT_POSITIVE, OPT_POSTDEC, OPT_POSTINC, OPT_precedence, OPT_PREDEC, OPT_PREINC, OPT_QUALIFIED_SUPER, OPT_QUALIFIED_THIS, OPT_RSH, OPT_RSHASG, OPT_SIMPLE_NAME, OPT_tokens, OPT_TYPE, OPT_TYPECAST, OPT_URSH, OPT_URSHASG, OPT_words |
Fields inherited from interface oracle.javatools.parser.java.v2.JavaTokens |
DW_values, DW_words, J2SE_13, J2SE_14, J2SE_15, J2SE_16, J2SE_17, J2SE_MAX, J2SE_MIN, KW_ABSTRACT, KW_ASSERT, KW_base, KW_BOOLEAN, KW_BREAK, KW_BYTE, KW_CASE, KW_CATCH, KW_CHAR, KW_CLASS, KW_CONST, KW_CONTINUE, KW_DEFAULT, KW_DO, KW_DOUBLE, KW_ELSE, KW_ENUM, KW_EXTENDS, KW_FINAL, KW_FINALLY, KW_FLOAT, KW_FOR, KW_GOTO, KW_IF, KW_IMPLEMENTS, KW_IMPORT, KW_INSTANCEOF, KW_INT, KW_INTERFACE, KW_j2se13_max, KW_j2se14_max, KW_j2se15_max, KW_j2se16_max, KW_LONG, KW_max, KW_NATIVE, KW_NEW, KW_PACKAGE, KW_PRIVATE, KW_PROTECTED, KW_PUBLIC, KW_RETURN, KW_SHORT, KW_STATIC, KW_STRICTFP, KW_SUPER, KW_SWITCH, KW_SYNCHRONIZED, KW_THIS, KW_THROW, KW_THROWS, KW_TRANSIENT, KW_TRY, KW_VOID, KW_VOLATILE, KW_WHILE, KW_words, OP_AND_ASG, OP_ASG, OP_AT, OP_base, OP_BINAND, OP_binary, OP_BINNOT, OP_BINOR, OP_BINXOR, OP_COLON, OP_COMMA, OP_DEC, OP_DIV, OP_DIV_ASG, OP_DOT, OP_ELLIPSIS, OP_EQ, OP_GE, OP_GT, OP_HASH, OP_INC, OP_LBRACE, OP_LBRACKET, OP_LE, OP_LOGAND, OP_LOGNOT, OP_LOGOR, OP_LPAREN, OP_LSH, OP_LSH_ASG, OP_LT, OP_max, OP_MINUS, OP_MINUS_ASG, OP_MOD, OP_MOD_ASG, OP_MUL, OP_MUL_ASG, OP_NE, OP_OR_ASG, OP_PLUS, OP_PLUS_ASG, OP_prefix, OP_QUES, OP_RBRACE, OP_RBRACKET, OP_RPAREN, OP_RSH, OP_RSH_ASG, OP_SEMI, OP_URSH, OP_URSH_ASG, OP_words, OP_XOR_ASG, TK_BOOLEAN_LITERAL, TK_CHAR_LITERAL, TK_DOC_COMMENT, TK_DOUBLE_LITERAL, TK_EOF, TK_FLOAT_LITERAL, TK_IDENTIFIER, TK_INT_LITERAL, TK_LITERAL_base, TK_LITERAL_max, TK_LONG_LITERAL, TK_max, TK_MULTI_COMMENT, TK_NULL_LITERAL, TK_SINGLE_COMMENT, TK_SQLJ, TK_STRING_LITERAL, TK_WHITESPACE |
Fields inherited from interface oracle.javatools.parser.java.v2.JavaPreferences |
BLANKLINES_AFTER_LAST_MEMBER, BLANKLINES_BEFORE_DOC_COMMENT, BLANKLINES_BEFORE_FIELD, BLANKLINES_BEFORE_FIRST_CLASS, BLANKLINES_BEFORE_FIRST_MEMBER, BLANKLINES_BEFORE_MEMBER_CLASS, BLANKLINES_BEFORE_METHOD, BLANKLINES_EMPTY_ANONYMOUS, BLANKLINES_EMPTY_BLOCK, BLANKLINES_EMPTY_CLASS, BLANKLINES_EMPTY_METHOD, BLANKLINES_IMPORTS_AFTER, BLANKLINES_PACKAGE_AFTER, BLANKLINES_PRESERVE_COUNT, CLONE_QUALIFIES_TYPES, FALSE, IGNORED_I, IGNORED_Z, IMPORT_GROUP_IMPORTS, IMPORT_GROUP_PACKAGE_DEPTH, IMPORT_INNER_CLASS_NAME, IMPORT_NARROW_MEMBERS_THRESHOLD, IMPORT_NARROW_THRESHOLD, INDENT_BLOCK_CHILDREN, INDENT_CLASS_MEMBERS, INDENT_CONTROL_BLOCKS, INDENT_NUM_SPACES, INDENT_REPLACE_WITH_TABS, INDENT_SWITCH_CASES, INDENT_TAB_SIZE, INTEGER_ALWAYS_WRAP, INTEGER_NEVER_WRAP, INTEGER_WRAP_IF_LONG, MEMBER_ORDER, NEWLINE_AFTER_SWITCH_CASE, NEWLINE_ARRAY_BRACES, NEWLINE_BLOCK_BRACES, NEWLINE_CATCH, NEWLINE_CLASS_BRACES, NEWLINE_ELSE, NEWLINE_EXTENDS, NEWLINE_FINALLY, NEWLINE_IMPLEMENTS, NEWLINE_METHOD_BRACES, NEWLINE_THROWS, NEWLINE_WHILE, ONE, PREFERENCES_base, PREFERENCES_defaults, PREFERENCES_keys, PREFERENCES_max, PREFERENCES_sun, SPACE_ARGUMENTS_BEFORE, SPACE_ASSIGN_AROUND, SPACE_BINARYOP_AROUND, SPACE_BRACES_AROUND, SPACE_BRACKETS_WITHIN, SPACE_COLON_AFTER, SPACE_COLON_BEFORE, SPACE_COMMA_AFTER, SPACE_COMMA_BEFORE, SPACE_KEYWORD_AFTER, SPACE_OPENBRACE_BEFORE, SPACE_PARAMETERS_BEFORE, SPACE_PARENS_WITHIN, SPACE_QUESTION_AFTER, SPACE_QUESTION_BEFORE, SPACE_SEMICOLON_AFTER, SPACE_SEMICOLON_BEFORE, SPACE_TYPECAST_AFTER, TRI_ALWAYS_WRAP, TRI_NEVER_WRAP, TRI_WRAP_IF_LONG, TRUE, TWO, UNKNOWN_I, UNKNOWN_Z, WRAP_ALIGN, WRAP_ARRAY_CONSTANT, WRAP_BINARY_OPERATOR, WRAP_DOT_CHAIN, WRAP_EXTENDS, WRAP_FOR_STATEMENT, WRAP_INVOKE_ARGUMENTS, WRAP_LINE_WIDTH, WRAP_MODIFIERS, WRAP_PARAMETER_LIST, WRAP_QUES_OPERATOR, WRAP_THROWS, ZERO |
Method Summary |
void |
clearCompiledInfo()
Overrides should chain. |
boolean |
equals(java.lang.Object o)
|
JavaAnnotation |
getAnnotation(JavaType annotationType)
Retrieves the annotation declared on this element that matches
the input annotation type. |
java.util.Collection |
getAnnotations()
Retrieves all the annotations declared on this element. |
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 |
getClasses()
Iteratively retrieves all member classes declared in this class
or its hierarchy. |
JavaMethod |
getClinitMethod()
|
JavaClass |
getClosestClass()
Deprecated. Please use getTypeErasure() . |
JavaType |
getComponentType()
|
JavaClass |
getDeclaredClass(java.lang.String name)
|
java.util.Collection |
getDeclaredClasses()
In order to get all inner classes, clients must recurse through
direct inner classes. |
JavaMethod |
getDeclaredConstructor(JavaType[] targetTypes)
|
java.util.Collection |
getDeclaredConstructors()
|
JavaField |
getDeclaredField(java.lang.String name)
|
java.util.Collection |
getDeclaredFields()
|
JavaMethod |
getDeclaredMethod(java.lang.String name,
JavaType[] targetTypes)
|
java.util.Collection |
getDeclaredMethods()
|
java.util.Collection |
getDeclaredMethods(java.lang.String name)
|
abstract java.lang.String |
getDescriptor()
Gets the descriptor for this type, as defined by the JVMS2. |
abstract int |
getElementKind()
|
JavaField |
getField(java.lang.String name)
Iteratively searches for a field declared in this class or its
hierarchy. |
java.util.Collection |
getFields()
Iteratively retrieves all fields declared in this class and its
hierarchy. |
java.util.Set |
getHierarchy()
Recursively gets the full list of all resolved superclasses and
super-interfaces. |
java.util.Collection |
getInterfaces()
The name "getInterfaces" was chosen to be consistent with
java/lang/Class. |
JavaMethod |
getMethod(java.lang.String name,
JavaType[] targetTypes)
Iteratively searches for a method declared in this class or its
hierarchy. |
java.util.Collection |
getMethods()
Iteratively retrieves all methods declared in this class or its
hierarchy. |
java.util.Collection |
getMethods(java.lang.String name)
Iteratively retrieves all methods declared in this class or its
hierarchy. |
int |
getModifiers()
|
abstract java.lang.String |
getName()
Gets the simplest name of this type with "[]"s if present. |
JavaElement |
getOwner()
TODO: Document me! |
JavaClass |
getOwningClass()
|
JavaMethod |
getOwningMethod()
|
JavaPackage |
getPackage()
Gets the owning package, null if N/A. |
java.lang.String |
getPackageName()
Gets the qualified name of the owning package. |
abstract 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. |
JavaType |
getResolvedType()
A JavaField instance will return the field's type. |
java.lang.String |
getSignature()
Gets the "Signature" attribute of this type, as defined by the
JVMS3. |
java.lang.String |
getSourceName()
|
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. |
abstract JavaClass |
getTypeErasure()
Gets the type erasure of this type, as defined by the JLS3. |
JavaTypeVariable |
getTypeParameter(java.lang.String name)
|
abstract 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 byecode, some types cannot be resolved
if the correct owning project is not associated to the JavaProvider. |
UnresolvedType |
getUnresolvedType()
Information about a type that has not been resolved. |
java.net.URL |
getURL()
If the input for this type is a *.class file, the returned URL
will be for the *.class file. |
abstract java.lang.String |
getVMName()
Gets the VM name for this type. |
int |
hashCode()
|
boolean |
isAnnotation()
|
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 |
isExported()
|
boolean |
isInterface()
|
boolean |
isMemberClass()
True if this is a member type. |
boolean |
isPrimitive()
|
boolean |
isSubtypeOf(JavaType supertype)
True if this is a subtype of the indicated argument. |
java.lang.String |
printCompiledInfo()
Debugging function for printing out compiled information. |
Methods inherited from class oracle.javatools.parser.java.v2.common.AbstractElement |
getActualTypeArguments, getDeclaredAnnotation, getDeclaredAnnotations, getSourceElement, getSourceSymbol, getTypeParameters, hasActualTypeArguments, hasTypeParameters, isAbstract, isDeprecated, isFinal, isHidden, isPackagePrivate, isPrivate, isProtected, isPublic, isSourceElement, isStatic, isSynthetic, isTransient, isVarargs |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
AbstractType
public AbstractType()
getElementKind
public abstract int getElementKind()
- Specified by:
getElementKind
in interface JavaElement
- Specified by:
getElementKind
in class AbstractElement
- Returns:
- The type of JavaElement this is. Valid values are
JavaConstants.ELEM_*.
getName
public abstract java.lang.String getName()
- Description copied from interface:
JavaType
- Gets the simplest name of this type with "[]"s if present.
The name of a non-parametrized top-level type of the form
"pkg.Cls" is "Cls".
The name of a non-parametrized 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 parametrized 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 should be pretty obvious.
The name of a primitive type should be pretty obvious.
The name of a local inner class is just its name.
An anonymous inner classes does not have a name and will return
the empty string.
- Specified by:
getName
in interface JavaHasName
- Specified by:
getName
in interface JavaType
- Returns:
- The simple name of this type with "[]"s if present.
getQualifiedName
public abstract java.lang.String getQualifiedName()
- Description copied from interface:
JavaType
- Gets the fully qualified name of this type in source format.
Here, "source format" means the format of a type reference in a
source compilation unit. A type's source name uniquely identifies
a type in a specific scope but not in the global scope.
The source name of a non-parametrized top-level type of the form
"pkg.Cls" is "pkg.Cls".
The source name of a non-parametrized 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 parametrized 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 is just its name.
The source name of a primitive type should be pretty obvious.
The source name of a local inner class is just its name because a
local inner class is referenced, in a source file, by its
name.
An anonymous inner classes does not have a source name. It will
return the empty string for its source name.
Open for discussion: What should be returned by an anonymous
class? Technically, the concept of a source name is irrelevant
because anonymous classes may not be referred to in a source
compilation unit.
- Specified by:
getQualifiedName
in interface JavaType
- Returns:
- The fully qualified source name for this type, empty for
anonymous classes. Example values:
java.lang.Object
java.util.Map<String,String>
java.lang.String[][]
getVMName
public abstract java.lang.String getVMName()
- Description copied from interface:
JavaType
- Gets the VM name for this type. The JVMS3 defines an internal
name format for raw classes. We call this the VM name of a type.
It's useful for loading known types such as "java/lang/Object"
and "java/lang/Throwable". Here is how we define the "VM name"
for all types:
The VM name of a non-parametrized top-level type of the form
"pkg.Cls" is "pkg/Cls".
The VM name of a non-parametrized member-level type of the form
"pkg.Cls.InnerClass" is "pkg/Cls$InnerClass".
The VM name of a parametrized type is the VM name of the raw
type. Because parametrization 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, an anonymous inner class belonging to the
type "pkg.Cls" may return "pkg/Cls$1".
The VM name of any other type is the same as its source name.
- Specified by:
getVMName
in interface JavaType
- Returns:
- The raw name, also known as the VM name, of this type.
e.g. "java/lang/Object", "java/util/Map$Entry"
getDescriptor
public abstract java.lang.String getDescriptor()
- Description copied from interface:
JavaType
- Gets the descriptor for this type, as defined by the JVMS2.
Note: The descriptor is equivalent to the type signature of this
type's erasure.
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.
- Specified by:
getDescriptor
in interface JavaType
- Returns:
- The descriptor as defined in the JVMS2. Always non-null.
Example values: "I", "Ljava/lang/Object;"
getUniqueIdentifier
public abstract java.lang.String getUniqueIdentifier()
- Description copied from interface:
JavaType
- Gets a unique identifier for this type. Two types are equal iff
their unique identifiers are equal.
- Specified by:
getUniqueIdentifier
in interface JavaMember
- Specified by:
getUniqueIdentifier
in interface JavaType
- Returns:
- The unique identifier for this type.
getTypeErasure
public abstract JavaClass getTypeErasure()
- Description copied from interface:
JavaType
- Gets the type erasure of this type, as defined by the JLS3. A
simple way of thinking of a type erasure is that it's the
"closest non-generic class" to this type. You can also think of
it as the 1.4-compatible class for this type.
- Specified by:
getTypeErasure
in interface JavaType
- Returns:
- The JavaClass for this type's erasure.
getResolvedType
public JavaType getResolvedType()
- Description copied from interface:
JavaHasType
- A JavaField instance will return the field's type.
A JavaMethod instance will return the method's return type.
A JavaVariable instance will return the variable's type.
A JavaType instance will return itself.
- Specified by:
getResolvedType
in interface JavaHasType
- Returns:
- The type of this compiled object.
getUnresolvedType
public UnresolvedType getUnresolvedType()
- Description copied from interface:
JavaHasType
- Information about a type that has not been resolved. Defined in
order to provide information when getResolvedType() == null. The
typical use is to obtain a String for display purposes.
- Specified by:
getUnresolvedType
in interface JavaHasType
- Overrides:
getUnresolvedType
in class AbstractElement
- Returns:
- An object that provides information on the type we are
trying to resolve. Always non-null.
getModifiers
public int getModifiers()
- Specified by:
getModifiers
in interface JavaElement
- Specified by:
getModifiers
in class AbstractElement
- Returns:
- The access modifiers on this element.
getOwner
public JavaElement getOwner()
- Description copied from interface:
JavaElement
- TODO: Document me!
- Specified by:
getOwner
in interface JavaElement
- Specified by:
getOwner
in class AbstractElement
getOwningClass
public JavaClass getOwningClass()
- Specified by:
getOwningClass
in interface JavaMember
- Returns:
- The owning class. If this is an instance of a generic
field, then this will return an instance of the owning class as
well. For example, consider:
class C<E>
{
E field;
{
C generic = new C();
generic.field = null;
C<String> specific = new C<String>();
specific.field = null;
}
}
If this instance represents the member field accessed by
"generic.field", then getOwningClass will return the type for
"C".
If this instance represents the member field accessed by
"specific.field", then getOwningClass will return the type for
"C<String>".
Further, the expressions "generic.field" and "specific.field" do
not refer to the same JavaField instance.
getOwningMethod
public JavaMethod getOwningMethod()
isExported
public boolean isExported()
- Specified by:
isExported
in interface JavaType
- Returns:
- True if this is a top-level class or a member inner class.
False otherwise (local classes and anonymous classes).
isInterface
public boolean isInterface()
- Specified by:
isInterface
in interface JavaType
- Returns:
- True if this is an interface type or an annotation type.
False otherwise.
isAnnotation
public boolean isAnnotation()
- Specified by:
isAnnotation
in interface JavaType
- Returns:
- True if this is an annotation type. False otherwise.
isEnum
public boolean isEnum()
- Specified by:
isEnum
in interface JavaType
- Returns:
- True if this an enumeration type. False otherwise.
isMemberClass
public boolean isMemberClass()
- Description copied from interface:
JavaType
- True if this is a member type.
- Specified by:
isMemberClass
in interface JavaType
isPrimitive
public boolean isPrimitive()
- Specified by:
isPrimitive
in interface JavaType
- Returns:
- True if this type is a primitive type.
isArray
public boolean isArray()
- Specified by:
isArray
in interface JavaType
- Returns:
- True if this type is an array type.
getComponentType
public JavaType getComponentType()
- Specified by:
getComponentType
in interface JavaType
- Returns:
- The component type of this array. For example, if this
type is "int[]", this will return the type for "int". If this is
not an array type, this returns null (to match the behavior of
java/lang/Class).
getArrayDimensions
public int getArrayDimensions()
- Specified by:
getArrayDimensions
in interface JavaType
- Returns:
- The array dimensions, zero if this is not an array type.
getBaseComponentType
public JavaType getBaseComponentType()
- Specified by:
getBaseComponentType
in interface JavaType
- Returns:
- The base component type of this array, that is, the type
we get when all array dimensions have been removed. For example,
if this type is "int[][]", this will return the type for "int".
If this is not an array type, this returns null (to match the
behavior of java/lang/Class).
getTypeParameter
public JavaTypeVariable getTypeParameter(java.lang.String name)
- Specified by:
getTypeParameter
in interface JavaIsGeneric
- Returns:
- The matching type parameter. Null means no match.
getUnqualifiedName
public java.lang.String getUnqualifiedName()
- Description copied from interface:
JavaType
- Gets the name of this type in its unqualified form.
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().
- Specified by:
getUnqualifiedName
in interface JavaType
getRawName
public java.lang.String getRawName()
- Description copied from interface:
JavaType
- Gets the raw name of this type. Here, we define the raw name to
be the fully qualified source name of the raw type.
The raw name of a parametrized 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
parametrization 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.
- Specified by:
getRawName
in interface JavaType
- Returns:
- The source name of the raw type. If "the raw type" does
not apply to this type, then the source type is returned.
getSourceName
public java.lang.String getSourceName()
getSignature
public java.lang.String getSignature()
- Description copied from interface:
JavaType
- Gets the "Signature" attribute of this type, as defined by the
JVMS3.
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.
- Specified by:
getSignature
in interface JavaType
- Returns:
- The class signature as defined in the JVMS3. "A signature
is a string representing the generic type of a field or method,
or generic type information for a class declaration." Always
non-null.
printCompiledInfo
public java.lang.String printCompiledInfo()
- Description copied from interface:
JavaElement
- Debugging function for printing out compiled information.
- Specified by:
printCompiledInfo
in interface JavaElement
- Overrides:
printCompiledInfo
in class AbstractElement
getURL
public java.net.URL getURL()
- Description copied from interface:
JavaType
- If the input for this type is a *.class file, the returned URL
will be for the *.class file. If the client wants a *.java URL,
the client should get the source element and then ask it what
it's URL is.
- Specified by:
getURL
in interface JavaType
- Returns:
- The URL for this JavaType. Null if none.
getClosestClass
@Deprecated
public JavaClass getClosestClass()
- Deprecated. Please use
getTypeErasure()
.
- Description copied from interface:
JavaType
- Synonymous with
JavaType.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.
- Specified by:
getClosestClass
in interface JavaType
- Returns:
- The JavaClass most closely approximating the type of this
compiled object.
getThisValue
public CompiledTmpVariable getThisValue()
- Description copied from interface:
JavaType
- 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.
EXPERIMENTAL.
- Specified by:
getThisValue
in interface JavaType
- Returns:
- A value object which has this as its type. May return a
different instance each call.
getPackage
public JavaPackage getPackage()
- Description copied from interface:
JavaType
- Gets the owning package, null if N/A.
- Specified by:
getPackage
in interface JavaType
- Returns:
- The owning compile-model package, null if this is a
primitive or an array type. Type parameters and wildcard types
return the owning package of the enclosing class.
getPackageName
public java.lang.String getPackageName()
- Description copied from interface:
JavaType
- Gets the qualified name of the owning package. Provided for
convenience.
- Specified by:
getPackageName
in interface JavaType
- Returns:
- The qualified name of the owning package. Empty if none.
getSuperclass
public JavaType getSuperclass()
- Description copied from interface:
JavaType
- The name "getSuperclass" was chosen to be consistent with
java/lang/Class.
- Specified by:
getSuperclass
in interface JavaType
- Returns:
- The resolved superclass.
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.
getInterfaces
public java.util.Collection getInterfaces()
- Description copied from interface:
JavaType
- The name "getInterfaces" was chosen to be consistent with
java/lang/Class.
- Specified by:
getInterfaces
in interface JavaType
- Returns:
- The array of resolved super-interfaces. May be
zero-length. Will include all implicit base interfaces, e.g. all
array types implement java/lang/Cloneable. Returns a collection
of JavaType's.
getUnresolvedInterfaces
public java.util.Collection<UnresolvedType> getUnresolvedInterfaces()
- Description copied from interface:
JavaType
- When reverse engineering byecode, some types cannot be resolved
if the correct owning project is not associated to the JavaProvider.
This method returns the set of interfaces this type implements
in the form of UnresolvedType's.
- Specified by:
getUnresolvedInterfaces
in interface JavaType
- Returns:
- The collection of UnresolvedType's.
getHierarchy
public java.util.Set getHierarchy()
- Description copied from interface:
JavaType
- Recursively gets the full list of all resolved superclasses and
super-interfaces. Order is depth-first, classes before
interfaces, left-to-right.
The full list of base classes and base interfaces does not have
duplicates.
Here, the definition of "hierarchy" is the set of types that this
type inherits members from. That is, "hierarchy" is defined by
the "inherits from" relationship rather than from the "is a
subtype of" relationship.
- Specified by:
getHierarchy
in interface JavaType
- Returns:
- The array of ALL base classes and base interfaces (including
java.lang.Object). Returns a collection of JavaType's.
isAssignableFrom
public boolean isAssignableFrom(JavaType subject)
- Description copied from interface:
JavaType
- Consider the following expression where S (subject) represents
another type and T (this) represents this type.
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: At the current writing, isAssignableFrom does not perform
auto-boxing.
- Specified by:
isAssignableFrom
in interface JavaType
- Returns:
- True if the above assignment is allowed. False if the
answer is not known or if the answer is no (i.e. a compile error
would be generated).
isSubtypeOf
public boolean isSubtypeOf(JavaType supertype)
- Description copied from interface:
JavaType
- True if this is a subtype of the indicated argument. Defined by
JLS 4.10.
- Specified by:
isSubtypeOf
in interface JavaType
getDeclaredFields
public java.util.Collection getDeclaredFields()
- Specified by:
getDeclaredFields
in interface JavaType
- Returns:
- The array of all compile-model fields, synthetic or not,
including enum constants. Returns a collection of JavaField's.
getDeclaredField
public JavaField getDeclaredField(java.lang.String name)
- Specified by:
getDeclaredField
in interface JavaType
- Parameters:
name
- Require non-null.
- Returns:
- The first matching compile-model declared field. Null if none.
getDeclaredMethods
public java.util.Collection getDeclaredMethods()
- Specified by:
getDeclaredMethods
in interface JavaType
- Returns:
- The array of all compile-model methods that are not
constructors. (What about the synthetic method? Returns
a collection of JavaMethod's.
getDeclaredMethods
public java.util.Collection getDeclaredMethods(java.lang.String name)
- Specified by:
getDeclaredMethods
in interface JavaType
- Returns:
- TThe array of matching compile-model declared methods.
getDeclaredMethod
public JavaMethod getDeclaredMethod(java.lang.String name,
JavaType[] targetTypes)
- Specified by:
getDeclaredMethod
in interface JavaType
targetTypes
- Null indicates an empty parameter list.
- Returns:
- The first matching compile-model declared method. Null
if none.
getDeclaredConstructors
public java.util.Collection getDeclaredConstructors()
- Specified by:
getDeclaredConstructors
in interface JavaType
- Returns:
- The array of all compiled-model constructors, synthetic
or not. Returns a collection of JavaMethod's.
getDeclaredConstructor
public JavaMethod getDeclaredConstructor(JavaType[] targetTypes)
- Specified by:
getDeclaredConstructor
in interface JavaType
- Parameters:
targetTypes
- Null indicates an empty parameter list.
- Returns:
- The first matching compile-model declared constructor.
Null if none.
getClinitMethod
public JavaMethod getClinitMethod()
- Specified by:
getClinitMethod
in interface JavaType
- Returns:
- The method belonging to this JavaType. Null if none.
getDeclaredClasses
public java.util.Collection getDeclaredClasses()
- Description copied from interface:
JavaType
- In order to get all inner classes, clients must recurse through
direct inner classes.
- Specified by:
getDeclaredClasses
in interface JavaType
- Returns:
- The array of all direct compile-model inner classes,
including local and anonymous classes, synthetic or not. Note
that inner classes, including local and anonymous classes, are
direct inner classes of the most enclosing class. Hence, inner
classes declared within an inner class of the current class are
not direct inner classes of the current class. Returns a
collection of JavaClass's.
getDeclaredClass
public JavaClass getDeclaredClass(java.lang.String name)
- Specified by:
getDeclaredClass
in interface JavaType
- Returns:
- The matching compile-model declared member class. Null if
none.
getFields
public java.util.Collection getFields()
- Description copied from interface:
JavaType
- Iteratively retrieves all fields declared in this class and its
hierarchy. The hierarchy dictates search order. This list, unlike
reflection, includes: private fields, package-private fields, and
hidden fields.
The implicit length field for array types is not reflected by
this method.
- Specified by:
getFields
in interface JavaType
- Returns:
- A collection of JavaField's.
getField
public JavaField getField(java.lang.String name)
- Description copied from interface:
JavaType
- Iteratively searches for a field declared in this class or its
hierarchy. The hierarchy dictates search order.
The implicit length field for array types is not reflected by
this method.
- Specified by:
getField
in interface JavaType
- Parameters:
name
- Require non-null.
- Returns:
- The first matching field. Null if none.
getMethods
public java.util.Collection getMethods()
- Description copied from interface:
JavaType
- Iteratively retrieves all methods declared in this class or its
hierarchy. The hierarchy dictates search order. This list, unlike
reflection, includes: private methods and package-private methods.
This list does not include constructors
- Specified by:
getMethods
in interface JavaType
- Returns:
- A collection of JavaMethod's.
getMethods
public java.util.Collection getMethods(java.lang.String name)
- Description copied from interface:
JavaType
- Iteratively retrieves all methods declared in this class or its
hierarchy. The hierarchy dictates search order.
- Specified by:
getMethods
in interface JavaType
- Parameters:
name
- Require non-null.
- Returns:
- A collection of JavaMethod's with the matching name.
getMethod
public JavaMethod getMethod(java.lang.String name,
JavaType[] targetTypes)
- Description copied from interface:
JavaType
- Iteratively searches for a method declared in this class or its
hierarchy. The hierarchy dictates search order.
- Specified by:
getMethod
in interface JavaType
- Parameters:
name
- Require non-null.targetTypes
- Null indicates an empty parameter list.
- Returns:
- The first matching method. Null if none.
getClasses
public java.util.Collection getClasses()
- Description copied from interface:
JavaType
- Iteratively retrieves all member classes declared in this class
or its hierarchy. The hierarchy dictates search order. This list,
unlike reflection, includes: private member classes and
package-private member classes.
- Specified by:
getClasses
in interface JavaType
- Returns:
- A collection of JavaClass's.
getClass
public JavaClass getClass(java.lang.String name)
- Description copied from interface:
JavaType
- Iteratively retrieves all member classes declared in this class
or its hierarchy. The hierarchy dictates search order.
Note: Be careful not to get this confused with
JavaProvider.getClass( String ).
- Specified by:
getClass
in interface JavaType
- Returns:
- The first matching member class. Null if none.
getAnnotations
public java.util.Collection getAnnotations()
- Description copied from interface:
JavaHasAnnotations
- Retrieves all the annotations declared on this element. If this
element is a class, then this will also iteratively retrieve all
annotations declared on this class's hierarchy.
- Specified by:
getAnnotations
in interface JavaHasAnnotations
- Overrides:
getAnnotations
in class AbstractElement
- Returns:
- The collection
getAnnotation
public JavaAnnotation getAnnotation(JavaType annotationType)
- Description copied from interface:
JavaHasAnnotations
- Retrieves the annotation declared on this element that matches
the input annotation type. If this element is a class, then this
will also iteratively search for an annotation of the matching
annotation type on this class's hierarchy.
- Specified by:
getAnnotation
in interface JavaHasAnnotations
- Overrides:
getAnnotation
in class AbstractElement
- Returns:
- The matching annotation declared on this element or its
hierarchy (if this is a class). Null if none.
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interface JavaType
- Overrides:
equals
in class java.lang.Object
- Returns:
- True if o is a JavaType and has the same signature as
this class.
hashCode
public int hashCode()
- Overrides:
hashCode
in class java.lang.Object
clearCompiledInfo
public void clearCompiledInfo()
- Description copied from class:
AbstractElement
- Overrides should chain.
- Overrides:
clearCompiledInfo
in class AbstractElement
Copyright © 1997, 2013, Oracle. All rights reserved.