|
janino.net | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.ClassLoader
org.codehaus.commons.compiler.AbstractJavaSourceClassLoader
org.codehaus.janino.JavaSourceClassLoader
public class JavaSourceClassLoader
A ClassLoader that, unlike usual ClassLoaders,
does not load byte code, but reads Java™ source code and then scans, parses,
compiles and loads it into the virtual machine.
As with any ClassLoader, it is not possible to "update" classes after they've been
loaded. The way to achieve this is to give up on the JavaSourceClassLoader and create
a new one.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.codehaus.commons.compiler.AbstractJavaSourceClassLoader |
|---|
AbstractJavaSourceClassLoader.ProtectionDomainFactory |
| Field Summary |
|---|
| Fields inherited from class org.codehaus.commons.compiler.AbstractJavaSourceClassLoader |
|---|
optionalProtectionDomainFactory |
| Constructor Summary | |
|---|---|
JavaSourceClassLoader()
|
|
JavaSourceClassLoader(ClassLoader parentClassLoader)
|
|
JavaSourceClassLoader(ClassLoader parentClassLoader,
File[] optionalSourcePath,
String optionalCharacterEncoding)
Set up a JavaSourceClassLoader that finds Java™ source code in a file that resides in either of
the directories specified by the given source path. |
|
JavaSourceClassLoader(ClassLoader parentClassLoader,
JavaSourceIClassLoader iClassLoader)
Constructs a JavaSourceClassLoader that finds classes through an JavaSourceIClassLoader. |
|
JavaSourceClassLoader(ClassLoader parentClassLoader,
ResourceFinder sourceFinder,
String optionalCharacterEncoding)
Constructs a JavaSourceClassLoader that finds Java™ source code through a given ResourceFinder. |
|
| Method Summary | |
|---|---|
protected Class |
findClass(String name)
Implementation of ClassLoader.findClass(String). |
protected Map<String,byte[]> |
generateBytecodes(String name)
Find, scan, parse the right compilation unit. |
void |
setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
|
void |
setDebuggingInfo(boolean debugSource,
boolean debugLines,
boolean debugVars)
|
void |
setSourceFileCharacterEncoding(String optionalCharacterEncoding)
|
void |
setSourcePath(File[] sourcePath)
|
void |
setWarningHandler(WarningHandler optionalWarningHandler)
|
| Methods inherited from class org.codehaus.commons.compiler.AbstractJavaSourceClassLoader |
|---|
main, setProtectionDomainFactory |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JavaSourceClassLoader()
public JavaSourceClassLoader(ClassLoader parentClassLoader)
public JavaSourceClassLoader(ClassLoader parentClassLoader,
File[] optionalSourcePath,
String optionalCharacterEncoding)
JavaSourceClassLoader that finds Java™ source code in a file that resides in either of
the directories specified by the given source path.
parentClassLoader - See ClassLoaderoptionalSourcePath - A collection of directories that are searched for Java™ source files in
the given orderoptionalCharacterEncoding - The encoding of the Java™ source files (null for platform
default encoding)
public JavaSourceClassLoader(ClassLoader parentClassLoader,
ResourceFinder sourceFinder,
String optionalCharacterEncoding)
JavaSourceClassLoader that finds Java™ source code through a given ResourceFinder.
You can specify to include certain debugging information in the generated class files, which
is useful if you want to debug through the generated classes (see
Scanner.Scanner(String, Reader)).
parentClassLoader - See ClassLoadersourceFinder - Used to locate additional source filesoptionalCharacterEncoding - The encoding of the Java™ source files (null for platform
default encoding)
public JavaSourceClassLoader(ClassLoader parentClassLoader,
JavaSourceIClassLoader iClassLoader)
JavaSourceClassLoader that finds classes through an JavaSourceIClassLoader.
| Method Detail |
|---|
public void setSourcePath(File[] sourcePath)
setSourcePath in class AbstractJavaSourceClassLoadersourcePath - The sequence of directories to search for Java™ source filespublic void setSourceFileCharacterEncoding(String optionalCharacterEncoding)
setSourceFileCharacterEncoding in class AbstractJavaSourceClassLoaderoptionalCharacterEncoding - if null, use platform default encoding
public void setDebuggingInfo(boolean debugSource,
boolean debugLines,
boolean debugVars)
setDebuggingInfo in class AbstractJavaSourceClassLoaderdebugSource - Whether line number debugging information should be generateddebugLines - Whether variables debugging information should be generateddebugVars - Whether source file debugging information should be generatedpublic void setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
UnitCompiler.setCompileErrorHandler(org.codehaus.commons.compiler.ErrorHandler)public void setWarningHandler(WarningHandler optionalWarningHandler)
Parser.setWarningHandler(WarningHandler),
UnitCompiler.setCompileErrorHandler(org.codehaus.commons.compiler.ErrorHandler)
protected Class findClass(String name)
throws ClassNotFoundException
ClassLoader.findClass(String).
findClass in class ClassLoaderClassNotFoundException
protected Map<String,byte[]> generateBytecodes(String name)
throws ClassNotFoundException
null if no source code could be found
ClassNotFoundException - on compilation problems
|
janino.net | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||