Package org.codehaus.janino
Class IClass
java.lang.Object
org.codehaus.janino.IClass
- Direct Known Subclasses:
ClassFileIClass
A simplified equivalent to "java.lang.reflect".
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassclassBase class forIClass.IConstructorandIClass.IMethodstatic interfaceclass -
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 ObjectSpecial return value forIClass.IField.getConstantValue()indicating that the field does not have a constant value.static final IClassTheIClassobject for the primitive type SHORT.static final IClassTheIClassobject for the type VOID. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfinal IClass.IMethodfindIMethod(String methodName, IClass[] parameterTypes) abstract AccessgetArrayIClass(int n, IClass objectType) Get anIClassthat represents an n-dimensional array of this type.getArrayIClass(IClass objectType) Get anIClassthat represents an array of this type.final IClassReturns the component type of the array.
Returns "null" for classes, interfaces, primitive types and "void".protected abstract IClassfinal IClass[]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[]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).
Returns an empty array for an array, primitive type or "void".final IClass.IMethod[]getDeclaredIMethods(String methodName) 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.protected abstract IClass.IMethod[]The uncached version ofgetDeclaredIMethods()which must be implemented by derived classes.final IClassIf this class is a member class, return the declaring class, otherwise returnnull.protected 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.IMethod[]Returns all methods declared in the class or interface, its superclasses and its superinterfaces.final IClass[]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[]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.
Returns "null" for class "Object", interfaces, arrays, primitive types and "void".protected abstract IClassReturns the synthetic fields of an anonymous or local class, in the order in which they are passed to all constructors.final booleanhasIMethod(String methodName, IClass[] parameterTypes) booleanimplementsInterface(IClass that) Ifthisrepresents a class: Returntrueif this class directly or indirectly implementsthatinterface.voidabstract booleanWhether the class may be instantiated (JVMS 4.1 access_flags)abstract booleanisArray()Returns "true" if this type represents an array.booleanisAssignableFrom(IClass that) Determine if "this" is assignable from "that".abstract booleanisFinal()Whether subclassing is allowed (JVMS 4.1 access_flags)abstract booleanReturns "true" if this type represents an interface.abstract booleanReturns "true" if this type represents a primitive type or "void".abstract booleanReturns "true" if this type represents "byte", "short", "int", "long", "char", "float" or "double".booleanisSubclassOf(IClass that) Returnstrueif this class is an immediate or non-immediate subclass ofthatclass.toString()
-
Field Details
-
NOT_CONSTANT
Special return value forIClass.IField.getConstantValue()indicating that the field does not have a constant value. -
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.
-
-
Constructor Details
-
IClass
public IClass()
-
-
Method Details
-
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).
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
IClassdoes declare anIClass.IMethodwith the given name and parameter types - Throws:
CompileException
-
findIMethod
public final IClass.IMethod findIMethod(String methodName, IClass[] parameterTypes) throws CompileException - Returns:
- The
IClass.IMethoddeclared in thisIClasswith the given name and parameter types - 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() -
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
- Throws:
CompileException
-
getDeclaringIClass
If this class is a member class, return the declaring class, otherwise returnnull.- Throws:
CompileException
-
getDeclaringIClass2
- 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
- Throws:
CompileException
-
getOuterIClass2
- Throws:
CompileException
-
getSuperclass
Returns the superclass of the class.
Returns "null" for class "Object", interfaces, arrays, primitive types and "void".- Throws:
CompileException
-
getSuperclass2
- Throws:
CompileException
-
getAccess
-
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.
Returns the superinterfaces of the interface.
Returns "Cloneable" and "Serializable" for arrays.
Returns an empty array for primitive types and "void".- Throws:
CompileException
-
getInterfaces2
- Throws:
CompileException
-
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. -
getDescriptor2
-
getDescriptors
Convenience method that determines the field descriptors of an array ofIClasses.- See Also:
-
isInterface
public abstract boolean isInterface()Returns "true" if this type represents an interface. -
isArray
public abstract boolean isArray()Returns "true" if this type represents an array. -
isPrimitive
public abstract boolean isPrimitive()Returns "true" if this type represents a primitive type or "void". -
isPrimitiveNumeric
public abstract boolean isPrimitiveNumeric()Returns "true" if this type represents "byte", "short", "int", "long", "char", "float" or "double". -
getComponentType
Returns the component type of the array.
Returns "null" for classes, interfaces, primitive types and "void". -
getComponentType2
-
toString
-
isAssignableFrom
Determine if "this" is assignable from "that". This is true if "this" is identical with "that" (JLS2 5.1.1), or if "that" is widening-primitive-convertible to "this" (JLS2 5.1.2), or if "that" is widening-reference-convertible to "this" (JLS2 5.1.4).- 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
-
getArrayIClass
Get anIClassthat represents an n-dimensional array of this type.- Parameters:
n- dimension countobjectType- Required because the superclass of an array class isObjectby definition
-
getArrayIClass
Get anIClassthat represents an array of this type.- Parameters:
objectType- Required because the superclass of an array class isObjectby definition
-
invalidateMethodCaches
public void invalidateMethodCaches()
-