Package javassist
Class ClassClassPath
- java.lang.Object
-
- javassist.ClassClassPath
-
- All Implemented Interfaces:
ClassPath
public class ClassClassPath extends java.lang.Object implements ClassPath
A search-path for obtaining a class file bygetResourceAsStream()injava.lang.Class.Try adding a
ClassClassPathwhen a program is running with a user-defined class loader and any class files are not found with the defaultClassPool. For example,ClassPool cp = ClassPool.getDefault(); cp.insertClassPath(new ClassClassPath(this.getClass()));
This code snippet permanently adds aClassClassPathto the defaultClassPool. Note that the defaultClassPoolis a singleton. The addedClassClassPathuses a class object representing the class including the code snippet above.Class files in a named module are private to that module. This method cannot obtain class files in named modules.
-
-
Constructor Summary
Constructors Constructor Description ClassClassPath(java.lang.Class<?> c)Creates a search path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.URLfind(java.lang.String classname)Obtains the URL of the specified class file.java.io.InputStreamopenClassfile(java.lang.String classname)Obtains a class file bygetResourceAsStream().java.lang.StringtoString()
-
-
-
Method Detail
-
openClassfile
public java.io.InputStream openClassfile(java.lang.String classname) throws NotFoundExceptionObtains a class file bygetResourceAsStream().- Specified by:
openClassfilein interfaceClassPath- Parameters:
classname- a fully-qualified class name- Returns:
- the input stream for reading a class file
- Throws:
NotFoundException- See Also:
Translator
-
find
public java.net.URL find(java.lang.String classname)
Obtains the URL of the specified class file.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-