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.

ClassPath.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Javassist, a Java-bytecode translator toolkit.
  3. * Copyright (C) 1999-2006 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. import java.io.InputStream;
  17. import java.net.URL;
  18. /**
  19. * <code>ClassPath</code> is an interface implemented by objects
  20. * representing a class search path.
  21. * <code>ClassPool</code> uses those objects for reading class files.
  22. *
  23. * <p>The users can define a class implementing this interface so that
  24. * a class file is obtained from a non-standard source.
  25. *
  26. * @see ClassPool#insertClassPath(ClassPath)
  27. * @see ClassPool#appendClassPath(ClassPath)
  28. * @see ClassPool#removeClassPath(ClassPath)
  29. */
  30. public interface ClassPath {
  31. /**
  32. * Opens a class file.
  33. * This method may be called just to examine whether the class file
  34. * exists as well as to read the contents of the file.
  35. *
  36. * <p>This method can return null if the specified class file is not
  37. * found. If null is returned, the next search path is examined.
  38. * However, if an error happens, this method must throw an exception
  39. * so that the search will be terminated.
  40. *
  41. * <p>This method should not modify the contents of the class file.
  42. *
  43. * @param classname a fully-qualified class name
  44. * @return the input stream for reading a class file
  45. * @see javassist.Translator
  46. */
  47. InputStream openClassfile(String classname) throws NotFoundException;
  48. /**
  49. * Returns the uniform resource locator (URL) of the class file
  50. * with the specified name.
  51. *
  52. * @param classname a fully-qualified class name.
  53. * @return null if the specified class file could not be found.
  54. */
  55. URL find(String classname);
  56. /**
  57. * This method is invoked when the <code>ClassPath</code> object is
  58. * detached from the search path. It will be an empty method in most of
  59. * classes.
  60. */
  61. void close();
  62. }