Class ClassMetaobject
- java.lang.Object
- 
- javassist.tools.reflect.ClassMetaobject
 
- 
- All Implemented Interfaces:
- java.io.Serializable
 
 public class ClassMetaobject extends java.lang.Object implements java.io.SerializableA runtime class metaobject.A ClassMetaobjectis created for every class of reflective objects. It can be used to hold values shared among the reflective objects of the same class.To obtain a class metaobject, calls _getClass()on a reflective object. For example,ClassMetaobject cm = ((Metalevel)reflectiveObject)._getClass(); - See Also:
- Metaobject,- Metalevel, Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description static booleanuseContextClassLoaderSpecifies how ajava.lang.Classobject is loaded.
 - 
Constructor SummaryConstructors Constructor Description ClassMetaobject(java.lang.String[] params)Constructs aClassMetaobject.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<?>getJavaClass()Obtains thejava.lang.Classrepresenting this class.java.lang.reflect.MethodgetMethod(int identifier)Returns thejava.lang.reflect.Methodobject representing the method specified byidentifier.intgetMethodIndex(java.lang.String originalName, java.lang.Class<?>[] argTypes)Returns the identifier index of the method, as identified by its original name.java.lang.StringgetMethodName(int identifier)Returns the name of the method specified byidentifier.java.lang.StringgetName()Obtains the name of this class.java.lang.Class<?>[]getParameterTypes(int identifier)Returns an array ofClassobjects representing the formal parameter types of the method specified byidentifier.java.lang.reflect.Method[]getReflectiveMethods()Returns an array of the methods defined on the given reflective object.java.lang.Class<?>getReturnType(int identifier)Returns aClassobjects representing the return type of the method specified byidentifier.static java.lang.Objectinvoke(java.lang.Object target, int identifier, java.lang.Object[] args)Invokes a method whose name begins withmethodPrefix "_m_"and the identifier.booleanisInstance(java.lang.Object obj)Returns true ifobjis an instance of this class.java.lang.ObjectnewInstance(java.lang.Object[] args)Creates a new instance of the class.java.lang.ObjecttrapFieldRead(java.lang.String name)Is invoked whenstaticfields of the base-level class are read and the runtime system intercepts it.voidtrapFieldWrite(java.lang.String name, java.lang.Object value)Is invoked whenstaticfields of the base-level class are modified and the runtime system intercepts it.java.lang.ObjecttrapMethodcall(int identifier, java.lang.Object[] args)Is invoked whenstaticmethods of the base-level class are called and the runtime system intercepts it.
 
- 
- 
- 
Method Detail- 
getJavaClasspublic final java.lang.Class<?> getJavaClass() Obtains thejava.lang.Classrepresenting this class.
 - 
getNamepublic final java.lang.String getName() Obtains the name of this class.
 - 
isInstancepublic final boolean isInstance(java.lang.Object obj) Returns true ifobjis an instance of this class.
 - 
newInstancepublic final java.lang.Object newInstance(java.lang.Object[] args) throws CannotCreateExceptionCreates a new instance of the class.- Parameters:
- args- the arguments passed to the constructor.
- Throws:
- CannotCreateException
 
 - 
trapFieldReadpublic java.lang.Object trapFieldRead(java.lang.String name) Is invoked whenstaticfields of the base-level class are read and the runtime system intercepts it. This method simply returns the value of the field.Every subclass of this class should redefine this method. 
 - 
trapFieldWritepublic void trapFieldWrite(java.lang.String name, java.lang.Object value)Is invoked whenstaticfields of the base-level class are modified and the runtime system intercepts it. This method simply sets the field to the given value.Every subclass of this class should redefine this method. 
 - 
invokepublic static java.lang.Object invoke(java.lang.Object target, int identifier, java.lang.Object[] args) throws java.lang.ThrowableInvokes a method whose name begins withmethodPrefix "_m_"and the identifier.- Throws:
- CannotInvokeException- if the invocation fails.
- java.lang.Throwable
 
 - 
trapMethodcallpublic java.lang.Object trapMethodcall(int identifier, java.lang.Object[] args) throws java.lang.ThrowableIs invoked whenstaticmethods of the base-level class are called and the runtime system intercepts it. This method simply executes the intercepted method invocation with the original parameters and returns the resulting value.Every subclass of this class should redefine this method. - Throws:
- java.lang.Throwable
 
 - 
getReflectiveMethodspublic final java.lang.reflect.Method[] getReflectiveMethods() Returns an array of the methods defined on the given reflective object. This method is for the internal use only.
 - 
getMethodpublic final java.lang.reflect.Method getMethod(int identifier) Returns thejava.lang.reflect.Methodobject representing the method specified byidentifier.Note that the actual method returned will be have an altered, reflective name i.e. _m_2_...- Parameters:
- identifier- the identifier index given to- trapMethodcall()etc.
- See Also:
- Metaobject.trapMethodcall(int,Object[]),- trapMethodcall(int,Object[])
 
 - 
getMethodNamepublic final java.lang.String getMethodName(int identifier) Returns the name of the method specified byidentifier.
 - 
getParameterTypespublic final java.lang.Class<?>[] getParameterTypes(int identifier) Returns an array ofClassobjects representing the formal parameter types of the method specified byidentifier.
 - 
getReturnTypepublic final java.lang.Class<?> getReturnType(int identifier) Returns aClassobjects representing the return type of the method specified byidentifier.
 - 
getMethodIndexpublic final int getMethodIndex(java.lang.String originalName, java.lang.Class<?>[] argTypes) throws java.lang.NoSuchMethodExceptionReturns the identifier index of the method, as identified by its original name.This method is useful, in conjuction with getMethod(int), to obtain a quick reference to the original method in the reflected class (i.e. not the proxy method), using the original name of the method.Written by Brett Randall and Shigeru Chiba. - Parameters:
- originalName- The original name of the reflected method
- argTypes- array of Class specifying the method signature
- Returns:
- the identifier index of the original method
- Throws:
- java.lang.NoSuchMethodException- if the method does not exist
- See Also:
- getMethod(int)
 
 
- 
 
-