Web Site

org.codehaus.janino
Class UnitCompiler

java.lang.Object
  extended byorg.codehaus.janino.UnitCompiler

public class UnitCompiler
extends Object

This class actually implements the JavaTM compiler. It is associated with exactly one compilation unit which it compiles.


Nested Class Summary
static interface UnitCompiler.ErrorHandler
          Interface type for setCompileErrorHandler(org.codehaus.janino.UnitCompiler.ErrorHandler).
static class UnitCompiler.SimpleIField
          Short-hand implementation of IClass.IField that implements a non-constant, non-static, package-accessible field.
 
Constructor Summary
UnitCompiler(Java.CompilationUnit compilationUnit, IClassLoader iClassLoader)
           
 
Method Summary
 void compile2(Java.AnonymousClassDeclaration acd)
           
 void compile2(Java.ClassDeclaration cd)
           
 void compile2(Java.InterfaceDeclaration id)
           
 void compile2(Java.LocalClassDeclaration lcd)
           
 void compile2(Java.MemberClassDeclaration mcd)
           
 ClassFile[] compileUnit(DebuggingInformation debuggingInformation)
          Generates an array of ClassFile objects which represent the classes and interfaces defined in the compilation unit.
 IClass findClass(String className)
          Find one class or interface by name.
 boolean generatesCode2(Java.Block b)
           
 boolean generatesCode2(Java.BlockStatement bs)
           
 boolean generatesCode2(Java.EmptyStatement es)
           
 boolean generatesCode2(Java.FieldDeclarator fd)
           
 boolean generatesCode2(Java.Initializer i)
           
 boolean generatesCode2(Java.LocalClassDeclarationStatement lcds)
           
 CodeContext.Offset getWhereToBreak(Java.BreakableStatement bs)
           
 IClass importTypeOnDemand(String simpleTypeName, Location location)
          6.5.2.BL1.B1.B5, 6.5.2.BL1.B1.B6 Type-import-on-demand.
6.5.5.1.6 Type-import-on-demand declaration.
 void leave2(Java.BlockStatement bs, IClass optionalStackValueType)
           
 void leave2(Java.SynchronizedStatement ss, IClass optionalStackValueType)
           
 void leave2(Java.TryStatement ts, IClass optionalStackValueType)
           
 void setCompileErrorHandler(UnitCompiler.ErrorHandler errorHandler)
          By default, CompileExceptions are thrown on compile errors, but an application my install its own (thread-local) UnitCompiler.ErrorHandler.
 void setWarningHandler(WarningHandler warningHandler)
          By default, warnings are discarded, but an application my install a (thread-local) WarningHandler.
 IClass.IMethod toIMethod(Java.MethodDeclarator md)
           
 Java.Lvalue toLvalueOrCE(Java.Atom a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitCompiler

public UnitCompiler(Java.CompilationUnit compilationUnit,
                    IClassLoader iClassLoader)
Method Detail

compileUnit

public ClassFile[] compileUnit(DebuggingInformation debuggingInformation)
                        throws CompileException
Generates an array of ClassFile objects which represent the classes and interfaces defined in the compilation unit.

Throws:
CompileException

compile2

public void compile2(Java.ClassDeclaration cd)
              throws CompileException
Throws:
CompileException

compile2

public void compile2(Java.AnonymousClassDeclaration acd)
              throws CompileException
Throws:
CompileException

compile2

public void compile2(Java.LocalClassDeclaration lcd)
              throws CompileException
Throws:
CompileException

compile2

public void compile2(Java.MemberClassDeclaration mcd)
              throws CompileException
Throws:
CompileException

compile2

public void compile2(Java.InterfaceDeclaration id)
              throws CompileException
Throws:
CompileException

generatesCode2

public boolean generatesCode2(Java.BlockStatement bs)

generatesCode2

public boolean generatesCode2(Java.EmptyStatement es)

generatesCode2

public boolean generatesCode2(Java.LocalClassDeclarationStatement lcds)

generatesCode2

public boolean generatesCode2(Java.Initializer i)
                       throws CompileException
Throws:
CompileException

generatesCode2

public boolean generatesCode2(Java.Block b)
                       throws CompileException
Throws:
CompileException

generatesCode2

public boolean generatesCode2(Java.FieldDeclarator fd)
                       throws CompileException
Throws:
CompileException

leave2

public void leave2(Java.BlockStatement bs,
                   IClass optionalStackValueType)

leave2

public void leave2(Java.SynchronizedStatement ss,
                   IClass optionalStackValueType)

leave2

public void leave2(Java.TryStatement ts,
                   IClass optionalStackValueType)

toLvalueOrCE

public final Java.Lvalue toLvalueOrCE(Java.Atom a)
                               throws CompileException
Throws:
CompileException

toIMethod

public IClass.IMethod toIMethod(Java.MethodDeclarator md)

importTypeOnDemand

public IClass importTypeOnDemand(String simpleTypeName,
                                 Location location)
                          throws CompileException
6.5.2.BL1.B1.B5, 6.5.2.BL1.B1.B6 Type-import-on-demand.
6.5.5.1.6 Type-import-on-demand declaration.

Returns:
null if the given simpleTypeName cannot be resolved through any of the import-on-demand directives
Throws:
CompileException

findClass

public IClass findClass(String className)
Find one class or interface by name.

Parameters:
className - Fully qualified class name, e.g. "pkg1.pkg2.Outer$Inner".
Returns:
null if a class with that name is not declared in this compilation unit

setCompileErrorHandler

public void setCompileErrorHandler(UnitCompiler.ErrorHandler errorHandler)
By default, CompileExceptions are thrown on compile errors, but an application my install its own (thread-local) UnitCompiler.ErrorHandler.

Be aware that a single problem during compilation often causes a bunch of compile errors, so a good UnitCompiler.ErrorHandler counts errors and throws a CompileException when a limit is reached.


setWarningHandler

public void setWarningHandler(WarningHandler warningHandler)
By default, warnings are discarded, but an application my install a (thread-local) WarningHandler.


getWhereToBreak

public CodeContext.Offset getWhereToBreak(Java.BreakableStatement bs)

Web Site