Package javassist

# Class LoaderClassPath

java.lang.Object
javassist.LoaderClassPath

All Implemented Interfaces:
  `ClassPath`

public class LoaderClassPath extends Object implements ClassPath
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.

Author:
  Bill Burke, Shigeru Chiba
See Also:
  - `ClassPool.insertClassPath(ClassPath)`
  - `ClassPool.appendClassPath(ClassPath)`
  - `ClassClassPath`

## Constructor Summary

Constructors
Constructor
Description
`LoaderClassPath(ClassLoader cl)`
Creates a search path representing a class loader.

## Method Summary

Modifier and Type
Method
Description
`URL`
`find(String classname)`
Obtains the URL of the specified class file.
`InputStream`
`openClassfile(String classname)`
Obtains a class file from the class loader.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### LoaderClassPath

public LoaderClassPath(ClassLoader cl)
Creates a search path representing a class loader.

## Method Details

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### openClassfile

public InputStream openClassfile(String classname) throws NotFoundException
Obtains a class file from the class loader. This method calls `getResourceAsStream(String)` on the class loader.

Specified by:
  `openClassfile` in interface `ClassPath`
Parameters:
  `classname` - a fully-qualified class name
Returns:
  the input stream for reading a class file
Throws:
  `NotFoundException`
See Also:
  - `Translator`

### find

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

Specified by:
  `find` in interface `ClassPath`
Parameters:
  `classname` - a fully-qualified class name.
Returns:
  null if the class file could not be found.