ClassLoader that, unlike usual ClassLoaders, does not load byte code, but reads Java source code
and then scans, parses, compiles and loads it into the virtual machine.
As with any ClassLoader, it is not possible to "update" classes after they've been loaded. The way to
achieve this is to give up on the JavaSourceClassLoader and create a new one.
Notice that this class loader does not support resoures in the sense of ClassLoader#getResource(String),
ClassLoader#getResourceAsStream(String) nd ClassLoader#getResources(String).
ClassLoaders
| Modifier and Type | Field and Description |
|---|---|
| private final Set | |
| private boolean | |
| private boolean | |
| private boolean | |
| private final JavaSourceIClassLoader | |
| private final Map | precompiledClasses
This |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | JavaSourceClassLoader(ClassLoader
See parentClassLoader, File[] ClassLoaderA collection of directories that are searched for Java source files in
the given order sourcePath, String The encoding of the Java source files ( characterEncoding)null for platform
default encoding)Sets up a |
| public | JavaSourceClassLoader(ClassLoader
See parentClassLoader, ResourceFinder ClassLoaderUsed to locate additional source files sourceFinder, String The encoding of the Java source files ( characterEncoding)null for platform
default encoding)Constructs a |
| public | JavaSourceClassLoader(ClassLoader parentClassLoader, JavaSourceIClassLoader iClassLoader)
Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| private Class | |
| protected Class | findClass(String
The binary name of the class name)Overrides java. ClassLoader#findClass(String).
|
| protected Map | Returns: String name => byte[] bytecode, ornull if no source code could be foundFinds, scans, parses the right compilation unit. |
| public void | |
| public void | setDebuggingInfo(boolean
Whether line number debugging information should be generated debugSource, boolean Whether variables debugging information should be generated debugLines, boolean Whether source file debugging information should be generated debugVars)Implements abstract org. |
| public void | setSourceCharset(Charset
The character set to using when reading characters from a source file charset)Implements abstract org. |
| public void | setSourceFinder(ResourceFinder
Is used when searching for Java source files sourceFinder)Implements abstract org. |
| public void | setSourcePath(File[]
The sequence of directories to search for Java source files sourcePath)Implements abstract org. |
| public void | |
| public void |
| compiledUnitCompilers | back to summary |
|---|---|
| private final Set<UnitCompiler> compiledUnitCompilers | |
| debugLines | back to summary |
|---|---|
| private boolean debugLines | |
| debugSource | back to summary |
|---|---|
| private boolean debugSource | |
| debugVars | back to summary |
|---|---|
| private boolean debugVars | |
| iClassLoader | back to summary |
|---|---|
| private final JavaSourceIClassLoader iClassLoader | |
| precompiledClasses | back to summary |
|---|---|
| private final Map<String, byte[]> precompiledClasses This | |
| JavaSourceClassLoader | back to summary |
|---|---|
| public JavaSourceClassLoader() | |
| JavaSourceClassLoader | back to summary |
|---|---|
| public JavaSourceClassLoader(ClassLoader parentClassLoader) | |
| JavaSourceClassLoader | back to summary |
|---|---|
| public JavaSourceClassLoader(ClassLoader parentClassLoader, File[] sourcePath, String characterEncoding) Sets up a
| |
| JavaSourceClassLoader | back to summary |
|---|---|
| public JavaSourceClassLoader(ClassLoader parentClassLoader, ResourceFinder sourceFinder, String characterEncoding) Constructs a
You can specify to include certain debugging information in the generated class files, which is useful if you
want to debug through the generated classes (see
| |
| JavaSourceClassLoader | back to summary |
|---|---|
| public JavaSourceClassLoader(ClassLoader parentClassLoader, JavaSourceIClassLoader iClassLoader) Constructs a | |
| defineBytecode | back to summary |
|---|---|
private Class
| |
| findClass | back to summary |
|---|---|
| protected Class Overrides java. Implementation of
| |
| generateBytecodes | back to summary |
|---|---|
| protected Map Finds, scans, parses the right compilation unit. Compile the parsed compilation unit to bytecode. This may cause more compilation units being scanned and parsed. Continue until all compilation units are compiled.
| |
| setCompileErrorHandler | back to summary |
|---|---|
public void setCompileErrorHandler(ErrorHandler compileErrorHandler)
| |
| setDebuggingInfo | back to summary |
|---|---|
| public void setDebuggingInfo(boolean debugSource, boolean debugLines, boolean debugVars) Implements abstract org.
| |
| setSourceCharset | back to summary |
|---|---|
| public void setSourceCharset(Charset charset) Implements abstract org.
| |
| setSourceFinder | back to summary |
|---|---|
| public void setSourceFinder(ResourceFinder sourceFinder) Implements abstract org.
| |
| setSourcePath | back to summary |
|---|---|
| public void setSourcePath(File[] sourcePath) Implements abstract org.
| |
| setTargetVersion | back to summary |
|---|---|
| public void setTargetVersion(int version) | |
| setWarningHandler | back to summary |
|---|---|
| public void setWarningHandler(WarningHandler warningHandler) | |