public abstract class IClass
extends java.lang.Object
'JLS7' means a reference to the Java Language Specification, Java SE 7 Edition
Modifier and Type | Class and Description |
---|---|
class |
IClass.IConstructor
Representation of a constructor of an
IClass . |
class |
IClass.IField
Representation of a field of this
IClass . |
class |
IClass.IInvocable
Base class for
IClass.IConstructor and IClass.IMethod . |
static interface |
IClass.IMember
Base for the members of an
IClass . |
class |
IClass.IMethod
Representation of a method in an
IClass . |
private static class |
IClass.PrimitiveIClass |
Modifier and Type | Field and Description |
---|---|
private IClass |
arrayIClass |
static IClass |
BOOLEAN
The
IClass object for the primitive type BOOLEAN. |
static IClass |
BYTE
The
IClass object for the primitive type BYTE. |
static IClass |
CHAR
The
IClass object for the primitive type CHAR. |
private IClass |
componentTypeCache |
private boolean |
componentTypeIsCached |
private static boolean |
DEBUG |
private IClass[] |
declaredIClassesCache |
private IClass.IConstructor[] |
declaredIConstructorsCache |
private java.util.Map<java.lang.String,IClass.IField> |
declaredIFieldsCache |
private java.util.Map<java.lang.String,java.lang.Object> |
declaredIMethodCache |
private IClass.IMethod[] |
declaredIMethodsCache |
private IClass |
declaringIClassCache |
private boolean |
declaringIClassIsCached |
private java.lang.String |
descriptorCache |
static IClass |
DOUBLE
The
IClass object for the primitive type DOUBLE. |
static IClass |
FLOAT
The
IClass object for the primitive type FLOAT. |
private IClass.IMethod[] |
iMethodCache |
static IClass |
INT
The
IClass object for the primitive type INT. |
private IClass[] |
interfacesCache |
static IClass |
LONG
The
IClass object for the primitive type LONG. |
private java.util.Map<java.lang.String,IClass[]> |
memberTypeCache |
private static IClass.IMethod[] |
NO_IMETHODS |
static java.lang.Object |
NOT_CONSTANT
Special return value for
IClass.IField.getConstantValue() indicating that the field does not have a
constant value. |
private IClass |
outerIClassCache |
private boolean |
outerIClassIsCached |
private static java.util.Set<java.lang.String> |
PRIMITIVE_WIDENING_CONVERSIONS |
static IClass |
SHORT
The
IClass object for the primitive type SHORT. |
private IClass |
superclassCache |
private boolean |
superclassIsCached |
static IClass |
VOID
The
IClass object for the type VOID. |
private static IClass[] |
ZERO_ICLASSES |
Constructor and Description |
---|
IClass() |
Modifier and Type | Method and Description |
---|---|
protected void |
clearIFieldCaches()
Clears the cache of declared fields which this class maintains in order to minimize the invocations of
getDeclaredIFields2() . |
IClass.IConstructor |
findIConstructor(IClass[] parameterTypes) |
IClass.IMethod |
findIMethod(java.lang.String methodName,
IClass[] parameterTypes) |
(package private) IClass[] |
findMemberType(java.lang.String optionalName)
|
private void |
findMemberType(java.lang.String optionalName,
java.util.Collection<IClass> result) |
abstract Access |
getAccess() |
IClass |
getArrayIClass(IClass objectType)
Get an
IClass that represents an array of this type. |
IClass |
getArrayIClass(int n,
IClass objectType)
Get an
IClass that represents an n-dimensional array of this type. |
private IClass |
getArrayIClass2(IClass objectType) |
IClass |
getComponentType() |
protected abstract IClass |
getComponentType2() |
IClass[] |
getDeclaredIClasses()
Returns the classes and interfaces declared as members of the class
(but not inherited classes and interfaces).
Returns an empty array for an array, primitive type or "void". |
protected abstract IClass[] |
getDeclaredIClasses2() |
IClass.IConstructor[] |
getDeclaredIConstructors()
Returns all the constructors declared by the class represented by the
type.
|
protected abstract IClass.IConstructor[] |
getDeclaredIConstructors2()
The uncached version of
getDeclaredIConstructors() which must be implemented by derived classes. |
IClass.IField |
getDeclaredIField(java.lang.String name)
Returns the named
IClass.IField declared in this IClass (does not work for inherited fields). |
IClass.IField[] |
getDeclaredIFields()
Returns the
IClass.IField s declared in this IClass (but not inherited fields). |
protected abstract IClass.IField[] |
getDeclaredIFields2()
Uncached version of
getDeclaredIFields() . |
private java.util.Map<java.lang.String,IClass.IField> |
getDeclaredIFieldsCache() |
IClass.IMethod[] |
getDeclaredIMethods()
Returns the methods of the class or interface (but not inherited methods).
|
IClass.IMethod[] |
getDeclaredIMethods(java.lang.String methodName)
Returns all methods with the given name declared in the class or interface (but not inherited methods).
|
protected abstract IClass.IMethod[] |
getDeclaredIMethods2()
The uncached version of
getDeclaredIMethods() which must be implemented by derived classes. |
IClass |
getDeclaringIClass() |
protected abstract IClass |
getDeclaringIClass2() |
java.lang.String |
getDescriptor()
Returns the field descriptor for the type as defined by JVMS 4.3.2.
|
protected abstract java.lang.String |
getDescriptor2() |
static java.lang.String[] |
getDescriptors(IClass[] iClasses)
Convenience method that determines the field descriptors of an array of
IClass es. |
IClass.IMethod[] |
getIMethods()
Returns all methods declared in the class or interface, its superclasses and its
superinterfaces.
|
private void |
getIMethods(java.util.List<IClass.IMethod> result) |
IClass[] |
getInterfaces()
Returns the interfaces implemented by the class.
Returns the superinterfaces of the interface. Returns "Cloneable" and "Serializable" for arrays. Returns an empty array for primitive types and "void". |
protected abstract IClass[] |
getInterfaces2() |
IClass |
getOuterIClass()
The following types have an "outer class":
Anonymous classes declared in a non-static method of a class
Local classes declared in a non-static method of a class
Non-static member classes
|
protected abstract IClass |
getOuterIClass2() |
IClass |
getSuperclass()
Returns the superclass of the class.
Returns "null" for class "Object", interfaces, arrays, primitive types and "void". |
protected abstract IClass |
getSuperclass2() |
IClass.IField[] |
getSyntheticIFields()
Returns the synthetic fields of an anonymous or local class, in
the order in which they are passed to all constructors.
|
boolean |
hasIMethod(java.lang.String methodName,
IClass[] parameterTypes) |
boolean |
implementsInterface(IClass that)
If
this represents a class: Return true if this class
directly or indirectly implements that interface. |
void |
invalidateMethodCaches()
This class caches the declared methods in order to minimize the invocations of
getDeclaredIMethods2() . |
abstract boolean |
isAbstract()
Whether the class may be instantiated (JVMS 4.1 access_flags)
|
abstract boolean |
isArray() |
boolean |
isAssignableFrom(IClass that)
Determine if "this" is assignable from "that".
|
abstract boolean |
isFinal()
Whether subclassing is allowed (JVMS 4.1 access_flags)
|
abstract boolean |
isInterface() |
abstract boolean |
isPrimitive() |
abstract boolean |
isPrimitiveNumeric() |
boolean |
isSubclassOf(IClass that)
Returns
true if this class is an immediate or non-immediate
subclass of that class. |
java.lang.String |
toString() |
private static final boolean DEBUG
public static final java.lang.Object NOT_CONSTANT
IClass.IField.getConstantValue()
indicating that the field does not have a
constant value.private IClass.IConstructor[] declaredIConstructorsCache
private IClass.IMethod[] declaredIMethodsCache
private java.util.Map<java.lang.String,java.lang.Object> declaredIMethodCache
private IClass.IMethod[] iMethodCache
private static final IClass.IMethod[] NO_IMETHODS
private java.util.Map<java.lang.String,IClass.IField> declaredIFieldsCache
private IClass[] declaredIClassesCache
private boolean declaringIClassIsCached
private IClass declaringIClassCache
private boolean outerIClassIsCached
private IClass outerIClassCache
private boolean superclassIsCached
private IClass superclassCache
private IClass[] interfacesCache
private java.lang.String descriptorCache
private boolean componentTypeIsCached
private IClass componentTypeCache
private static final java.util.Set<java.lang.String> PRIMITIVE_WIDENING_CONVERSIONS
private IClass arrayIClass
private final java.util.Map<java.lang.String,IClass[]> memberTypeCache
private static final IClass[] ZERO_ICLASSES
public final IClass.IConstructor[] getDeclaredIConstructors()
Returns an array with zero elements for an interface, array, primitive type or "void".
protected abstract IClass.IConstructor[] getDeclaredIConstructors2()
getDeclaredIConstructors()
which must be implemented by derived classes.public final IClass.IMethod[] getDeclaredIMethods()
protected abstract IClass.IMethod[] getDeclaredIMethods2()
getDeclaredIMethods()
which must be implemented by derived classes.public final IClass.IMethod[] getDeclaredIMethods(java.lang.String methodName)
IClass.IMethod
s that must not be modifiedpublic final IClass.IMethod[] getIMethods() throws CompileException
IClass.IMethod
s that must not be modifiedCompileException
private void getIMethods(java.util.List<IClass.IMethod> result) throws CompileException
CompileException
public final boolean hasIMethod(java.lang.String methodName, IClass[] parameterTypes) throws CompileException
IClass
(or its superclass or the interfaces it implements) has an IClass.IMethod
with the given name and parameter typesCompileException
public final IClass.IMethod findIMethod(java.lang.String methodName, IClass[] parameterTypes) throws CompileException
IClass.IMethod
declared in this IClass
(or its superclass or the interfaces it implements)
with the given name and parameter types, or null
if an applicable method could not be foundCompileException
public final IClass.IConstructor findIConstructor(IClass[] parameterTypes) throws CompileException
IClass.IConstructor
declared in this IClass
with the given parameter types, or null
if an applicable constrcutor could not be foundCompileException
public final IClass.IField[] getDeclaredIFields()
IClass.IField
s declared in this IClass
(but not inherited fields).private java.util.Map<java.lang.String,IClass.IField> getDeclaredIFieldsCache()
public final IClass.IField getDeclaredIField(java.lang.String name)
IClass.IField
declared in this IClass
(does not work for inherited fields).null
iff this IClass
does not declare an IClass.IField
with that nameprotected void clearIFieldCaches()
getDeclaredIFields2()
.protected abstract IClass.IField[] getDeclaredIFields2()
getDeclaredIFields()
.public IClass.IField[] getSyntheticIFields()
public final IClass[] getDeclaredIClasses() throws CompileException
CompileException
protected abstract IClass[] getDeclaredIClasses2() throws CompileException
CompileException
public final IClass getDeclaringIClass() throws CompileException
null
CompileException
protected abstract IClass getDeclaringIClass2() throws CompileException
null
CompileException
public final IClass getOuterIClass() throws CompileException
null
CompileException
protected abstract IClass getOuterIClass2() throws CompileException
CompileException
getOuterIClass()
public final IClass getSuperclass() throws CompileException
CompileException
protected abstract IClass getSuperclass2() throws CompileException
CompileException
getSuperclass()
public abstract Access getAccess()
public abstract boolean isFinal()
true
if subclassing is prohibitedpublic final IClass[] getInterfaces() throws CompileException
CompileException
protected abstract IClass[] getInterfaces2() throws CompileException
CompileException
getInterfaces()
public abstract boolean isAbstract()
true
if instantiation is prohibitedpublic final java.lang.String getDescriptor()
protected abstract java.lang.String getDescriptor2()
public static java.lang.String[] getDescriptors(IClass[] iClasses)
IClass
es.getDescriptor()
public abstract boolean isInterface()
public abstract boolean isArray()
public abstract boolean isPrimitive()
public abstract boolean isPrimitiveNumeric()
public final IClass getComponentType()
null
for classes, interfaces, primitive types and void
protected abstract IClass getComponentType2()
getComponentType()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isAssignableFrom(IClass that) throws CompileException
CompileException
public boolean isSubclassOf(IClass that) throws CompileException
true
if this class is an immediate or non-immediate
subclass of that
class.CompileException
public boolean implementsInterface(IClass that) throws CompileException
this
represents a class: Return true
if this class
directly or indirectly implements that
interface.
If this
represents an interface: Return true
if this
interface directly or indirectly extends that
interface.
CompileException
public IClass getArrayIClass(int n, IClass objectType)
IClass
that represents an n-dimensional array of this type.n
- dimension countobjectType
- Required because the superclass of an array class is Object
by definitionpublic IClass getArrayIClass(IClass objectType)
IClass
that represents an array of this type.objectType
- Required because the superclass of an array class is Object
by definitionIClass[] findMemberType(java.lang.String optionalName) throws CompileException
optionalName
is null
, find all IClass
es visible in the
scope of the current class.
If optionalName
is not null
, find the member IClass
es
that has the given name. If the name is ambiguous (i.e. if more than one superclass,
interface of enclosing type declares a type with that name), then the size of the
returned array is greater than one.
Examines superclasses, interfaces and enclosing type declarations.
IClass
es in unspecified order, possibly of length zeroCompileException
private void findMemberType(java.lang.String optionalName, java.util.Collection<IClass> result) throws CompileException
CompileException
public void invalidateMethodCaches()
getDeclaredIMethods2()
.