Package org.codehaus.janino
Class IClass
java.lang.Object
org.codehaus.janino.IClass
- All Implemented Interfaces:
IType,ITypeVariableOrIClass
- Direct Known Subclasses:
ClassFileIClass
A simplified equivalent to "java.lang.reflect".
'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. -
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.static final IClassTheIClassobject for the primitive type DOUBLE.static final IClassTheIClassobject for the primitive type FLOAT.static final IClassTheIClassobject for the primitive type INT.static final IClassTheIClassobject for the primitive type LONG.static final IClass.IAnnotation[]Array of zeroIClass.IAnnotations.static final ObjectSpecial return value forIClass.IField.getConstantValue()indicating that the field does not have a constant value.static final IClassTheIClassof thenullliteral.static final IClassTheIClassobject for the primitive type SHORT.static final IClassTheIClassobject for the type VOID. -
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) 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().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.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
-
NOT_CONSTANT
Special return value forIClass.IField.getConstantValue()indicating that the field does not have a constant value. -
NULL
TheIClassof thenullliteral. -
VOID
TheIClassobject for the type VOID. -
BYTE
TheIClassobject for the primitive type BYTE. -
CHAR
TheIClassobject for the primitive type CHAR. -
DOUBLE
TheIClassobject for the primitive type DOUBLE. -
FLOAT
TheIClassobject for the primitive type FLOAT. -
INT
TheIClassobject for the primitive type INT. -
LONG
TheIClassobject for the primitive type LONG. -
SHORT
TheIClassobject for the primitive type SHORT. -
BOOLEAN
TheIClassobject for the primitive type BOOLEAN. -
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
-
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
-
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
Convenience method that determines the field descriptors of an array ofIClasses.- See Also:
-
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
- Returns:
- The component type of the array, or
nullfor classes, interfaces, primitive types andvoid
-
getComponentType2
- See Also:
-
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
-
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
-