Package org.codehaus.commons.compiler.jdk

# Class JavaSourceClassLoader

java.lang.Object
java.lang.ClassLoader
org.codehaus.commons.compiler.AbstractJavaSourceClassLoader
org.codehaus.commons.compiler.jdk.JavaSourceClassLoader

public class JavaSourceClassLoader extends AbstractJavaSourceClassLoader
A `ClassLoader` that loads classes by looking for their source files through a "source path" and compiling them on-the-fly.

Notice that this class loader does not support resoures in the sense of `ClassLoader.getResource(String)`, `ClassLoader.getResourceAsStream(String)` nd `ClassLoader.getResources(String)`.

See Also:
  - `ClassLoaders`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`JavaSourceClassLoader.DiagnosticException`
Container for a `Diagnostic` object.

## Nested classes/interfaces inherited from class org.codehaus.commons.compiler.AbstractJavaSourceClassLoader

`AbstractJavaSourceClassLoader.ProtectionDomainFactory`

## Field Summary

### Fields inherited from class org.codehaus.commons.compiler.AbstractJavaSourceClassLoader

`protectionDomainFactory`

## Constructor Summary

Constructors
Constructor
Description
`JavaSourceClassLoader()`
`JavaSourceClassLoader(ClassLoader parentClassLoader)`

## Method Summary

Modifier and Type
Method
Description
`protected Class<?>`
`findClass(String className)`
Implementation of `ClassLoader.findClass(String)`.
`void`
`setCompilerOptions(String[] compilerOptions)`
Notice: Don't use the '-g' options - these are controlled through `setDebuggingInfo(boolean, boolean, boolean)`.
`void`
`setDebuggingInfo(boolean lines, boolean vars, boolean source)`
`void`
`setSourceCharset(Charset charset)`
`void`
`setSourceFinder(ResourceFinder sourceFinder)`
`void`
`setSourcePath(File[] sourcePath)`

### Methods inherited from class org.codehaus.commons.compiler.AbstractJavaSourceClassLoader

`getResourceAsStream, main, setProtectionDomainFactory, setSourceFileCharacterEncoding`

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

`clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners`

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### JavaSourceClassLoader

public JavaSourceClassLoader()

See Also:
  - `ICompilerFactory.newJavaSourceClassLoader()`

### JavaSourceClassLoader

public JavaSourceClassLoader(ClassLoader parentClassLoader)

See Also:
  - `ICompilerFactory.newJavaSourceClassLoader(ClassLoader)`

## Method Details

### setSourcePath

public void setSourcePath(File[] sourcePath)

Specified by:
  `setSourcePath` in class `AbstractJavaSourceClassLoader`
Parameters:
  `sourcePath` - The sequence of directories to search for Java source files

### setSourceFinder

public void setSourceFinder(ResourceFinder sourceFinder)

Specified by:
  `setSourceFinder` in class `AbstractJavaSourceClassLoader`
Parameters:
  `sourceFinder` - Is used when searching for Java source files

### setSourceCharset

public void setSourceCharset(Charset charset)

Specified by:
  `setSourceCharset` in class `AbstractJavaSourceClassLoader`
Parameters:
  `charset` - The character set to using when reading characters from a source file

### setDebuggingInfo

public void setDebuggingInfo(boolean lines, boolean vars, boolean source)

Specified by:
  `setDebuggingInfo` in class `AbstractJavaSourceClassLoader`
Parameters:
  `lines` - Whether line number debugging information should be generated
  `vars` - Whether variables debugging information should be generated
  `source` - Whether source file debugging information should be generated

### setCompilerOptions

public void setCompilerOptions(String[] compilerOptions)
Notice: Don't use the '-g' options - these are controlled through `setDebuggingInfo(boolean, boolean, boolean)`.

Parameters:
  `compilerOptions` - All command line options supported by the JDK JAVAC tool

### findClass

protected Class<?> findClass(String className) throws ClassNotFoundException
Implementation of `ClassLoader.findClass(String)`.

Overrides:
  `findClass` in class `ClassLoader`
Throws:
  `ClassNotFoundException`