169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal/* 269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Javassist, a Java-bytecode translator toolkit. 369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Copyright (C) 1999-2007 Shigeru Chiba. All Rights Reserved. 469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * The contents of this file are subject to the Mozilla Public License Version 669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 1.1 (the "License"); you may not use this file except in compliance with 769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * the License. Alternatively, the contents of this file may be used under 869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * the terms of the GNU Lesser General Public License Version 2.1 or later. 969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 1069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Software distributed under the License is distributed on an "AS IS" basis, 1169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 1269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * for the specific language governing rights and limitations under the 1369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * License. 1469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal */ 1569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalpackage javassist; 1769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 1869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalimport java.io.InputStream; 1969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalimport java.net.URL; 2069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 2169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal/** 2269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * <code>ClassPath</code> is an interface implemented by objects 2369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * representing a class search path. 2469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * <code>ClassPool</code> uses those objects for reading class files. 2569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 2669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * <p>The users can define a class implementing this interface so that 2769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * a class file is obtained from a non-standard source. 2869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 2969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @see ClassPool#insertClassPath(ClassPath) 3069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @see ClassPool#appendClassPath(ClassPath) 3169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @see ClassPool#removeClassPath(ClassPath) 3269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal */ 3369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigalpublic interface ClassPath { 3469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal /** 3569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Opens a class file. 3669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * This method may be called just to examine whether the class file 3769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * exists as well as to read the contents of the file. 3869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 3969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * <p>This method can return null if the specified class file is not 4069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * found. If null is returned, the next search path is examined. 4169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * However, if an error happens, this method must throw an exception 4269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * so that the search will be terminated. 4369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 4469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * <p>This method should not modify the contents of the class file. 4569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 4669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @param classname a fully-qualified class name 4769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @return the input stream for reading a class file 4869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @see javassist.Translator 4969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal */ 5069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal InputStream openClassfile(String classname) throws NotFoundException; 5169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 5269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal /** 5369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * Returns the uniform resource locator (URL) of the class file 5469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * with the specified name. 5569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * 5669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @param classname a fully-qualified class name. 5769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * @return null if the specified class file could not be found. 5869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal */ 5969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal URL find(String classname); 6069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal 6169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal /** 6269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * This method is invoked when the <code>ClassPath</code> object is 6369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * detached from the search path. It will be an empty method in most of 6469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal * classes. 6569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal */ 6669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal void close(); 6769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal} 68