public class CachedClass
extends Object
Caches reflection information for a class including its fields, methods, constructors, and interfaces.
Lazily initializes cached members on first access and provides utility methods for searching methods, checking assignability, and managing MOP methods. Instances are typically obtained via ReflectionCache.
| Modifiers | Name | Description |
|---|---|---|
static class |
CachedClass.CachedMethodComparatorByName |
Comparator for ordering cached methods by name. |
static class |
CachedClass.CachedMethodComparatorWithString |
Comparator for ordering cached methods against string names. |
| Modifiers | Name | Description |
|---|---|---|
static CachedClass[] |
EMPTY_ARRAY |
An empty array constant representing zero cached classes. |
ClassInfo |
classInfo |
ClassInfo object for this class, holding metadata about the class. |
boolean |
isArray |
true if the cached class is an array type, false otherwise. |
boolean |
isInterface |
true if the cached class is an interface, false otherwise. |
boolean |
isNumber |
true if the cached class is assignable from Number, false otherwise. |
boolean |
isPrimitive |
true if the cached class is a primitive type, false otherwise. |
int |
modifiers |
The modifiers of this class (e.g., public, final, abstract). |
CachedMethod[] |
mopMethods |
Array of MOP (Meta-Object Protocol) methods, including inherited methods. |
| Constructor and description |
|---|
CachedClass(Class<?> klazz, ClassInfo classInfo)Constructs a CachedClass for the given class with the specified ClassInfo. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
addNewMopMethods(List<MetaMethod> arr)Adds a list of new meta-methods to this class's existing MOP methods. |
|
public Object |
coerceArgument(Object argument)Coerces an argument to a form suitable for this class. |
|
public CachedClass |
getCachedClass()Returns this cached class (for compatibility). |
|
public CachedClass |
getCachedSuperClass()Returns the cached superclass of this class, if any. |
|
public CallSiteClassLoader |
getCallSiteLoader()Returns the class loader used for generating call site classes for this cached class. |
|
public CachedConstructor[] |
getConstructors()Returns all public and protected constructors declared in this class. |
|
public Set<CachedClass> |
getDeclaredInterfaces()Returns a set of interfaces directly declared by this class (not including inherited ones). |
|
public CachedField[] |
getFields()Returns all public and protected fields declared in this class. |
|
public Collection<ClassInfo> |
getHierarchy()Returns the complete type hierarchy for this class, including superclasses and interfaces. |
|
public Set<CachedClass> |
getInterfaces()Returns a set of all interfaces implemented or extended by this class, including inherited interfaces. |
|
public CachedMethod[] |
getMethods()Returns all public and protected methods of this class and its superclasses. |
|
public int |
getModifiers()Returns the access modifier flags for this class. |
|
public String |
getName()Returns the fully qualified name of this class. |
|
public MetaMethod[] |
getNewMetaMethods()Returns a list of new meta-methods added to this class's meta-class. |
|
public int |
getSuperClassDistance()Computes the distance from this class to the superclass hierarchy, used for type matching. |
|
public final Class<?> |
getTheClass()Returns the underlying Java Class object wrapped by this cached class. |
|
public String |
getTypeDescription()Returns the bytecode type descriptor for this class. |
|
public int |
hashCode() |
|
public boolean |
isAssignableFrom(Class<?> argument)Returns whether the argument class is assignable to this class. |
|
public boolean |
isDirectlyAssignable(Object argument)Returns whether an object instance is directly assignable to this class. |
|
public boolean |
isInterface()Returns whether this class represents an interface type. |
|
public boolean |
isPrimitive()Returns whether this class represents a primitive type. |
|
public boolean |
isVoid()Returns whether this class represents the void type. |
|
public CachedMethod |
searchMethods(String name, CachedClass[] parameterTypes)Searches for a method with the specified name and parameter types in this class. |
|
public void |
setNewMopMethods(List<MetaMethod> arr)Replaces the current MOP methods with the specified list of meta-methods. |
|
public String |
toString() |
An empty array constant representing zero cached classes.
ClassInfo object for this class, holding metadata about the class.
true if the cached class is an array type, false otherwise.
true if the cached class is an interface, false otherwise.
true if the cached class is assignable from Number, false otherwise.
true if the cached class is a primitive type, false otherwise.
The modifiers of this class (e.g., public, final, abstract). See Modifier for constants.
Array of MOP (Meta-Object Protocol) methods, including inherited methods. Updated when methods are added via setNewMopMethods(List) or addNewMopMethods(List).
Adds a list of new meta-methods to this class's existing MOP methods. Reinitializes the meta-class to incorporate the new methods alongside existing ones.
arr - the list of meta-methods to addCoerces an argument to a form suitable for this class.
By default, returns the argument unchanged. Subclasses may override to provide type-specific coercion logic.
argument - the argument to coerceReturns this cached class (for compatibility).
CachedClassReturns the cached superclass of this class, if any.
null if this is Object or an interfaceReturns the class loader used for generating call site classes for this cached class.
Returns all public and protected constructors declared in this class.
Returns a set of interfaces directly declared by this class (not including inherited ones).
Returns all public and protected fields declared in this class.
Returns the complete type hierarchy for this class, including superclasses and interfaces.
ClassInfo objects in the hierarchyReturns a set of all interfaces implemented or extended by this class, including inherited interfaces. If this class is an interface, it includes itself in the set.
Returns all public and protected methods of this class and its superclasses.
Returns the access modifier flags for this class.
Returns the fully qualified name of this class.
Returns a list of new meta-methods added to this class's meta-class. Includes expando methods and methods from all superclasses and interfaces.
Computes the distance from this class to the superclass hierarchy, used for type matching.
The distance is the number of steps up the inheritance chain from this class to Object.
Returns the underlying Java Class object wrapped by this cached class.
Returns the bytecode type descriptor for this class.
Returns whether the argument class is assignable to this class.
Returns true for null arguments.
argument - the class to checktrue if argument is null or assignable to this classReturns whether an object instance is directly assignable to this class.
argument - the object to checktrue if the object's class is assignable to this classReturns whether this class represents an interface type.
true if this is an interface, false otherwiseReturns whether this class represents a primitive type.
true if this is a primitive type (int, double, etc.), false otherwiseReturns whether this class represents the void type.
true if this class is void, false otherwiseSearches for a method with the specified name and parameter types in this class.
name - the name of the method to search forparameterTypes - the parameter types of the methodnull if not found. If multiple matches exist,
returns the one with the most specific return typeReplaces the current MOP methods with the specified list of meta-methods. Reinitializes the meta-class to reflect the new methods.
arr - the new list of meta-methods to use, or null to revert to defaultCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.