Top Description Fields Constructors Methods
javassist

public Class ClassClassPath

extends Object
implements ClassPath
Class Inheritance
All Implemented Interfaces
javassist.ClassPath
Imports
java.io.InputStream, java.net.URL

A search-path for obtaining a class file by 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.

See Also
ClassPool#insertClassPath(ClassPath), ClassPool#appendClassPath(ClassPath), LoaderClassPath

Field Summary

Modifier and TypeField and Description
private Class<?>

Constructor Summary

AccessConstructor and Description
public
ClassClassPath(Class<?>
the Class object used to obtain a class file. getResourceAsStream() is called on this object.
c
)

Creates a search path.

pack-priv

Method Summary

Modifier and TypeMethod and Description
public URL

Returns:

null if the class file could not be found.
find
(String
a fully-qualified class name.
classname
)

Implements javassist.ClassPath.find.

Obtains the URL of the specified class file.

public InputStream
openClassfile(String
a fully-qualified class name
classname
)

Implements javassist.ClassPath.openClassfile.

Obtains a class file by getResourceAsStream().

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

thisClassback to summary
private Class<?> thisClass

Constructor Detail

ClassClassPathback to summary
public ClassClassPath(Class<?> c)

Creates a search path.

Parameters
c:Class<?>

the Class object used to obtain a class file. getResourceAsStream() is called on this object.

ClassClassPathback to summary
pack-priv ClassClassPath()

Method Detail

findback to summary
public URL find(String classname)

Implements javassist.ClassPath.find.

Obtains the URL of the specified class file.

Parameters
classname:String

Doc from javassist.ClassPath.find.

a fully-qualified class name.

Returns:URL

null if the class file could not be found.

Annotations
@Override
openClassfileback to summary
public InputStream openClassfile(String classname) throws NotFoundException

Implements javassist.ClassPath.openClassfile.

Obtains a class file by getResourceAsStream().

Parameters
classname:String

Doc from javassist.ClassPath.openClassfile.

a fully-qualified class name

Returns:InputStream

Doc from javassist.ClassPath.openClassfile.

the input stream for reading a class file

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override