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.

Translator.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved.
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. Alternatively, the contents of this file may be used under
  8. * the terms of the GNU Lesser General Public License Version 2.1 or later.
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. */
  15. package javassist;
  16. /**
  17. * An observer of <code>ClassPool</code>.
  18. * The users can define a class implementing this
  19. * interface and attach an instance of that class to a
  20. * <code>ClassPool</code> object so that it can translate a class file
  21. * when the class file is loaded into the JVM, for example.
  22. *
  23. * @see ClassPool#ClassPool(ClassPool,Translator)
  24. * @see ClassPool#getDefault(Translator)
  25. */
  26. public interface Translator {
  27. /**
  28. * Is invoked by a <code>ClassPool</code> for initialization
  29. * when the object is attached to a <code>ClassPool</code> object.
  30. *
  31. * @param pool the <code>ClassPool</code> that this translator
  32. * is attached to.
  33. *
  34. * @see ClassPool#ClassPool(ClassPool,Translator)
  35. * @see ClassPool#getDefault(Translator)
  36. */
  37. void start(ClassPool pool)
  38. throws NotFoundException, CannotCompileException;
  39. /**
  40. * Is invoked by a <code>ClassPool</code> for notifying that
  41. * a class is written out to an output stream.
  42. *
  43. * <p>If CtClass.frozen() is true, that is, if the class has been
  44. * already modified and written, then onWrite() is not invoked.
  45. *
  46. * @param pool the <code>ClassPool</code> that this translator
  47. * is attached to.
  48. * @param classname a fully-qualified class name
  49. *
  50. * @see ClassPool#writeFile(String)
  51. * @see ClassPool#writeFile(String, String)
  52. * @see ClassPool#write(String)
  53. * @see ClassPool#write(String,DataOutputStream)
  54. */
  55. void onWrite(ClassPool pool, String classname)
  56. throws NotFoundException, CannotCompileException;
  57. }