org.codehaus.janino

Class IClass

public abstract class IClass extends Object

A simplified equivalent to "java.lang.reflect".
Nested Class Summary
abstract classIClass.IConstructor
abstract classIClass.IField
abstract classIClass.IInvocable
interfaceIClass.IMember
abstract classIClass.IMethod
Field Summary
static IClassBOOLEAN
static IClassBYTE
static IClassCHAR
protected IClass.IMethod[]declaredIMethods
static IClassDOUBLE
static IClassFLOAT
static IClassINT
static IClassLONG
static IClass.IMethod[]NO_IMETHODS
static IClassSHORT
static IClassVOID
Method Summary
protected voidclearIFieldCaches()
abstract AccessgetAccess()
IClassgetArrayIClass(int n, IClass objectType)
Get an IClass that represents an n-dimensional array of this type.
IClassgetArrayIClass(IClass objectType)
Get an IClass that represents an array of this type.
IClassgetComponentType()
Returns the component type of the array.
Returns "null" for classes, interfaces, primitive types and "void".
protected abstract IClassgetComponentType2()
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()
IClass.IFieldgetDeclaredIField(String name)
IClass.IField[]getDeclaredIFields()
Returns the fields of a class or interface (but not inherited fields).
Returns an empty array for an array, primitive type or "void".
protected abstract IClass.IField[]getDeclaredIFields2()
IClass.IMethod[]getDeclaredIMethods()
Returns the methods of the class or interface (but not inherited methods).
Returns an empty array for an array, primitive type or "void".
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[]getDeclaredIMethods2()
IClassgetDeclaringIClass()
If this class is a member class, return the declaring class, otherwise return null.
protected abstract IClassgetDeclaringIClass2()
StringgetDescriptor()
Returns the field descriptor for the type as defined by JVMS 4.3.2.
protected abstract StringgetDescriptor2()
static String[]getDescriptors(IClass[] iClasses)
Convenience method that determines the field descriptors of an array of IClasses.
IClass.IMethod[]getIMethods()
Returns all methods declared in the class or interface, its superclasses and its superinterfaces.
For overridden methods, only the last non-abstract implementation is returned.
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()
IClassgetOuterIClass()
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 IClassgetOuterIClass2()
IClassgetSuperclass()
Returns the superclass of the class.
Returns "null" for class "Object", interfaces, arrays, primitive types and "void".
protected abstract IClassgetSuperclass2()
IClass.IField[]getSyntheticIFields()
Returns the synthetic fields of an anonymous or local class, in the order in which they are passed to all constructors.
booleanhasIMethod(String methodName, IClass[] parameterTypes)
booleanimplementsInterface(IClass that)
If this represents a class: Return true if this class directly or indirectly implements that interface.
abstract booleanisAbstract()
Whether 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 booleanisInterface()
Returns "true" if this type represents an interface.
abstract booleanisPrimitive()
Returns "true" if this type represents a primitive type or "void".
abstract booleanisPrimitiveNumeric()
Returns "true" if this type represents "byte", "short", "int", "long", "char", "float" or "double".
booleanisSubclassOf(IClass that)
Returns true if this class is an immediate or non-immediate subclass of that class.
StringtoString()
Returns a string representation for this object.

Field Detail

BOOLEAN

public static final IClass BOOLEAN

BYTE

public static final IClass BYTE

CHAR

public static final IClass CHAR

declaredIMethods

protected IClass.IMethod[] declaredIMethods

DOUBLE

public static final IClass DOUBLE

FLOAT

public static final IClass FLOAT

INT

public static final IClass INT

LONG

public static final IClass LONG

NO_IMETHODS

public static final IClass.IMethod[] NO_IMETHODS

SHORT

public static final IClass SHORT

VOID

public static final IClass VOID

Method Detail

clearIFieldCaches

protected void clearIFieldCaches()

getAccess

public abstract Access getAccess()

getArrayIClass

public IClass getArrayIClass(int n, IClass objectType)
Get an IClass that represents an n-dimensional array of this type.

Parameters: n dimension count objectType Required because the superclass of an array class is Object by definition

getArrayIClass

public IClass getArrayIClass(IClass objectType)
Get an IClass that represents an array of this type.

Parameters: objectType Required because the superclass of an array class is Object by definition

getComponentType

public final IClass getComponentType()
Returns the component type of the array.
Returns "null" for classes, interfaces, primitive types and "void".

getComponentType2

protected abstract IClass getComponentType2()

getDeclaredIClasses

public final 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".

getDeclaredIClasses2

protected abstract IClass[] getDeclaredIClasses2()

getDeclaredIConstructors

public final IClass.IConstructor[] 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

protected abstract IClass.IConstructor[] getDeclaredIConstructors2()

getDeclaredIField

public final IClass.IField getDeclaredIField(String name)

getDeclaredIFields

public final IClass.IField[] getDeclaredIFields()
Returns the fields of a class or interface (but not inherited fields).
Returns an empty array for an array, primitive type or "void".

getDeclaredIFields2

protected abstract IClass.IField[] getDeclaredIFields2()

getDeclaredIMethods

public final IClass.IMethod[] getDeclaredIMethods()
Returns the methods of the class or interface (but not inherited methods).
Returns an empty array for an array, primitive type or "void".

getDeclaredIMethods

public 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.

Returns: an array of IMethods that must not be modified

getDeclaredIMethods2

protected abstract IClass.IMethod[] getDeclaredIMethods2()

getDeclaringIClass

public final IClass getDeclaringIClass()
If this class is a member class, return the declaring class, otherwise return null.

getDeclaringIClass2

protected abstract IClass getDeclaringIClass2()

getDescriptor

public final String getDescriptor()
Returns the field descriptor for the type as defined by JVMS 4.3.2.

getDescriptor2

protected abstract String getDescriptor2()

getDescriptors

public static String[] getDescriptors(IClass[] iClasses)
Convenience method that determines the field descriptors of an array of IClasses.

See Also: getDescriptor

getIMethods

public final IClass.IMethod[] getIMethods()
Returns all methods declared in the class or interface, its superclasses and its superinterfaces.
For overridden methods, only the last non-abstract implementation is returned.

Returns: an array of IMethods that must not be modified

getInterfaces

public final 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".

getInterfaces2

protected abstract IClass[] getInterfaces2()

getOuterIClass

public final IClass getOuterIClass()
The following types have an "outer class":

getOuterIClass2

protected abstract IClass getOuterIClass2()

getSuperclass

public final IClass getSuperclass()
Returns the superclass of the class.
Returns "null" for class "Object", interfaces, arrays, primitive types and "void".

getSuperclass2

protected abstract IClass getSuperclass2()

getSyntheticIFields

public IClass.IField[] getSyntheticIFields()
Returns the synthetic fields of an anonymous or local class, in the order in which they are passed to all constructors.

hasIMethod

public final boolean hasIMethod(String methodName, IClass[] parameterTypes)

implementsInterface

public boolean implementsInterface(IClass that)
If 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.

isAbstract

public abstract boolean isAbstract()
Whether the class may be instantiated (JVMS 4.1 access_flags)

Returns: true if instantiation is prohibited

isArray

public abstract boolean isArray()
Returns "true" if this type represents an array.

isAssignableFrom

public boolean isAssignableFrom(IClass that)
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).

isFinal

public abstract boolean isFinal()
Whether subclassing is allowed (JVMS 4.1 access_flags)

Returns: true if subclassing is prohibited

isInterface

public abstract boolean isInterface()
Returns "true" if this type represents an interface.

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".

isSubclassOf

public boolean isSubclassOf(IClass that)
Returns true if this class is an immediate or non-immediate subclass of that class.

toString

public String toString()
Returns a string representation for this object.