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.Modifier and Type | Field and Description |
---|---|
protected boolean |
debugLines |
protected boolean |
debugSource |
protected boolean |
debugVars |
BOOT_CLASS_LOADER, SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR, SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE
Constructor and Description |
---|
SimpleCompiler() |
SimpleCompiler(Scanner scanner,
java.lang.ClassLoader optionalParentClassLoader)
Equivalent to
|
SimpleCompiler(java.lang.String fileName)
Equivalent to
|
SimpleCompiler(java.lang.String optionalFileName,
java.io.InputStream is)
Equivalent to
|
SimpleCompiler(java.lang.String optionalFileName,
java.io.Reader in)
Equivalent to
|
Modifier and Type | Method and Description |
---|---|
protected void |
assertNotCooked()
Throw an
IllegalStateException if this Cookable is already cooked. |
protected Java.Type[] |
classesToTypes(Location location,
java.lang.Class[] classes)
Convert an array of
Class es into an array ofJava.Type s. |
protected Java.Type |
classToType(Location location,
java.lang.Class clazz)
Wrap a reflection
Class in a Java.Type object. |
protected java.lang.ClassLoader |
compileToClassLoader(Java.CompilationUnit compilationUnit)
Compile the given compilation unit.
|
void |
cook(Java.CompilationUnit compilationUnit)
Cook this compilation unit directly.
|
void |
cook(Scanner scanner)
Scans, parses and ompiles a given compilation unit from the given scanner.
|
void |
cook(java.lang.String optionalFileName,
java.io.Reader r)
Scans, parses and compiles a given compilation unit from the given
Reader . |
boolean |
equals(java.lang.Object o)
Two
SimpleCompiler s are regarded equal iff
Both are objects of the same class (e.g. |
java.lang.ClassLoader |
getClassLoader()
Returns a
ClassLoader object through which the previously compiled classes can be accessed. |
int |
hashCode() |
static void |
main(java.lang.String[] args) |
void |
setDebuggingInformation(boolean debugSource,
boolean debugLines,
boolean debugVars)
Determines what kind of debugging information is included in the generates classes.
|
void |
setParentClassLoader(java.lang.ClassLoader optionalParentClassLoader)
The "parent class loader" is used to load referenced classes.
|
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile, readString
protected boolean debugSource
protected boolean debugLines
protected boolean debugVars
public SimpleCompiler(java.lang.String optionalFileName, java.io.Reader in) throws java.io.IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, in);
java.io.IOException
CompileException
SimpleCompiler()
,
Cookable.cook(String, Reader)
public SimpleCompiler(java.lang.String optionalFileName, java.io.InputStream is) throws java.io.IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, is);
java.io.IOException
CompileException
SimpleCompiler()
,
Cookable.cook(String, InputStream)
public SimpleCompiler(java.lang.String fileName) throws java.io.IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName);
java.io.IOException
CompileException
SimpleCompiler()
,
Cookable.cookFile(String)
public SimpleCompiler(Scanner scanner, java.lang.ClassLoader optionalParentClassLoader) throws java.io.IOException, CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.setParentClassLoader(optionalParentClassLoader); sc.cook(scanner);
java.io.IOException
CompileException
SimpleCompiler()
,
setParentClassLoader(ClassLoader)
,
Cookable.cook(Reader)
public SimpleCompiler()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public void setParentClassLoader(java.lang.ClassLoader optionalParentClassLoader)
ICookable
System.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
public void setDebuggingInformation(boolean debugSource, boolean debugLines, boolean debugVars)
ICookable
setDebuggingInformation
in interface ICookable
public final void cook(java.lang.String optionalFileName, java.io.Reader r) throws CompileException, java.io.IOException
Reader
. After completion, getClassLoader()
returns a ClassLoader
that allows for access to the compiled classes.cook
in interface ICookable
cook
in class Cookable
optionalFileName
- Used when reporting errors and warnings.CompileException
java.io.IOException
ICookable.cook(String, Reader)
public void cook(Scanner scanner) throws CompileException, java.io.IOException
getClassLoader()
returns a ClassLoader
that allows for access to the compiled classes.CompileException
java.io.IOException
public void cook(Java.CompilationUnit compilationUnit) throws CompileException
Cookable.cook(java.lang.String, java.io.Reader)
CompileException
public java.lang.ClassLoader getClassLoader()
ISimpleCompiler
ClassLoader
object through which the previously compiled classes can be accessed. This ClassLoader
can be used for subsequent ISimpleCompiler
s 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 ISimpleCompiler
public boolean equals(java.lang.Object o)
SimpleCompiler
s are regarded equal iff
ScriptEvaluator
s)
ByteArrayClassLoader.equals(Object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected Java.Type classToType(Location location, java.lang.Class clazz)
Class
in a Java.Type
object.protected Java.Type[] classesToTypes(Location location, java.lang.Class[] classes)
Class
es into an array ofJava.Type
s.protected final java.lang.ClassLoader compileToClassLoader(Java.CompilationUnit compilationUnit) throws CompileException
compilationUnit
- The parsed compilation unitClassLoader
into which the compiled classes were definedCompileException
protected void assertNotCooked()
IllegalStateException
if this Cookable
is already cooked.