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 ClassLoaderTheClassLoaderthat loads this classes on the boot class path, i.e.static final StringValue 'org.codehaus.janino.source_debugging.dir'.static final StringValue 'org.codehaus.janino.source_debugging.enable'. -
Method Summary
Modifier and TypeMethodDescriptionvoidcook(InputStream is) Reads, scans, parses and compiles Java tokens from the givenInputStream, encoded in the "platform default encoding".voidcook(InputStream is, String optionalEncoding) Reads, scans, parses and compiles Java tokens from the givenInputStreamwith the givenencoding.voidReads, scans, parses and compiles Java tokens from the givenReader.voidReads, scans, parses and compiles Java tokens from the givenString.voidcook(String optionalFileName, InputStream is) Reads, scans, parses and compiles Java tokens from the givenInputStream, encoded in the "platform default encoding".voidcook(String optionalFileName, InputStream is, String optionalEncoding) Reads, scans, parses and compiles Java tokens from the givenInputStreamwith the givenencoding.voidReads, scans, parses and compiles Java tokens from the givenReader.voidReads, scans, parses and compiles Java tokens from the givenString.voidReads, scans, parses and compiles Java tokens from the givenFile, encoded in the "platform default encoding".voidReads, scans, parses and compiles Java tokens from the givenFilewith the givenencoding.voidReads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".voidReads, scans, parses and compiles Java tokens from the named file with the givenencoding.voidsetDebuggingInformation(boolean debugSource, boolean debugLines, boolean debugVars) Determines what kind of debugging information is included in the generates classes.voidsetParentClassLoader(ClassLoader optionalParentClassLoader) The "parent class loader" is used to load referenced classes.
-
Field Details
-
BOOT_CLASS_LOADER
TheClassLoaderthat 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()ornullThe class loader effective for the invoking thread BOOT_CLASS_LOADERThe 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:
CompileExceptionIOException
-
cook
Reads, scans, parses and compiles Java tokens from the givenReader.- Throws:
CompileExceptionIOException
-
cook
Reads, scans, parses and compiles Java tokens from the givenInputStream, encoded in the "platform default encoding".- Throws:
CompileExceptionIOException
-
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:
CompileExceptionIOException
-
cook
Reads, scans, parses and compiles Java tokens from the givenInputStreamwith the givenencoding.- Throws:
CompileExceptionIOException
-
cook
void cook(String optionalFileName, InputStream is, String optionalEncoding) throws CompileException, IOException Reads, scans, parses and compiles Java tokens from the givenInputStreamwith the givenencoding.- Parameters:
optionalFileName- Used when reporting errors and warnings.- Throws:
CompileExceptionIOException
-
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:
CompileExceptionIOException
-
cookFile
Reads, scans, parses and compiles Java tokens from the givenFilewith the givenencoding.- Throws:
CompileExceptionIOException
-
cookFile
Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".- Throws:
CompileExceptionIOException
-
cookFile
Reads, scans, parses and compiles Java tokens from the named file with the givenencoding.- Throws:
CompileExceptionIOException
-