public abstract class AbstractJavaSourceClassLoader extends ClassLoader
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 AbstractJavaSourceClassLoader and create a new one.
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractJavaSourceClassLoader.ProtectionDomainFactory |
| Modifier and Type | Field and Description |
|---|---|
protected AbstractJavaSourceClassLoader.ProtectionDomainFactory |
protectionDomainFactory |
| Constructor and Description |
|---|
AbstractJavaSourceClassLoader() |
AbstractJavaSourceClassLoader(ClassLoader parentClassLoader) |
| Modifier and Type | Method and Description |
|---|---|
InputStream |
getResourceAsStream(String name) |
static void |
main(String[] args)
Reads Java source code for a given class name, scan, parse, compile and load it into the virtual machine,
and invoke its "main()" method with the given arguments.
|
abstract void |
setDebuggingInfo(boolean lines,
boolean vars,
boolean source) |
void |
setProtectionDomainFactory(AbstractJavaSourceClassLoader.ProtectionDomainFactory protectionDomainFactory) |
abstract void |
setSourceCharset(Charset charset) |
void |
setSourceFileCharacterEncoding(String charsetName) |
abstract void |
setSourceFinder(ResourceFinder sourceFinder) |
abstract void |
setSourcePath(File[] sourcePath) |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners@Nullable protected AbstractJavaSourceClassLoader.ProtectionDomainFactory protectionDomainFactory
public AbstractJavaSourceClassLoader()
public AbstractJavaSourceClassLoader(ClassLoader parentClassLoader)
public InputStream getResourceAsStream(String name)
getResourceAsStream in class ClassLoaderpublic abstract void setSourcePath(File[] sourcePath)
sourcePath - The sequence of directories to search for Java source filespublic abstract void setSourceFinder(ResourceFinder sourceFinder)
sourceFinder - Is used when searching for Java source filespublic void setSourceFileCharacterEncoding(@Nullable String charsetName)
charsetName - if null, use platform default encodingpublic abstract void setSourceCharset(Charset charset)
charset - The character set to using when reading characters from a source filepublic abstract void setDebuggingInfo(boolean lines,
boolean vars,
boolean source)
lines - Whether line number debugging information should be generatedvars - Whether variables debugging information should be generatedsource - Whether source file debugging information should be generatedpublic final void setProtectionDomainFactory(@Nullable AbstractJavaSourceClassLoader.ProtectionDomainFactory protectionDomainFactory)
public static void main(String[] args) throws Exception
Usage is as follows:
java AbstractJavaSourceClassLoader [ option ] ... class-name [ argument ] ...
option:
-sourcepath colon-separated-list-of-source-directories
-encoding character-encoding
-g Generate all debugging info
-g:none Generate no debugging info
-g:{source,lines,vars} Generate only some debugging info
ExceptionCopyright © 2021. All rights reserved.