Package org.codehaus.commons.compiler
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 a
ClassBodyEvaluator
, then the tokens are interpreted as a class body and
compiled into a Class
which is accessible through IClassBodyEvaluator.getClazz()
.
The cook*()
methods eventually invoke the abstract cook(String, Reader)
method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClassLoader
TheClassLoader
that loads this classes on the boot class path, i.e.static final String
Value 'org.codehaus.janino.source_debugging.dir'.static final String
Value 'org.codehaus.janino.source_debugging.enable'. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cook
(InputStream is) Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".void
cook
(InputStream is, String optionalEncoding) Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.void
Reads, scans, parses and compiles Java tokens from the givenReader
.void
Reads, scans, parses and compiles Java tokens from the givenString
.void
cook
(String optionalFileName, InputStream is) Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".void
cook
(String optionalFileName, InputStream is, String optionalEncoding) Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.void
Reads, scans, parses and compiles Java tokens from the givenReader
.void
Reads, scans, parses and compiles Java tokens from the givenString
.void
Reads, scans, parses and compiles Java tokens from the givenFile
, encoded in the "platform default encoding".void
Reads, scans, parses and compiles Java tokens from the givenFile
with the givenencoding
.void
Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".void
Reads, scans, parses and compiles Java tokens from the named file with the givenencoding
.void
setDebuggingInformation
(boolean debugSource, boolean debugLines, boolean debugVars) Determines what kind of debugging information is included in the generates classes.void
setParentClassLoader
(ClassLoader optionalParentClassLoader) The "parent class loader" is used to load referenced classes.
-
Field Details
-
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
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:
-
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:
-
-
Method Details
-
setParentClassLoader
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
Reads, scans, parses and compiles Java tokens from the givenReader
.- Parameters:
optionalFileName
- Used when reporting errors and warnings.- Throws:
CompileException
IOException
-
cook
Reads, scans, parses and compiles Java tokens from the givenReader
.- Throws:
CompileException
IOException
-
cook
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".- Throws:
CompileException
IOException
-
cook
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
IOException
-
cook
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.- Throws:
CompileException
IOException
-
cook
void cook(String optionalFileName, InputStream is, String optionalEncoding) throws CompileException, IOException Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.- Parameters:
optionalFileName
- Used when reporting errors and warnings.- Throws:
CompileException
IOException
-
cook
Reads, scans, parses and compiles Java tokens from the givenString
.- Throws:
CompileException
-
cook
Reads, scans, parses and compiles Java tokens from the givenString
.- Parameters:
optionalFileName
- Used when reporting errors and warnings.- Throws:
CompileException
-
cookFile
Reads, scans, parses and compiles Java tokens from the givenFile
, encoded in the "platform default encoding".- Throws:
CompileException
IOException
-
cookFile
Reads, scans, parses and compiles Java tokens from the givenFile
with the givenencoding
.- Throws:
CompileException
IOException
-
cookFile
Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".- Throws:
CompileException
IOException
-
cookFile
Reads, scans, parses and compiles Java tokens from the named file with the givenencoding
.- Throws:
CompileException
IOException
-