| java.lang.Object javassist.tools.reflect.Reflection
Reflection | public class Reflection implements Translator(Code) | | The class implementing the behavioral reflection mechanism.
If a class is reflective,
then all the method invocations on every
instance of that class are intercepted by the runtime
metaobject controlling that instance. The methods inherited from the
super classes are also intercepted except final methods. To intercept
a final method in a super class, that super class must be also reflective.
To do this, the original class file representing a reflective class:
class Person {
public int f(int i) { return i + 1; }
public int value;
}
is modified so that it represents a class:
class Person implements Metalevel {
public int _original_f(int i) { return i + 1; }
public int f(int i) { delegate to the metaobject }
public int value;
public int _r_value() { read "value" }
public void _w_value(int v) { write "value" }
public ClassMetaobject _getClass() { return a class metaobject }
public Metaobject _getMetaobject() { return a metaobject }
public void _setMetaobject(Metaobject m) { change a metaobject }
}
See Also: javassist.tools.reflect.ClassMetaobject See Also: javassist.tools.reflect.Metaobject See Also: javassist.tools.reflect.Loader See Also: javassist.tools.reflect.Compiler |
Constructor Summary | |
public | Reflection() Constructs a new Reflection object. |
Method Summary | |
public boolean | makeReflective(String classname, String metaobject, String metaclass) Produces a reflective class.
If the super class is also made reflective, it must be done
before the sub class.
Parameters: classname - the name of the reflective class Parameters: metaobject - the class name of metaobjects. Parameters: metaclass - the class name of the class metaobject. | public boolean | makeReflective(Class clazz, Class metaobject, Class metaclass) Produces a reflective class.
If the super class is also made reflective, it must be done
before the sub class.
Parameters: clazz - the reflective class. Parameters: metaobject - the class of metaobjects.It must be a subclass ofMetaobject . Parameters: metaclass - the class of the class metaobject.It must be a subclass ofClassMetaobject . | public boolean | makeReflective(CtClass clazz, CtClass metaobject, CtClass metaclass) Produces a reflective class. | public void | onLoad(ClassPool pool, String classname) Inserts hooks for intercepting accesses to the fields declared
in reflective classes. | public void | start(ClassPool pool) Initializes the object. |
classMetaobjectClassName | final static String classMetaobjectClassName(Code) | | |
classobjectAccessor | final static String classobjectAccessor(Code) | | |
metaobjectClassName | final static String metaobjectClassName(Code) | | |
trapMethodtrapStaticMethod | protected CtMethod trapMethodtrapStaticMethod(Code) | | |
Reflection | public Reflection()(Code) | | Constructs a new Reflection object.
|
|
|