You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233
  1. package sample.reflect;
  2. import javassist.reflect.ClassMetaobject;
  3. import javassist.reflect.Loader;
  4. /*
  5. The "verbose metaobject" example (JDK 1.2 or later only).
  6. Since this program registers class Person as a reflective class
  7. (in a more realistic demonstration, what classes are reflective
  8. would be specified by some configuration file), the class loader
  9. modifies Person.class when loading into the JVM so that the class
  10. Person is changed into a reflective class and a Person object is
  11. controlled by a VerboseMetaobj.
  12. To run,
  13. % java javassist.reflect.Loader sample.reflect.Main Joe
  14. Compare this result with that of the regular execution without reflection:
  15. % java sample.reflect.Person Joe
  16. */
  17. public class Main {
  18. public static void main(String[] args) throws Throwable {
  19. Loader cl = (Loader)Main.class.getClassLoader();
  20. cl.makeReflective("sample.reflect.Person",
  21. "sample.reflect.VerboseMetaobj",
  22. "javassist.reflect.ClassMetaobject");
  23. cl.run("sample.reflect.Person", args);
  24. }
  25. }