janino.net

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 which is accessible through IClassBodyEvaluator.getClazz().

The cook*() methods eventually invoke the abstract cook(String, Reader) method.


Field Summary
static  BOOT_CLASS_LOADER
          The 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.
static  SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR
          Value 'org.codehaus.janino.source_debugging.dir'.
static  SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE
          Value 'org.codehaus.janino.source_debugging.enable'.
 
Method Summary
 void cook( is)
          Reads, scans, parses and compiles Java tokens from the given , encoded in the "platform default encoding".
 void cook( is,  optionalEncoding)
          Reads, scans, parses and compiles Java tokens from the given with the given encoding.
 void cook( r)
          Reads, scans, parses and compiles Java tokens from the given .
 void cook( s)
          Reads, scans, parses and compiles Java tokens from the given .
 void cook( optionalFileName,  is)
          Reads, scans, parses and compiles Java tokens from the given , encoded in the "platform default encoding".
 void cook( optionalFileName,  is,  optionalEncoding)
          Reads, scans, parses and compiles Java tokens from the given with the given encoding.
 void cook( optionalFileName,  r)
          Reads, scans, parses and compiles Java tokens from the given .
 void cook( optionalFileName,  s)
          Reads, scans, parses and compiles Java tokens from the given .
 void cookFile( file)
          Reads, scans, parses and compiles Java tokens from the given , encoded in the "platform default encoding".
 void cookFile( file,  optionalEncoding)
          Reads, scans, parses and compiles Java tokens from the given with the given encoding.
 void cookFile( fileName)
          Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".
 void cookFile( fileName,  optionalEncoding)
          Reads, scans, parses and compiles Java tokens from the named file with the given optionalEncoding.
 void setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
          By default, CompileExceptions 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.
 

Field Detail

BOOT_CLASS_LOADER

static final  BOOT_CLASS_LOADER
The 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  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  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:
, Constant Field Values
Method Detail

setParentClassLoader

void setParentClassLoader( optionalParentClassLoader)
The "parent class loader" is used to load referenced classes. Useful values are:
System.getSystemClassLoader() The running JVM's class path
Thread.currentThread().getContextClassLoader() or null The class loader effective for the invoking thread
BOOT_CLASS_LOADER The running JVM's boot class path
The parent class loader defaults to the current thread's context class loader.


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( optionalFileName,
           r)
          throws CompileException,
                 
Reads, scans, parses and compiles Java tokens from the given .

Parameters:
optionalFileName - Used when reporting errors and warnings.
Throws:
CompileException

cook

void cook( r)
          throws CompileException,
                 
Reads, scans, parses and compiles Java tokens from the given .

Throws:
CompileException

cook

void cook( is)
          throws CompileException,
                 
Reads, scans, parses and compiles Java tokens from the given , encoded in the "platform default encoding".

Throws:
CompileException

cook

void cook( optionalFileName,
           is)
          throws CompileException,
                 
Reads, scans, parses and compiles Java tokens from the given , encoded in the "platform default encoding".

Parameters:
optionalFileName - Used when reporting errors and warnings.
Throws:
CompileException

cook

void cook( is,
           optionalEncoding)
          throws CompileException,
                 
Reads, scans, parses and compiles Java tokens from the given with the given encoding.

Throws:
CompileException

cook

void cook( optionalFileName,
           is,
           optionalEncoding)
          throws CompileException,
                 
Reads, scans, parses and compiles Java tokens from the given with the given encoding.

Parameters:
optionalFileName - Used when reporting errors and warnings.
Throws:
CompileException

cook

void cook( s)
          throws CompileException
Reads, scans, parses and compiles Java tokens from the given .

Throws:
CompileException

cook

void cook( optionalFileName,
           s)
          throws CompileException
Reads, scans, parses and compiles Java tokens from the given .

Parameters:
optionalFileName - Used when reporting errors and warnings.
Throws:
CompileException

cookFile

void cookFile( file)
              throws CompileException,
                     
Reads, scans, parses and compiles Java tokens from the given , encoded in the "platform default encoding".

Throws:
CompileException

cookFile

void cookFile( file,
               optionalEncoding)
              throws CompileException,
                     
Reads, scans, parses and compiles Java tokens from the given with the given encoding.

Throws:
CompileException

cookFile

void cookFile( fileName)
              throws CompileException,
                     
Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".

Throws:
CompileException

cookFile

void cookFile( fileName,
               optionalEncoding)
              throws CompileException,
                     
Reads, scans, parses and compiles Java tokens from the named file with the given optionalEncoding.

Throws:
CompileException

setCompileErrorHandler

void setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
By default, CompileExceptions 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 CompileExceptions, then the compilation is terminated and the exception is propagated.

If the given ErrorHandler does not throw CompileExceptions, 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.

Parameters:
optionalCompileErrorHandler - null to restore the default behavior (throwing a CompileException

setWarningHandler

void setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a custom WarningHandler.

Parameters:
optionalWarningHandler - null to indicate that no warnings be issued

janino.net