ClassPath
public class ClassClassPath extends java.lang.Object implements ClassPath
getResourceAsStream()
in java.lang.Class
.
Try adding a ClassClassPath
when a program is running
with a user-defined class loader and any class files are not found with
the default ClassPool
. For example,
ClassPool cp = ClassPool.getDefault(); cp.insertClassPath(new ClassClassPath(this.getClass()));This code snippet permanently adds a
ClassClassPath
to the default ClassPool
. Note that the default
ClassPool
is a singleton. The added
ClassClassPath
uses 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 | Description |
---|---|
ClassClassPath(java.lang.Class<?> c) |
Creates a search path.
|
Modifier and Type | Method | Description |
---|---|---|
java.net.URL |
find(java.lang.String classname) |
Obtains the URL of the specified class file.
|
java.io.InputStream |
openClassfile(java.lang.String classname) |
Obtains a class file by
getResourceAsStream() . |
java.lang.String |
toString() |
public ClassClassPath(java.lang.Class<?> c)
c
- the Class
object used to obtain a class
file. getResourceAsStream()
is called on
this object.public java.io.InputStream openClassfile(java.lang.String classname) throws NotFoundException
getResourceAsStream()
.openClassfile
in interface ClassPath
classname
- a fully-qualified class nameNotFoundException
Translator
public java.net.URL find(java.lang.String classname)
public java.lang.String toString()
toString
in class java.lang.Object
Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.