|
janino.net | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
org.codehaus.commons.compiler.Cookable org.codehaus.janino.SimpleCompiler
public class SimpleCompiler
To set up a SimpleCompiler
object, proceed as described for ISimpleCompiler
.
Alternatively, a number of "convenience constructors" exist that execute the described steps
instantly.
Field Summary |
---|
Fields inherited from interface org.codehaus.commons.compiler.ICookable |
---|
BOOT_CLASS_LOADER, SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR, SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE |
Constructor Summary | |
---|---|
SimpleCompiler()
|
|
SimpleCompiler(Scanner scanner,
optionalParentClassLoader)
Equivalent to SimpleCompiler sc = new SimpleCompiler(); sc.setParentClassLoader(optionalParentClassLoader); sc.cook(scanner); |
|
SimpleCompiler( fileName)
Equivalent to SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName); |
|
SimpleCompiler( optionalFileName,
is)
Equivalent to SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, is); |
|
SimpleCompiler( optionalFileName,
in)
Equivalent to SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, in); |
Method Summary | |
---|---|
protected void |
assertNotCooked()
|
protected Java.Type[] |
classesToTypes(Location location,
[] classes)
Converts an array of es into an array of Java.Type s. |
protected Java.Type |
classToType(Location location,
clazz)
Wraps a reflection in a Java.Type object. |
protected |
compileToClassLoader(Java.CompilationUnit compilationUnit)
Compile the given compilation unit. |
void |
cook(Java.CompilationUnit compilationUnit)
Cooks this compilation unit directly. |
void |
cook(Scanner scanner)
Scans, parses and ompiles a given compilation unit from the given scanner. |
void |
cook( optionalFileName,
r)
Scans, parses and compiles a given compilation unit from the given . |
boolean |
equals( 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
|
|
getClassLoader()
Returns a object through which the previously compiled classes can be accessed. |
int |
hashCode()
|
static void |
main([] args)
|
void |
setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
By default, CompileException s 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( optionalParentClassLoader)
The "parent class loader" is used to load referenced classes. |
void |
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a custom WarningHandler . |
Methods inherited from class org.codehaus.commons.compiler.Cookable |
---|
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile, readString |
Methods inherited from class java.lang. |
---|
, , , , , , , , |
Methods inherited from interface org.codehaus.commons.compiler.ICookable |
---|
cook, cook, cook, cook, cook, cook, cook, cookFile, cookFile, cookFile, cookFile |
Constructor Detail |
---|
public SimpleCompiler( optionalFileName, in) throws , CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, in);
CompileException
SimpleCompiler()
,
Cookable.cook(String, Reader)
public SimpleCompiler( optionalFileName, is) throws , CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, is);
CompileException
SimpleCompiler()
,
Cookable.cook(String, InputStream)
public SimpleCompiler( fileName) throws , CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName);
CompileException
SimpleCompiler()
,
Cookable.cookFile(String)
public SimpleCompiler(Scanner scanner, optionalParentClassLoader) throws , CompileException
SimpleCompiler sc = new SimpleCompiler(); sc.setParentClassLoader(optionalParentClassLoader); sc.cook(scanner);
CompileException
SimpleCompiler()
,
setParentClassLoader(ClassLoader)
,
Cookable.cook(Reader)
public SimpleCompiler()
Method Detail |
---|
public static void main([] args) throws
public void setParentClassLoader( 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( optionalFileName, r) throws CompileException,
getClassLoader()
returns a that allows for access to the compiled classes.
cook
in interface ICookable
cook
in class Cookable
optionalFileName
- Used when reporting errors and warnings.
CompileException
ICookable.cook(String, Reader)
public void cook(Scanner scanner) throws CompileException,
getClassLoader()
returns a that allows for access to the compiled classes.
CompileException
public void cook(Java.CompilationUnit compilationUnit) throws CompileException
CompileException
Cookable.cook(Reader)
public getClassLoader()
ISimpleCompiler
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( o)
SimpleCompiler
s are regarded equal iff
ScriptEvaluator
s)
in class
public int hashCode()
in class
public void setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
ICookable
CompileException
s 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 CompileException
s, then the compilation is terminated and
the exception is propagated.
If the given ErrorHandler
does not throw CompileException
s, 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 ICookable
optionalCompileErrorHandler
- null
to restore the default behavior (throwing a CompileException
public void setWarningHandler(WarningHandler optionalWarningHandler)
ICookable
WarningHandler
.
setWarningHandler
in interface ICookable
optionalWarningHandler
- null
to indicate that no warnings be issuedprotected Java.Type classToType(Location location, clazz)
Java.Type
object.
protected Java.Type[] classesToTypes(Location location, [] classes)
Java.Type
s.
protected final compileToClassLoader(Java.CompilationUnit compilationUnit) throws CompileException
compilationUnit
- The parsed compilation unit
CompileException
protected void assertNotCooked()
- This Cookable
is already cooked
|
janino.net | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |