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.

Assistant.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999- 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. * or the Apache License Version 2.0.
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. */
  16. package sample.preproc;
  17. import javassist.CtClass;
  18. import javassist.CannotCompileException;
  19. import javassist.ClassPool;
  20. /**
  21. * This is an interface for objects invoked by the
  22. * Javassist preprocessor when the preprocessor encounters an annotated
  23. * import declaration.
  24. *
  25. * @see sample.preproc.Compiler
  26. */
  27. public interface Assistant {
  28. /**
  29. * Is called when the Javassist preprocessor encounters an
  30. * import declaration annotated with the "by" keyword.
  31. *
  32. * <p>The original import declaration is replaced with new import
  33. * declarations of classes returned by this method. For example,
  34. * the following implementation does not change the original
  35. * declaration:
  36. *
  37. * <ul><pre>
  38. * public CtClass[] assist(ClassPool cp, String importname, String[] args) {
  39. * return new CtClass[] { cp.get(importname) };
  40. * }
  41. * </pre></uL>
  42. *
  43. * @param cp class pool
  44. * @param importname the class imported by the declaration
  45. * @param args the parameters specified by the annotation
  46. * @return the classes imported in the java source
  47. * program produced by the preprocessor.
  48. */
  49. public CtClass[] assist(ClassPool cp, String importname,
  50. String[] args) throws CannotCompileException;
  51. }