Top Description Fields Constructors Methods
javassist

public Class LoaderClassPath

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

A class search-path representing a class loader.

It is used for obtaining a class file from the given class loader by getResourceAsStream(). The LoaderClassPath refers to the class loader through WeakReference. If the class loader is garbage collected, the other search pathes are examined.

The given class loader must have both getResourceAsStream() and getResource().

Class files in a named module are private to that module. This method cannot obtain class files in named modules.

Authors
Bill Burke, Shigeru Chiba
See Also
ClassPool#insertClassPath(ClassPath), ClassPool#appendClassPath(ClassPath), ClassClassPath

Field Summary

Modifier and TypeField and Description
private Reference<ClassLoader>

Constructor Summary

AccessConstructor and Description
public
LoaderClassPath(ClassLoader cl)

Creates a search path representing a class loader.

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 from the class loader.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

clrefback to summary
private Reference<ClassLoader> clref

Constructor Detail

LoaderClassPathback to summary
public LoaderClassPath(ClassLoader cl)

Creates a search path representing a class loader.

Method Detail

findback to summary
public URL find(String classname)

Implements javassist.ClassPath.find.

Obtains the URL of the specified class file. This method calls getResource(String) on the class loader.

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 from the class loader. This method calls getResourceAsStream(String) on the class loader.

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