public class SimpleCompiler extends Cookable implements ISimpleCompiler
ISimpleCompiler.BOOT_CLASS_LOADER, SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR, SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE| Constructor and Description |
|---|
SimpleCompiler() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertNotCooked()
Throws an
IllegalStateException if this Cookable is already cooked. |
void |
cook(String optionalFileName,
Reader r)
Reads, scans, parses and compiles Java tokens from the given
Reader. |
ClassLoader |
getClassLoader()
Returns a
ClassLoader object through which the previously compiled classes can be accessed. |
void |
setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
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 optionalParentClassLoader)
The "parent class loader" is used to load referenced classes.
|
void |
setParentClassLoader(ClassLoader optionalParentClassLoader,
Class<?>[] auxiliaryClasses)
Deprecated.
Auxiliary classes never really worked... don't use them.
|
void |
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a custom
WarningHandler. |
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile, readStringpublic ClassLoader getClassLoader()
ISimpleCompilerClassLoader 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 on of the ICookable.cook(String, java.io.Reader) methods was called.
getClassLoader in interface ISimpleCompilerIllegalStateException - This Cookable is not yet cookedpublic void cook(@Nullable
String optionalFileName,
Reader r)
throws CompileException,
IOException
ICookableReader.cook in interface ICookablecook in class CookableoptionalFileName - Used when reporting errors and warnings.CompileExceptionIOExceptionICookable.cook(String, Reader)public void setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars)
ICookablesetDebuggingInformation in interface ICookablepublic void setParentClassLoader(@Nullable
ClassLoader optionalParentClassLoader)
ICookableSystem.getSystemClassLoader() |
The running JVM's class path |
Thread.currentThread().getContextClassLoader() or null |
The class loader effective for the invoking thread |
ICookable.BOOT_CLASS_LOADER |
The running JVM's boot class path |
setParentClassLoader in interface ICookable@Deprecated public void setParentClassLoader(@Nullable ClassLoader optionalParentClassLoader, Class<?>[] auxiliaryClasses)
public void setCompileErrorHandler(@Nullable
ErrorHandler optionalCompileErrorHandler)
ICookableCompileExceptions 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.
setCompileErrorHandler in interface ICookableoptionalCompileErrorHandler - null to restore the default behavior (throwing a CompileExceptionpublic void setWarningHandler(@Nullable
WarningHandler optionalWarningHandler)
ICookableWarningHandler.setWarningHandler in interface ICookableoptionalWarningHandler - null to indicate that no warnings be issuedprotected void assertNotCooked()
IllegalStateException if this Cookable is already cooked.