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.Constructor and Description |
---|
SimpleCompiler() |
SimpleCompiler(Scanner scanner,
ClassLoader parentClassLoader)
Equivalent to
SimpleCompiler sc = new SimpleCompiler();
sc.setParentClassLoader(parentClassLoader);
sc.cook(scanner);
|
SimpleCompiler(String fileName)
Equivalent to
SimpleCompiler sc = new SimpleCompiler();
sc.cook(fileName);
|
SimpleCompiler(String fileName,
InputStream is)
Equivalent to
SimpleCompiler sc = new SimpleCompiler();
sc.cook(fileName, is);
|
SimpleCompiler(String fileName,
Reader in)
Equivalent to
SimpleCompiler sc = new SimpleCompiler();
sc.cook(fileName, 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.AbstractCompilationUnit abstractCompilationUnit)
Compiles the given compilation unit.
|
void |
cook(Java.AbstractCompilationUnit abstractCompilationUnit)
Cooks this compilation unit directly.
|
void |
cook(Scanner scanner)
Scans, parses and compiles a given compilation unit from the given scanner.
|
void |
cook(String fileName,
Reader r)
Scans, parses and compiles a given compilation unit from the given
Reader . |
boolean |
equals(Object o)
Two
SimpleCompiler s are regarded equal iff
Both are objects of the same class (e.g. both are ScriptEvaluator s)
Both generated functionally equal classes as seen by Object.equals(Object)
|
Map<String,byte[]> |
getBytecodes() |
ClassFile[] |
getClassFiles() |
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 compileErrorHandler) |
void |
setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars) |
void |
setParentClassLoader(ClassLoader parentClassLoader) |
void |
setSourceVersion(int version)
Controls the language elements that are accepted by the
Parser . |
void |
setTargetVersion(int version)
Controls the .class files that are generated by the
UnitCompiler . |
void |
setWarningHandler(WarningHandler warningHandler) |
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile
public SimpleCompiler(@Nullable String fileName, Reader in) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName, in);
IOException
CompileException
SimpleCompiler()
,
Cookable.cook(String, Reader)
public SimpleCompiler(@Nullable String fileName, InputStream is) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName, is);
IOException
CompileException
SimpleCompiler()
,
Cookable.cook(String, InputStream)
public SimpleCompiler(String fileName) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName);
IOException
CompileException
SimpleCompiler()
,
Cookable.cookFile(String)
public SimpleCompiler(Scanner scanner, @Nullable ClassLoader parentClassLoader) throws IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.setParentClassLoader(parentClassLoader); sc.cook(scanner);
public SimpleCompiler()
public void setParentClassLoader(@Nullable ClassLoader parentClassLoader)
setParentClassLoader
in interface ISimpleCompiler
public void setDebuggingInformation(boolean debugSource, boolean debugLines, boolean debugVars)
setDebuggingInformation
in interface ISimpleCompiler
public final void cook(@Nullable String fileName, Reader r) throws CompileException, IOException
Reader
. After completion, getClassLoader()
returns a ClassLoader
that allows for access to the compiled classes.cook
in interface ICookable
cook
in class Cookable
CompileException
IOException
public void cook(Scanner scanner) throws CompileException, IOException
getClassLoader()
returns a ClassLoader
that allows for access to the compiled classes.CompileException
IOException
public void cook(Java.AbstractCompilationUnit abstractCompilationUnit) throws CompileException
CompileException
public ClassFile[] getClassFiles()
ClassFile
s that were generated during cookingpublic void setSourceVersion(int version)
Parser
.setSourceVersion
in interface ICookable
Parser.setSourceVersion(int)
public void setTargetVersion(int version)
UnitCompiler
.setTargetVersion
in interface ICookable
UnitCompiler.setTargetVersion(int)
public Map<String,byte[]> getBytecodes()
getBytecodes
in interface ICookable
public ClassLoader getClassLoader()
getClassLoader
in interface ISimpleCompiler
public boolean equals(@Nullable Object o)
SimpleCompiler
s are regarded equal iff
ScriptEvaluator
s)
Object.equals(Object)
public void setCompileErrorHandler(@Nullable ErrorHandler compileErrorHandler)
setCompileErrorHandler
in interface ISimpleCompiler
public void setWarningHandler(@Nullable WarningHandler warningHandler)
setWarningHandler
in interface ISimpleCompiler
public 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.AbstractCompilationUnit abstractCompilationUnit) throws CompileException
abstractCompilationUnit
- The parsed compilation unitClassLoader
into which the compiled classes were definedCompileException
Copyright © 2023. All rights reserved.