|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--edu.mit.ai.psg.jeva.CompileUnit
CompileUnit -- compile a Java compilation unit (i.e., contents of a .java file) in a string.
By default uses access to temporary file space (via
File.createTempFile). To reuse compilations between runs (e.g., while debugging),
call setTempRoot(java.io.File). (This directory should be used only for
compilations, as any source files will be overwritten!)
Currently uses the Sun Java Development Kit JDK1.2 sun.tools.javac compiler (preferrably by including jdk1.2/lib/tools.jar in the classpath, though if not there will try to invoke javac as a process, which requires javac in the command path).
| Inner Class Summary | |
static interface |
CompileUnit.CompilerCommand
interface for invoking compilers using command line arguments |
static class |
CompileUnit.CompilerInOwnProcess
|
static class |
CompileUnit.JavaCInProcess
|
| Field Summary | |
static CompileUnit.CompilerCommand[] |
compilers
CompilerCommands tried in order until one returns rather than throwing an exception. |
static String[] |
javacOptions
command options for java compiler, e.g., new String[]{"-g"} |
static boolean |
suppressClassFileDeletion
Specifies whether or not to delete .class files on exit. |
| Constructor Summary | |
CompileUnit()
|
|
| Method Summary | |
static Class |
compile(String className,
String compilationUnit)
Write compilation unit out to temp, run javac compiler on it, and load className. |
static Class |
compile(String className,
String compilationUnit,
OutputStream outStream,
OutputStream errStream)
Write compilation unit out to temp, run javac compiler on it, and load className. |
static Class |
compileFileInTemp(String className)
Calls compileFileInTemp on class using System.out and System.err |
static Class |
compileFileInTemp(String className,
OutputStream outStream,
OutputStream errStream)
Calls java compiler on file previously written with writeCompilationUnitToTemp(String, String),
adding temp file space to classpath. |
static long |
dateClassInTemp(String className)
may be used to see if a class compiled in a previous session may be reloaded rather than recompiled. |
static Class |
loadClassUsingTemp(String className)
Loads classes from files compiled in temp. |
static void |
setTempRoot(File newTempRoot)
set temp root directory for compilation files |
static void |
writeCompilationUnitToTemp(String className,
String compilationUnit)
Write compilation unit to temp. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static boolean suppressClassFileDeletion
setTempRoot(java.io.File) so .class files may be reused by subsequent
runspublic static String[] javacOptions
new String[]{"-g"}public static CompileUnit.CompilerCommand[] compilers
. new CompilerCommand[]{new JavacInProcess(),
. new CompilerInOwnProcess("javac")};
(tries in-process first [faster]).| Constructor Detail |
public CompileUnit()
| Method Detail |
public static Class compile(String className,
String compilationUnit)
className - full class name of class (e.g., myOrg.myPkg.MyClass)compilationUnit - java source code for class,
(e.g., contents of its .java file)
public static Class compile(String className,
String compilationUnit,
OutputStream outStream,
OutputStream errStream)
className - full class name of class (e.g., myOrg.myPkg.MyClass)compilationUnit - java source code for class,
(e.g., contents of its .java file)outStream - output stream for compiler messageserrStream - output stream for compiler messages
public static void writeCompilationUnitToTemp(String className,
String compilationUnit)
File.createTempFile(String, String, File) unless other location
is specified by setTempRoot(java.io.File).) Used for writing
out multiple compilation units that depend on each other before
compiling one.className - full class name of class (e.g., myOrg.myPkg.MyClass)compilationUnit - java source code for class,
(e.g., contents of its .java file)public static Class compileFileInTemp(String className)
public static Class compileFileInTemp(String className,
OutputStream outStream,
OutputStream errStream)
writeCompilationUnitToTemp(String, String),
adding temp file space to classpath.
Tries compilers in order until one is accessible and
reports success or failure. For each compiler,
supplies arguments javacOptions -classpath
classPath, where classPath is from
System.getProperty("java.class.path")
augmented with tempRoot.className - full class name of previously written compilation unit
to compile.outStream - output stream for compiler messageserrStream - output stream for compiler messagespublic static Class loadClassUsingTemp(String className)
Class.forName(String)public static long dateClassInTemp(String className)
File.lastModified()public static void setTempRoot(File newTempRoot)
|
Copyright (c) 1996-1999 Massachusetts Institute of Technology Feedback: jeva-feedback@ai.mit.edu |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||