org.codehaus.janino
public class SimpleCompiler extends Cookable
Opposed to a normal ".java" file, you can declare multiple public classes here.
To set up a SimpleCompiler object, proceed as follows:
Field Summary | |
---|---|
static ClassLoader | BOOT_CLASS_LOADER
A ClassLoader that finds the classes on the JVM's boot class path (e.g.
|
Constructor Summary | |
---|---|
SimpleCompiler(String optionalFileName, Reader in)
Equivalent to SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, in); | |
SimpleCompiler(String optionalFileName, InputStream is)
Equivalent to SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, is); | |
SimpleCompiler(String fileName)
Equivalent to SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName); | |
SimpleCompiler(Scanner scanner, ClassLoader optionalParentClassLoader)
Equivalent to SimpleCompiler sc = new SimpleCompiler(); sc.setParentClassLoader(optionalParentClassLoader); sc.cook(scanner); | |
SimpleCompiler() |
Method Summary | |
---|---|
protected void | assertNotCooked()
Throw an IllegalStateException if this Cookable is already cooked. |
protected Java.Type[] | classesToTypes(Location location, Class[] classes)
Convert an array of Classes into an array ofTypes. |
protected Java.Type | classToType(Location location, Class optionalClass)
Wrap a reflection Class in a Type object. |
protected ClassLoader | compileToClassLoader(Java.CompilationUnit compilationUnit, EnumeratorSet debuggingInformation)
Compile the given compilation unit. |
void | cook(Scanner scanner) |
void | cook(Java.CompilationUnit compilationUnit)
Cook this compilation unit directly.
|
boolean | equals(Object o)
Two SimpleCompilers are regarded equal iff
|
ClassLoader | getClassLoader()
Returns a ClassLoader object through which the previously compiled classes can
be accessed. |
int | hashCode() |
static void | main(String[] args) |
void | setParentClassLoader(ClassLoader optionalParentClassLoader)
The "parent class loader" is used to load referenced classes. |
void | setParentClassLoader(ClassLoader optionalParentClassLoader, Class[] auxiliaryClasses)
Allow references to the classes loaded through this parent class loader
(@see setParentClassLoader), plus the extra
auxiliaryClasses .
|
protected void | setUpClassLoaders()
Initializes classLoader and iClassLoader from the configured
parentClassLoader and optionalAuxiliaryClasses. |
java.io.*
), but not the classes on the JVM's class path.SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, in);
See Also: SimpleCompiler Cookable
SimpleCompiler sc = new SimpleCompiler(); sc.cook(optionalFileName, is);
See Also: SimpleCompiler Cookable
SimpleCompiler sc = new SimpleCompiler(); sc.cook(fileName);
See Also: SimpleCompiler cookFile
SimpleCompiler sc = new SimpleCompiler(); sc.setParentClassLoader(optionalParentClassLoader); sc.cook(scanner);
See Also: SimpleCompiler setParentClassLoader cook
Parameters: compilationUnit The parsed compilation unit debuggingInformation What kind of debugging information to generate in the class file
Returns: The ClassLoader into which the compiled classes were defined
Throws: CompileException
This method must only be called after cook.
This method must not be called for instances of derived classes.
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 |
auxiliaryClasses
.
Notice that the auxiliaryClasses
must either be loadable through the
optionalParentClassLoader
(in which case they have no effect), or
no class with the same name must be loadable through the
optionalParentClassLoader
.