Interface ICookable
-
- All Known Subinterfaces:
IClassBodyEvaluator
,IExpressionEvaluator
,IScriptEvaluator
,ISimpleCompiler
- All Known Implementing Classes:
ClassBodyEvaluator
,ClassBodyEvaluator
,Cookable
,ExpressionEvaluator
,ExpressionEvaluator
,ScriptEvaluator
,ScriptEvaluator
,SimpleCompiler
,SimpleCompiler
public interface ICookable
"Cooking" means scanning a sequence of characters and turning them into some JVM-executable artifact. For example, if you cook aClassBodyEvaluator
, then the tokens are interpreted as a class body and compiled into aClass
which is accessible throughIClassBodyEvaluator.getClazz()
.The
cook*()
methods eventually invoke the abstractcook(String, Reader)
method.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ClassLoader
BOOT_CLASS_LOADER
TheClassLoader
that loads this classes on the boot class path, i.e.static java.lang.String
SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR
Value 'org.codehaus.janino.source_debugging.dir'.static java.lang.String
SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE
Value 'org.codehaus.janino.source_debugging.enable'.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cook(java.io.InputStream is)
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".void
cook(java.io.InputStream is, java.lang.String optionalEncoding)
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.void
cook(java.io.Reader r)
Reads, scans, parses and compiles Java tokens from the givenReader
.void
cook(java.lang.String s)
Reads, scans, parses and compiles Java tokens from the givenString
.void
cook(java.lang.String optionalFileName, java.io.InputStream is)
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".void
cook(java.lang.String optionalFileName, java.io.InputStream is, java.lang.String optionalEncoding)
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.void
cook(java.lang.String optionalFileName, java.io.Reader r)
Reads, scans, parses and compiles Java tokens from the givenReader
.void
cook(java.lang.String optionalFileName, java.lang.String s)
Reads, scans, parses and compiles Java tokens from the givenString
.void
cookFile(java.io.File file)
Reads, scans, parses and compiles Java tokens from the givenFile
, encoded in the "platform default encoding".void
cookFile(java.io.File file, java.lang.String optionalEncoding)
Reads, scans, parses and compiles Java tokens from the givenFile
with the givenencoding
.void
cookFile(java.lang.String fileName)
Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".void
cookFile(java.lang.String fileName, java.lang.String optionalEncoding)
Reads, scans, parses and compiles Java tokens from the named file with the givenoptionalEncoding
.void
setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
By default,CompileException
s are thrown on compile errors, but an application my install its ownErrorHandler
.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.void
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a customWarningHandler
.
-
-
-
Field Detail
-
BOOT_CLASS_LOADER
static final java.lang.ClassLoader BOOT_CLASS_LOADER
TheClassLoader
that loads this classes on the boot class path, i.e. the JARs in the JRE's "lib" and "lib/ext" directories, but not the JARs and class directories specified through the class path.
-
SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE
static final java.lang.String SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE
Value 'org.codehaus.janino.source_debugging.enable'.Setting this system property to 'true' enables source-level debugging. Typically, this means that compilation is executed with '-g:all' instead of '-g:none'.
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR
static final java.lang.String SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR
Value 'org.codehaus.janino.source_debugging.dir'.If source code is not compiled from a file, debuggers have a hard time locating the source file for source-level debugging. As a workaround, a copy of the source code is written to a temporary file, which must be included in the debugger's source path. If this system property is set, the temporary source file is created in that directory, otherwise in the default temporary-file directory.
- See Also:
File.createTempFile(String, String, File)
, Constant Field Values
-
-
Method Detail
-
setParentClassLoader
void setParentClassLoader(java.lang.ClassLoader optionalParentClassLoader)
The "parent class loader" is used to load referenced classes. Useful values are:
The parent class loader defaults to the current thread's context class loader.System.getSystemClassLoader()
The running JVM's class path Thread.currentThread().getContextClassLoader()
ornull
The class loader effective for the invoking thread BOOT_CLASS_LOADER
The running JVM's boot class path
-
setDebuggingInformation
void setDebuggingInformation(boolean debugSource, boolean debugLines, boolean debugVars)
Determines what kind of debugging information is included in the generates classes. The default is typically '-g:none', and '-g:all' if the system property 'org.codehaus.janino.source_debugging.enable' is set to 'true'.
-
cook
void cook(java.lang.String optionalFileName, java.io.Reader r) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenReader
.- Parameters:
optionalFileName
- Used when reporting errors and warnings.- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.io.Reader r) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenReader
.- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.io.InputStream is) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.lang.String optionalFileName, java.io.InputStream is) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".- Parameters:
optionalFileName
- Used when reporting errors and warnings.- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.io.InputStream is, java.lang.String optionalEncoding) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.lang.String optionalFileName, java.io.InputStream is, java.lang.String optionalEncoding) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.- Parameters:
optionalFileName
- Used when reporting errors and warnings.- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.lang.String s) throws CompileException
Reads, scans, parses and compiles Java tokens from the givenString
.- Throws:
CompileException
-
cook
void cook(java.lang.String optionalFileName, java.lang.String s) throws CompileException
Reads, scans, parses and compiles Java tokens from the givenString
.- Parameters:
optionalFileName
- Used when reporting errors and warnings.- Throws:
CompileException
-
cookFile
void cookFile(java.io.File file) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenFile
, encoded in the "platform default encoding".- Throws:
CompileException
java.io.IOException
-
cookFile
void cookFile(java.io.File file, java.lang.String optionalEncoding) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenFile
with the givenencoding
.- Throws:
CompileException
java.io.IOException
-
cookFile
void cookFile(java.lang.String fileName) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".- Throws:
CompileException
java.io.IOException
-
cookFile
void cookFile(java.lang.String fileName, java.lang.String optionalEncoding) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the named file with the givenoptionalEncoding
.- Throws:
CompileException
java.io.IOException
-
setCompileErrorHandler
void setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
By default,CompileException
s are thrown on compile errors, but an application my install its ownErrorHandler
.Be aware that a single problem during compilation often causes a bunch of compile errors, so a good
ErrorHandler
counts errors and throws aCompileException
when a limit is reached.If the given
ErrorHandler
throwsCompileException
s, then the compilation is terminated and the exception is propagated.If the given
ErrorHandler
does not throwCompileException
s, then the compiler may or may not continue compilation, but must eventually throw aCompileException
.In other words: The
ErrorHandler
may throw aCompileException
or not, but the compiler must definitely throw aCompileException
if one or more compile errors have occurred.- Parameters:
optionalCompileErrorHandler
-null
to restore the default behavior (throwing aCompileException
-
setWarningHandler
void setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a customWarningHandler
.- Parameters:
optionalWarningHandler
-null
to indicate that no warnings be issued
-
-