public interface ISimpleCompiler extends ICookable
Opposed to a normal ".java" file, you can declare multiple public classes here.
To set up an ISimpleCompiler object, proceed as follows:
ISimpleCompiler-implementing objectsetParentClassLoader(ClassLoader).ICookable.cook(String, Reader) methods to scan, parse, compile and load the compilation
unit into the JVM.
getClassLoader() to obtain a ClassLoader that you can use to access the compiled classes.
| Modifier and Type | Method and Description |
|---|---|
ClassLoader |
getClassLoader()
Returns a
ClassLoader object through which the previously compiled classes can be accessed. |
void |
setCompileErrorHandler(ErrorHandler compileErrorHandler)
By default,
CompileExceptions are thrown on compile errors, but an application my install its own
ErrorHandler. |
void |
setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars)
Determines what kind of debugging information is included in the generates classes.
|
void |
setParentClassLoader(ClassLoader parentClassLoader)
The "parent class loader" is used to load referenced classes.
|
void |
setWarningHandler(WarningHandler warningHandler)
By default, warnings are discarded, but an application my install a custom
WarningHandler. |
void setParentClassLoader(@Nullable ClassLoader parentClassLoader)
System.getSystemClassLoader() |
The running JVM's class path |
Thread.currentThread().getContextClassLoader() or null |
The class loader effective for the invoking thread |
ClassLoaders.BOOTCLASSPATH_CLASS_LOADER |
The running JVM's boot class path |
The parent class loader defaults to the current thread's context class loader.
void setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars)
-g:none".void setCompileErrorHandler(@Nullable ErrorHandler compileErrorHandler)
CompileExceptions are thrown on compile errors, but an application my install its own
ErrorHandler.
Be aware that a single problem during compilation often causes a bunch of compile errors, so a good ErrorHandler counts errors and throws a CompileException when a limit is reached.
If the given ErrorHandler throws CompileExceptions, then the compilation is terminated and
the exception is propagated.
If the given ErrorHandler does not throw CompileExceptions, then the compiler may or may not
continue compilation, but must eventually throw a CompileException.
In other words: The ErrorHandler may throw a CompileException or not, but the compiler must
definitely throw a CompileException if one or more compile errors have occurred.
compileErrorHandler - null to restore the default behavior (throwing a CompileExceptionvoid setWarningHandler(@Nullable WarningHandler warningHandler)
WarningHandler.warningHandler - null to indicate that no warnings be issuedClassLoader getClassLoader()
ClassLoader object through which the previously compiled classes can be accessed. This ClassLoader can be used for subsequent ISimpleCompilers in order to compile compilation units that use
types (e.g. declare derived types) declared in the previous one.
This method must only be called after exactly one of the ICookable.cook(String, java.io.Reader) methods was
called.
Copyright © 2020. All rights reserved.