Class IClass
- All Implemented Interfaces:
IType, ITypeVariableOrIClass
- Direct Known Subclasses:
ClassFileIClass, IClass.PrimitiveIClass, ReflectionIClass
'JLS7' means a reference to the Java Language Specification, Java SE 7 Edition.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresentation of a Java "annotation".classRepresentation of a constructor of anIClass.classRepresentation of a field of thisIClass.classBase class forIClass.IConstructorandIClass.IMethod.static interfaceBase for the members of anIClass.classRepresentation of a method in anIClass.private static class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IClassTheIClassobject for the primitive type BOOLEAN.static final IClassTheIClassobject for the primitive type BYTE.static final IClassTheIClassobject for the primitive type CHAR.private IClassprivate booleanprivate IClass[]private IClass.IConstructor[]private Map<String, IClass.IField> private IClass.IMethod[]private IClassprivate booleanprivate Stringstatic final IClassTheIClassobject for the primitive type DOUBLE.static final IClassTheIClassobject for the primitive type FLOAT.private IClass.IAnnotation[]private IClass.IMethod[]static final IClassTheIClassobject for the primitive type INT.private IClass[]private ITypeVariable[]private static final Loggerstatic final IClassTheIClassobject for the primitive type LONG.static final IClass.IAnnotation[]Array of zeroIClass.IAnnotations.private static final IClass.IMethod[]static final ObjectSpecial return value forIClass.IField.getConstantValue()indicating that the field does not have a constant value.static final IClassTheIClassof thenullliteral.private IClassprivate booleanstatic final IClassTheIClassobject for the primitive type SHORT.private IClassprivate booleanstatic final IClassTheIClassobject for the type VOID.private static final IClass[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidClears the cache of declared fields which this class maintains in order to minimize the invocations ofgetDeclaredIFields2().final IClass.IConstructorfindIConstructor(IClass[] parameterTypes) final IClass.IMethodfindIMethod(String methodName, IClass[] parameterTypes) (package private) IClass[]findMemberType(String name) If name isnull, finds allIClasses visible in the scope of the current class.private voidfindMemberType(String name, Collection<IClass> result) abstract Accessfinal IClassprotected abstract IClassfinal IClass[]Returns the classes and interfaces declared as members of the class (but not inherited classes and interfaces).protected abstract IClass[]final IClass.IConstructor[]Returns all the constructors declared by the class represented by the type.protected abstract IClass.IConstructor[]The uncached version ofgetDeclaredIConstructors()which must be implemented by derived classes.final IClass.IFieldgetDeclaredIField(String name) Returns the namedIClass.IFielddeclared in thisIClass(does not work for inherited fields).final IClass.IField[]Returns theIClass.IFields declared in thisIClass(but not inherited fields).protected abstract IClass.IField[]Uncached version ofgetDeclaredIFields().private Map<String, IClass.IField> final IClass.IMethod[]Returns the methods of the class or interface (but not inherited methods).final IClass.IMethod[]getDeclaredIMethods(String methodName) Returns all methods with the given name declared in the class or interface (but not inherited methods).protected abstract IClass.IMethod[]The uncached version ofgetDeclaredIMethods()which must be implemented by derived classes.final IClassprotected abstract IClassfinal StringReturns the field descriptor for the type as defined by JVMS 4.3.2.protected abstract Stringstatic String[]getDescriptors(IClass[] iClasses) Convenience method that determines the field descriptors of an array ofIClasses.final IClass.IAnnotation[]protected IClass.IAnnotation[]final IClass.IMethod[]Returns all methods declared in the class or interface, its superclasses and its superinterfaces.private voidgetIMethods(List<IClass.IMethod> result) final IClass[]Returns the interfaces implemented by the class, respectively the superinterfaces of the interface, respectively{Cloneable,Serializable}for arrays.protected abstract IClass[]final ITypeVariable[]protected abstract ITypeVariable[]The uncached version ofgetDeclaredIConstructors()which must be implemented by derived classes.final IClassThe 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 classesprotected abstract IClassfinal IClassReturns the superclass of the class.protected abstract IClassfinal booleanhasIMethod(String methodName, IClass[] parameterTypes) booleanimplementsInterface(IClass that) Ifthisrepresents a class: Returntrueif this class directly or indirectly implementsthatinterface.voidThis class caches the declared methods in order to minimize the invocations ofgetDeclaredIMethods2().abstract booleanWhether the class may be instantiated (JVMS 4.1 access_flags).abstract booleanisArray()booleanisAssignableFrom(IClass that) Determines ifthisis assignable from that.abstract booleanisEnum()abstract booleanisFinal()Whether subclassing is allowed (JVMS 4.1 access_flags)abstract booleanabstract booleanabstract booleanbooleanisSubclassOf(IClass that) Returnstrueif this class is an immediate or non-immediate subclass ofthatclass.static IClasstoString()
-
Field Details
-
LOGGER
-
NOT_CONSTANT
Special return value forIClass.IField.getConstantValue()indicating that the field does not have a constant value. -
NULL
-
VOID
-
BYTE
-
CHAR
-
DOUBLE
-
FLOAT
-
INT
-
LONG
-
SHORT
-
BOOLEAN
-
iTypeVariablesCache
-
declaredIConstructorsCache
-
declaredIMethodsCache
-
declaredIMethodCache
-
iMethodCache
-
NO_IMETHODS
-
declaredIFieldsCache
-
declaredIClassesCache
-
declaringIClassIsCached
private boolean declaringIClassIsCached -
declaringIClassCache
-
outerIClassIsCached
private boolean outerIClassIsCached -
outerIClassCache
-
superclassIsCached
private boolean superclassIsCached -
superclassCache
-
interfacesCache
-
descriptorCache
-
componentTypeIsCached
private boolean componentTypeIsCached -
componentTypeCache
-
PRIMITIVE_WIDENING_CONVERSIONS
-
memberTypeCache
-
ZERO_ICLASSES
-
iAnnotationsCache
-
NO_ANNOTATIONS
Array of zeroIClass.IAnnotations.
-
-
Constructor Details
-
IClass
public IClass()
-
-
Method Details
-
getITypeVariables
- Returns:
- Zero-length array if this
IClassdeclares no type variables - Throws:
CompileException
-
getITypeVariables2
The uncached version ofgetDeclaredIConstructors()which must be implemented by derived classes.- Throws:
CompileException
-
getDeclaredIConstructors
Returns all the constructors declared by the class represented by the type. If the class has a default constructor, it is included.Returns an array with zero elements for an interface, array, primitive type or
void. -
getDeclaredIConstructors2
The uncached version ofgetDeclaredIConstructors()which must be implemented by derived classes. -
getDeclaredIMethods
Returns the methods of the class or interface (but not inherited methods). For covariant methods, only the method with the most derived return type is included.Returns an empty array for an array, primitive type or
void. -
getDeclaredIMethods2
The uncached version ofgetDeclaredIMethods()which must be implemented by derived classes. -
getDeclaredIMethods
Returns all methods with the given name declared in the class or interface (but not inherited methods).Returns an empty array if no methods with that name are declared.
- Returns:
- an array of
IClass.IMethods that must not be modified
-
getIMethods
Returns all methods declared in the class or interface, its superclasses and its superinterfaces.- Returns:
- an array of
IClass.IMethods that must not be modified - Throws:
CompileException
-
getIMethods
- Throws:
CompileException
-
hasIMethod
- Returns:
- Whether this
IClass(or its superclass or the interfaces it implements) has anIClass.IMethodwith the given name and parameter types - Throws:
CompileException
-
findIMethod
@Nullable public final IClass.IMethod findIMethod(String methodName, IClass[] parameterTypes) throws CompileException - Returns:
- The
IClass.IMethoddeclared in thisIClass(or its superclass or the interfaces it implements) with the given name and parameter types, ornullif an applicable method could not be found - Throws:
CompileException
-
findIConstructor
@Nullable public final IClass.IConstructor findIConstructor(IClass[] parameterTypes) throws CompileException - Returns:
- The
IClass.IConstructordeclared in thisIClasswith the given parameter types, ornullif an applicable constructor could not be found - Throws:
CompileException
-
getDeclaredIFields
Returns theIClass.IFields declared in thisIClass(but not inherited fields).- Returns:
- An empty array for an array, primitive type or
void
-
getDeclaredIFieldsCache
- Returns:
String fieldName => IField
-
getDeclaredIField
Returns the namedIClass.IFielddeclared in thisIClass(does not work for inherited fields).- Returns:
nulliff thisIClassdoes not declare anIClass.IFieldwith that name
-
clearIFieldCaches
protected void clearIFieldCaches()Clears the cache of declared fields which this class maintains in order to minimize the invocations ofgetDeclaredIFields2(). -
getDeclaredIFields2
Uncached version ofgetDeclaredIFields(). -
getSyntheticIFields
- Returns:
- The synthetic fields of an anonymous or local class, in the order in which they are passed to all constructors
-
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.- Throws:
CompileException
-
getDeclaredIClasses2
- Returns:
- The member types of this type
- Throws:
CompileException
-
getDeclaringIClass
- Returns:
- If this class is a member class, the declaring class, otherwise
null - Throws:
CompileException
-
getDeclaringIClass2
- Returns:
- If this class is a member class, the declaring class, otherwise
null - Throws:
CompileException
-
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
- Returns:
- The outer class of this type, or
null - Throws:
CompileException
-
getOuterIClass2
- Throws:
CompileException- See Also:
-
getSuperclass
Returns the superclass of the class.Returns
nullfor classObject, interfaces, arrays, primitive types andvoid.- Throws:
CompileException
-
getSuperclass2
- Throws:
CompileException- See Also:
-
getAccess
- Returns:
- The accessibility of this type
-
isFinal
public abstract boolean isFinal()Whether subclassing is allowed (JVMS 4.1 access_flags)- Returns:
trueif subclassing is prohibited
-
getInterfaces
Returns the interfaces implemented by the class, respectively the superinterfaces of the interface, respectively{Cloneable,Serializable}for arrays.Returns an empty array for primitive types and
void.- Throws:
CompileException
-
getInterfaces2
- Throws:
CompileException- See Also:
-
isAbstract
public abstract boolean isAbstract()Whether the class may be instantiated (JVMS 4.1 access_flags).- Returns:
trueif instantiation is prohibited
-
getDescriptor
Returns the field descriptor for the type as defined by JVMS 4.3.2. This method is fast. -
getDescriptor2
- Returns:
- The field descriptor for the type as defined by JVMS 4.3.2.
-
getDescriptors
-
isEnum
public abstract boolean isEnum()- Returns:
- Whether this type represents an enum
-
isInterface
public abstract boolean isInterface()- Returns:
- Whether this type represents an interface
-
isArray
public abstract boolean isArray()- Returns:
- Whether this type represents an array
-
isPrimitive
public abstract boolean isPrimitive()- Returns:
- Whether this type represents a primitive type or
void
-
isPrimitiveNumeric
public abstract boolean isPrimitiveNumeric()- Returns:
- Whether this type represents
byte,short,int,long,char,floatordouble
-
getComponentType
-
getComponentType2
-
toString
-
isAssignableFrom
Determines ifthisis assignable from that. This is true ifthisis identical with that (JLS7 5.1.1), or if that is widening-primitive-convertible tothis(JLS7 5.1.2), or if that is widening-reference-convertible tothis(JLS7 5.1.5).- Throws:
CompileException
-
isSubclassOf
Returnstrueif this class is an immediate or non-immediate subclass ofthatclass.- Throws:
CompileException
-
implementsInterface
Ifthisrepresents a class: Returntrueif this class directly or indirectly implementsthatinterface.If
thisrepresents an interface: Returntrueif this interface directly or indirectly extendsthatinterface.- Throws:
CompileException
-
findMemberType
If name isnull, finds allIClasses visible in the scope of the current class.If name is not
null, finds the memberIClasses 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.
- Returns:
- an array of
IClasses in unspecified order, possibly of length zero - Throws:
CompileException
-
findMemberType
private void findMemberType(@Nullable String name, Collection<IClass> result) throws CompileException - Throws:
CompileException
-
getIAnnotations
- Returns:
- The annotations of this type (possibly the empty array)
- Throws:
CompileException
-
getIAnnotations2
- Throws:
CompileException
-
invalidateMethodCaches
public void invalidateMethodCaches()This class caches the declared methods in order to minimize the invocations ofgetDeclaredIMethods2(). -
rawTypeOf
-