public class ClassClassPath extends 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.Constructor and Description |
---|
ClassClassPath(Class c)
Creates a search path.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Does nothing.
|
URL |
find(String classname)
Obtains the URL of the specified class file.
|
InputStream |
openClassfile(String classname)
Obtains a class file by
getResourceAsStream() . |
String |
toString() |
public ClassClassPath(Class c)
c
- the Class
object used to obtain a class
file. getResourceAsStream()
is called on
this object.public InputStream openClassfile(String classname)
getResourceAsStream()
.openClassfile
in interface ClassPath
classname
- a fully-qualified class nameTranslator
Copyright © 2024. All rights reserved.