|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.ClassLoader jodd.util.JavaSourceClassLoader
public class JavaSourceClassLoader
A ClassLoader
that, unlike usual class loaders,
does not load byte code, but reads JavaTM source code and then scans, parses,
compiles and loads it into the virtual machine.
It requires a root source folder. When a class is required, JavaSourceClassLoader
will first check if source is available. If source exists, it will be compiled with current
classpath. If source doesn't exist, or if it is one of the system classes, class will be
loaded with the parent classloader.
JavaSourceClassLoader
may work in two ways:
RuntimeJavaSourceLoader
Field Summary | |
---|---|
protected boolean |
aggressive
|
protected java.util.Map<java.lang.String,java.lang.Class> |
classBuffer
|
protected boolean |
debugInfo
|
protected java.lang.String |
destinationFolder
|
protected java.lang.String |
encoding
|
protected java.lang.String |
sourceFolder
|
static java.lang.String[] |
SYSTEM_CLASSES
Prefixes for system classes that should be always loaded by parent constructor. |
Constructor Summary | |
---|---|
JavaSourceClassLoader(java.lang.ClassLoader parent,
java.lang.String sourceFolder,
boolean aggressive)
|
|
JavaSourceClassLoader(java.lang.String sourceFolder,
boolean aggressive)
|
Method Summary | |
---|---|
java.lang.Class |
compileAndLoadClass(java.lang.String className)
|
java.lang.Class |
compileAndLoadClass(java.lang.String className,
boolean resolveIt)
Compiles and then loads the class with the specified name. |
int |
compileClass(java.lang.String className)
Compiles java source file. |
java.lang.String |
getDestinationFolder()
|
java.lang.String |
getEncoding()
|
boolean |
isClassAlreadyLoaded(java.lang.String className)
Returns true if this classloader has already loaded a class
with provided name. |
boolean |
isDebugInfo()
|
java.lang.Class<?> |
loadClass(java.lang.String className)
|
protected java.lang.Class<?> |
loadClass(java.lang.String className,
boolean resolve)
Loads the class with the specified name. |
java.lang.Class |
readAndDefineClass(java.lang.String className)
Reads compiled class bytes and defines a class. |
void |
setDebugInfo(boolean debugInfo)
|
void |
setDestinationFolder(java.lang.String destinationFolder)
|
void |
setEncoding(java.lang.String encoding)
|
Methods inherited from class java.lang.ClassLoader |
---|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String[] SYSTEM_CLASSES
protected final java.lang.String sourceFolder
protected java.lang.String destinationFolder
protected boolean debugInfo
protected java.lang.String encoding
protected final boolean aggressive
protected java.util.Map<java.lang.String,java.lang.Class> classBuffer
Constructor Detail |
---|
public JavaSourceClassLoader(java.lang.String sourceFolder, boolean aggressive)
public JavaSourceClassLoader(java.lang.ClassLoader parent, java.lang.String sourceFolder, boolean aggressive)
Method Detail |
---|
public java.lang.String getDestinationFolder()
public void setDestinationFolder(java.lang.String destinationFolder)
public boolean isDebugInfo()
public void setDebugInfo(boolean debugInfo)
public java.lang.String getEncoding()
public void setEncoding(java.lang.String encoding)
public boolean isClassAlreadyLoaded(java.lang.String className)
true
if this classloader has already loaded a class
with provided name.
public java.lang.Class<?> loadClass(java.lang.String className) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
protected java.lang.Class<?> loadClass(java.lang.String className, boolean resolve) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
compileAndLoadClass(String, boolean)
public java.lang.Class compileAndLoadClass(java.lang.String className) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public java.lang.Class compileAndLoadClass(java.lang.String className, boolean resolveIt) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
loadClass(String, boolean)
public int compileClass(java.lang.String className) throws java.io.FileNotFoundException
java.io.FileNotFoundException
- if class source file doesn't exist (indicates that class might be loaded with next classloader in chain)public java.lang.Class readAndDefineClass(java.lang.String className) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |