A class loader for reflection.
To run a program, say MyApp ,
including a reflective class,
you must write a start-up program as follows:
public class Main {
public static void main(String[] args) throws Throwable {
javassist.tools.reflect.Loader cl
= (javassist.tools.reflect.Loader)Main.class.getClassLoader();
cl.makeReflective("Person", "MyMetaobject",
"javassist.tools.reflect.ClassMetaobject");
cl.run("MyApp", args);
}
}
Then run this program as follows:
% java javassist.tools.reflect.Loader Main arg1, ...
This command runs Main.main() with arg1 , ...
and Main.main() runs MyApp.main() with
arg1 , ...
The Person class is modified
to be a reflective class. |