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 TypeClassDescriptionclass
class
class
Base class forIClass.IConstructor
andIClass.IMethod
static interface
class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IClass
TheIClass
object for the primitive type BOOLEAN.static final IClass
TheIClass
object for the primitive type BYTE.static final IClass
TheIClass
object for the primitive type CHAR.static final IClass
TheIClass
object for the primitive type DOUBLE.static final IClass
TheIClass
object for the primitive type FLOAT.static final IClass
TheIClass
object for the primitive type INT.static final IClass
TheIClass
object for the primitive type LONG.static final Object
Special return value forIClass.IField.getConstantValue()
indicating that the field does not have a constant value.static final IClass
TheIClass
object for the primitive type SHORT.static final IClass
TheIClass
object for the type VOID. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
final IClass.IMethod
findIMethod
(String methodName, IClass[] parameterTypes) abstract Access
getArrayIClass
(int n, IClass objectType) Get anIClass
that represents an n-dimensional array of this type.getArrayIClass
(IClass objectType) Get anIClass
that represents an array of this type.final IClass
Returns the component type of the array.
Returns "null" for classes, interfaces, primitive types and "void".protected abstract IClass
final 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.IField
getDeclaredIField
(String name) Returns the namedIClass.IField
declared in thisIClass
(does not work for inherited fields).final IClass.IField[]
Returns theIClass.IField
s 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 IClass
If this class is a member class, return the declaring class, otherwise returnnull
.protected abstract IClass
final String
Returns the field descriptor for the type as defined by JVMS 4.3.2.protected abstract String
static String[]
getDescriptors
(IClass[] iClasses) Convenience method that determines the field descriptors of an array ofIClass
es.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 IClass
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 classesprotected abstract IClass
final IClass
Returns the superclass of the class.
Returns "null" for class "Object", interfaces, arrays, primitive types and "void".protected abstract IClass
Returns the synthetic fields of an anonymous or local class, in the order in which they are passed to all constructors.final boolean
hasIMethod
(String methodName, IClass[] parameterTypes) boolean
implementsInterface
(IClass that) Ifthis
represents a class: Returntrue
if this class directly or indirectly implementsthat
interface.void
abstract boolean
Whether the class may be instantiated (JVMS 4.1 access_flags)abstract boolean
isArray()
Returns "true" if this type represents an array.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
Returns "true" if this type represents an interface.abstract boolean
Returns "true" if this type represents a primitive type or "void".abstract boolean
Returns "true" if this type represents "byte", "short", "int", "long", "char", "float" or "double".boolean
isSubclassOf
(IClass that) Returnstrue
if this class is an immediate or non-immediate subclass ofthat
class.toString()
-
Field Details
-
NOT_CONSTANT
Special return value forIClass.IField.getConstantValue()
indicating that the field does not have a constant value. -
VOID
TheIClass
object for the type VOID. -
BYTE
TheIClass
object for the primitive type BYTE. -
CHAR
TheIClass
object for the primitive type CHAR. -
DOUBLE
TheIClass
object for the primitive type DOUBLE. -
FLOAT
TheIClass
object for the primitive type FLOAT. -
INT
TheIClass
object for the primitive type INT. -
LONG
TheIClass
object for the primitive type LONG. -
SHORT
TheIClass
object for the primitive type SHORT. -
BOOLEAN
TheIClass
object 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.IMethod
s 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.IMethod
s that must not be modified - Throws:
CompileException
-
hasIMethod
- Returns:
- Whether this
IClass
does declare anIClass.IMethod
with the given name and parameter types - Throws:
CompileException
-
findIMethod
public final IClass.IMethod findIMethod(String methodName, IClass[] parameterTypes) throws CompileException - Returns:
- The
IClass.IMethod
declared in thisIClass
with the given name and parameter types - Throws:
CompileException
-
getDeclaredIFields
Returns theIClass.IField
s declared in thisIClass
(but not inherited fields).- Returns:
- An empty array for an array, primitive type or "void"
-
getDeclaredIField
Returns the namedIClass.IField
declared in thisIClass
(does not work for inherited fields).- Returns:
null
iff thisIClass
does not declare anIClass.IField
with 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:
true
if 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:
true
if 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 ofIClass
es.- 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
Returnstrue
if this class is an immediate or non-immediate subclass ofthat
class.- Throws:
CompileException
-
implementsInterface
Ifthis
represents a class: Returntrue
if this class directly or indirectly implementsthat
interface.If
this
represents an interface: Returntrue
if this interface directly or indirectly extendsthat
interface.- Throws:
CompileException
-
getArrayIClass
Get anIClass
that represents an n-dimensional array of this type.- Parameters:
n
- dimension countobjectType
- Required because the superclass of an array class isObject
by definition
-
getArrayIClass
Get anIClass
that represents an array of this type.- Parameters:
objectType
- Required because the superclass of an array class isObject
by definition
-
invalidateMethodCaches
public void invalidateMethodCaches()
-