public class SimpleCompiler extends Cookable implements ISimpleCompiler
SimpleCompiler object, proceed as described for ISimpleCompiler. Alternatively, a number
of "convenience constructors" exist that execute the described steps instantly.BOOT_CLASS_LOADER, SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR, SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE| Constructor and Description |
|---|
SimpleCompiler() |
SimpleCompiler(Scanner scanner,
ClassLoader optionalParentClassLoader)
Equivalent to
SimpleCompiler sc = new SimpleCompiler();
sc.setParentClassLoader(optionalParentClassLoader);
sc.cook(scanner);
|
SimpleCompiler(String fileName)
Equivalent to
SimpleCompiler sc = new SimpleCompiler();
sc.cook(fileName);
|
SimpleCompiler(String optionalFileName,
InputStream is)
Equivalent to
SimpleCompiler sc = new SimpleCompiler();
sc.cook(optionalFileName, is);
|
SimpleCompiler(String optionalFileName,
Reader in)
Equivalent to
SimpleCompiler sc = new SimpleCompiler();
sc.cook(optionalFileName, in);
|
| Modifier and Type | Method and Description |
|---|---|
protected Java.Type[] |
classesToTypes(Location location,
Class<?>[] classes)
|
protected Java.Type |
classToType(Location location,
Class<?> clazz)
|
protected ClassLoader |
compileToClassLoader(Java.CompilationUnit compilationUnit)
Compiles the given compilation unit.
|
void |
cook(ClassFile[] classFiles)
Serializes the given classFiles as bytecode, stores them in a map, and then invokes
cook(Map). |
void |
cook(Java.CompilationUnit compilationUnit)
Cooks this compilation unit directly and invokes
cook(ClassFile[]). |
void |
cook(Map<String,byte[]> classes)
Creates a
ClassLoader that loads the given classes (lazily), and makes that class loader
available through getClassLoader(). |
void |
cook(Scanner scanner)
Scans, parses and compiles a given compilation unit from the given scanner.
|
void |
cook(String optionalFileName,
Reader r)
Scans, parses and compiles a given compilation unit from the given
Reader. |
boolean |
equals(Object o)
Two
SimpleCompilers are regarded equal iff
Both are objects of the same class (e.g. both are ScriptEvaluators)
Both generated functionally equal classes as seen by Object.equals(Object)
|
ClassLoader |
getClassLoader() |
int |
hashCode() |
static void |
main(String[] args) |
protected Java.Type |
optionalClassToType(Location location,
Class<?> clazz)
|
EnumSet<JaninoOption> |
options() |
SimpleCompiler |
options(EnumSet<JaninoOption> options)
Sets the options for all future compilations.
|
void |
setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler) |
void |
setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars) |
void |
setNoPermissions() |
void |
setParentClassLoader(ClassLoader optionalParentClassLoader) |
void |
setPermissions(Permissions permissions) |
void |
setWarningHandler(WarningHandler optionalWarningHandler) |
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile, readStringpublic SimpleCompiler(@Nullable String optionalFileName, Reader in) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler();
sc.cook(optionalFileName, in);
IOExceptionCompileExceptionSimpleCompiler(),
ICookable.cook(String, Reader)public SimpleCompiler(@Nullable String optionalFileName, InputStream is) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler();
sc.cook(optionalFileName, is);
IOExceptionCompileExceptionSimpleCompiler(),
Cookable.cook(String, InputStream)public SimpleCompiler(String fileName) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler();
sc.cook(fileName);
IOExceptionCompileExceptionSimpleCompiler(),
Cookable.cookFile(String)public SimpleCompiler(Scanner scanner, @Nullable ClassLoader optionalParentClassLoader) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler();
sc.setParentClassLoader(optionalParentClassLoader);
sc.cook(scanner);
public SimpleCompiler()
public void setParentClassLoader(@Nullable ClassLoader optionalParentClassLoader)
setParentClassLoader in interface ICookablepublic void setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars)
setDebuggingInformation in interface ICookablepublic final void cook(@Nullable String optionalFileName, Reader r) throws CompileException, IOException
Reader. After completion, getClassLoader() returns a ClassLoader that allows for access to the compiled classes.cook in interface ICookableCompileExceptionIOExceptionpublic void cook(Scanner scanner) throws CompileException, IOException
getClassLoader() returns a ClassLoader that allows for access to the compiled classes.CompileExceptionIOExceptionpublic void cook(Java.CompilationUnit compilationUnit) throws CompileException
cook(ClassFile[]).CompileExceptionpublic void cook(ClassFile[] classFiles)
cook(Map).public void cook(Map<String,byte[]> classes)
ClassLoader that loads the given classes (lazily), and makes that class loader
available through getClassLoader().classes - Maps fully qualified classes names to bytecodespublic ClassLoader getClassLoader()
getClassLoader in interface ISimpleCompilerpublic void setPermissions(Permissions permissions)
setPermissions in interface ISimpleCompilerpublic void setNoPermissions()
setNoPermissions in interface ISimpleCompilerpublic boolean equals(@Nullable Object o)
SimpleCompilers are regarded equal iff
ScriptEvaluators)
Object.equals(Object)
public void setCompileErrorHandler(@Nullable ErrorHandler optionalCompileErrorHandler)
setCompileErrorHandler in interface ICookablepublic void setWarningHandler(@Nullable WarningHandler optionalWarningHandler)
setWarningHandler in interface ICookablepublic EnumSet<JaninoOption> options()
public SimpleCompiler options(EnumSet<JaninoOption> options)
@Nullable protected Java.Type optionalClassToType(Location location, @Nullable Class<?> clazz)
protected Java.Type[] classesToTypes(Location location, @Nullable Class<?>[] classes)
protected final ClassLoader compileToClassLoader(Java.CompilationUnit compilationUnit) throws CompileException
compilationUnit - The parsed compilation unitClassLoader into which the compiled classes were definedCompileExceptionCopyright © 2019. All rights reserved.