com.caucho.java
Class JavaCompilerUtil

java.lang.Object
  extended by com.caucho.java.JavaCompilerUtil

public class JavaCompilerUtil
extends java.lang.Object

Compiles Java source, returning the loaded class.


Field Summary
protected  java.util.ArrayList<java.lang.String> _args
           
protected  java.lang.String _charEncoding
           
protected  long _maxCompileTime
           
 
Method Summary
 void compile(java.lang.String fileName, LineMap lineMap)
          Compiles the class.
 void compile(java.lang.String fileName, LineMap lineMap, boolean ifModified)
          Compiles the class.
 void compileBatch(java.lang.String[] files)
          Compiles a batch list of classes.
 void compileIfModified(java.lang.String fileName, LineMap lineMap)
          Compiles the class.
protected  void compileInt(java.lang.String[] path, LineMap lineMap)
           
static JavaCompilerUtil create()
          Creates a new compiler.
static JavaCompilerUtil create(java.lang.ClassLoader loader)
          Creates a new compiler.
 java.util.ArrayList<java.lang.String> getArgs()
          Returns the ArrayList of arguments.
 java.lang.ClassLoader getClassLoader()
          Sets the class loader used to load the compiled class and to grab the classpath from.
 java.lang.String getClassPath()
          Returns the classpath.
 java.lang.String getCompiler()
          Gets the compiler name, e.g.
 java.lang.String getEncoding()
          Returns the encoding.
 long getMaxCompileTime()
          Returns the maximum time allowed for an external compilation.
 Path getSourceDir()
          Returns the directory where compiled classes go.
 java.lang.String getSourceExtension()
          Gets the source extension.
static java.lang.String mangleName(java.lang.String name)
          Mangles the path into a valid Java class name.
 void mergeSmap(Path classPath, Path smapPath)
           
 void setArgs(java.util.ArrayList<java.lang.String> args)
           
 void setArgs(java.lang.String argString)
          Sets any additional arguments for the compiler.
 void setClassDir(Path path)
          Sets the directory where compiled classes go.
 void setClassLoader(java.lang.ClassLoader loader)
          Sets the class loader used to load the compiled class and to grab the classpath from.
 void setClassPath(java.lang.String classPath)
          Sets the class path for compilation.
 void setCompileParent(boolean compileParent)
           
 void setCompiler(java.lang.String compiler)
          Sets the compiler name, e.g.
 void setEncoding(java.lang.String encoding)
          Sets the Java encoding for the compiler.
 void setExtraClassPath(java.lang.String classPath)
          Sets an extra class path for compilation.
 void setMaxBatch(int maxBatch)
          Sets the maximum time allowed for an external compilation.
 void setMaxCompileTime(long maxCompileTime)
          Sets the maximum time allowed for an external compilation.
 void setSourceDir(Path path)
          Sets the directory the java source comes from.
 void setSourceExtension(java.lang.String ext)
          Sets the source extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_charEncoding

protected java.lang.String _charEncoding

_args

protected java.util.ArrayList<java.lang.String> _args

_maxCompileTime

protected long _maxCompileTime
Method Detail

create

public static JavaCompilerUtil create()
Creates a new compiler.


create

public static JavaCompilerUtil create(java.lang.ClassLoader loader)
Creates a new compiler.

Parameters:
loader - the parent class loader for the compiler.

setClassLoader

public void setClassLoader(java.lang.ClassLoader loader)
Sets the class loader used to load the compiled class and to grab the classpath from.


getClassLoader

public java.lang.ClassLoader getClassLoader()
Sets the class loader used to load the compiled class and to grab the classpath from.


setCompiler

public void setCompiler(java.lang.String compiler)
Sets the compiler name, e.g. jikes.


getCompiler

public java.lang.String getCompiler()
Gets the compiler name, e.g. jikes.


setClassDir

public void setClassDir(Path path)
Sets the directory where compiled classes go.

Parameters:
path - representing the class dir.

setSourceDir

public void setSourceDir(Path path)
Sets the directory the java source comes from.

Parameters:
path - representing the source dir.

getSourceDir

public Path getSourceDir()
Returns the directory where compiled classes go.


setSourceExtension

public void setSourceExtension(java.lang.String ext)
Sets the source extension.


getSourceExtension

public java.lang.String getSourceExtension()
Gets the source extension.


setClassPath

public void setClassPath(java.lang.String classPath)
Sets the class path for compilation. Normally, the classpath from the class loader will be sufficient.


setExtraClassPath

public void setExtraClassPath(java.lang.String classPath)
Sets an extra class path for compilation.


setCompileParent

public void setCompileParent(boolean compileParent)

getClassPath

public java.lang.String getClassPath()
Returns the classpath.


setArgs

public void setArgs(java.lang.String argString)
Sets any additional arguments for the compiler.


getArgs

public java.util.ArrayList<java.lang.String> getArgs()
Returns the ArrayList of arguments.


setEncoding

public void setEncoding(java.lang.String encoding)
Sets the Java encoding for the compiler.


getEncoding

public java.lang.String getEncoding()
Returns the encoding.


getMaxCompileTime

public long getMaxCompileTime()
Returns the maximum time allowed for an external compilation.


setMaxCompileTime

public void setMaxCompileTime(long maxCompileTime)
Sets the maximum time allowed for an external compilation.


setMaxBatch

public void setMaxBatch(int maxBatch)
Sets the maximum time allowed for an external compilation.


mangleName

public static java.lang.String mangleName(java.lang.String name)
Mangles the path into a valid Java class name.


setArgs

public void setArgs(java.util.ArrayList<java.lang.String> args)

compile

public void compile(java.lang.String fileName,
                    LineMap lineMap)
             throws java.io.IOException,
                    java.lang.ClassNotFoundException
Compiles the class. className is a fully qualified Java class, e.g. work.jsp.Test

Parameters:
fileName - Java source name -- in VFS format
lineMap - mapping from generated class back to the source class
Throws:
java.io.IOException
java.lang.ClassNotFoundException

compileIfModified

public void compileIfModified(java.lang.String fileName,
                              LineMap lineMap)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
Compiles the class. className is a fully qualified Java class, e.g. work.jsp.Test

Parameters:
fileName - Java source name -- in VFS format
lineMap - mapping from generated class back to the source class
Throws:
java.io.IOException
java.lang.ClassNotFoundException

compile

public void compile(java.lang.String fileName,
                    LineMap lineMap,
                    boolean ifModified)
             throws java.io.IOException,
                    java.lang.ClassNotFoundException
Compiles the class. className is a fully qualified Java class, e.g. work.jsp.Test

Parameters:
fileName - Java source name -- in VFS format
lineMap - mapping from generated class back to the source class
ifModified - compile only if the *.java is modified
Throws:
java.io.IOException
java.lang.ClassNotFoundException

compileBatch

public void compileBatch(java.lang.String[] files)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Compiles a batch list of classes.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

compileInt

protected void compileInt(java.lang.String[] path,
                          LineMap lineMap)
                   throws java.io.IOException,
                          JavaCompileException
Throws:
java.io.IOException
JavaCompileException

mergeSmap

public void mergeSmap(Path classPath,
                      Path smapPath)