private class Compiler.CompilerIClassLoader extends IClassLoader
IClassLoader that loads IClasses from the following
sources:
Compiler.CompilerIClassLoader is an inner class of Compiler and
heavily uses Compiler's members.| Modifier and Type | Field and Description |
|---|---|
private ResourceFinder |
sourceFinder |
ANNO_java_lang_Override, CTOR_java_lang_StringBuilder__java_lang_String, METH_java_lang_Iterable__iterator, METH_java_lang_String__concat__java_lang_String, METH_java_lang_String__valueOf__boolean, METH_java_lang_String__valueOf__char, METH_java_lang_String__valueOf__double, METH_java_lang_String__valueOf__float, METH_java_lang_String__valueOf__int, METH_java_lang_String__valueOf__java_lang_Object, METH_java_lang_String__valueOf__long, METH_java_lang_StringBuilder__append__java_lang_String, METH_java_lang_StringBuilder__toString, METH_java_util_Iterator__hasNext, METH_java_util_Iterator__next, TYPE_java_io_Serializable, TYPE_java_lang_AssertionError, TYPE_java_lang_Boolean, TYPE_java_lang_Byte, TYPE_java_lang_Character, TYPE_java_lang_Class, TYPE_java_lang_Cloneable, TYPE_java_lang_Double, TYPE_java_lang_Error, TYPE_java_lang_Exception, TYPE_java_lang_Float, TYPE_java_lang_Integer, TYPE_java_lang_Iterable, TYPE_java_lang_Long, TYPE_java_lang_Object, TYPE_java_lang_RuntimeException, TYPE_java_lang_Short, TYPE_java_lang_String, TYPE_java_lang_StringBuilder, TYPE_java_lang_Throwable, TYPE_java_util_Iterator| Constructor and Description |
|---|
CompilerIClassLoader(ResourceFinder sourceFinder,
IClassLoader optionalParentIClassLoader) |
| Modifier and Type | Method and Description |
|---|---|
private IClass |
defineIClassFromClassFileResource(Resource classFileResource)
Open the given
classFileResource, read its contents, define it in the
IClassLoader, and resolve it (this step may involve loading more classes). |
private IClass |
defineIClassFromSourceResource(Resource sourceResource,
java.lang.String className)
Parse the compilation unit stored in the given
sourceResource, remember it in
Compiler.this.parsedCompilationUnits (it may declare other classes that
are needed later), find the declaration of the type with the given
className, and define it in the IClassLoader. |
protected IClass |
findIClass(java.lang.String type)
|
createJavacLikePathIClassLoader, defineIClass, loadIClass, postConstructprivate final ResourceFinder sourceFinder
public CompilerIClassLoader(ResourceFinder sourceFinder, IClassLoader optionalParentIClassLoader)
sourceFinder - Where to look for source filesoptionalParentIClassLoader - IClassLoader through which IClasses are to be loadedprotected IClass findIClass(java.lang.String type) throws java.lang.ClassNotFoundException
IClassLoaderIClass by descriptor; return null if a class
for that descriptor could not be found.
Similar ClassLoader.findClass(java.lang.String), this method
must
IClass object from somewhere for the given type
IClassLoader.defineIClass(IClass) with that IClass object as
the argument
IClass object
The format of a descriptor is defined in JVMS 4.3.2. Typical
descriptors are:
I (Integer)
Lpkg1/pkg2/Cls; (Class declared in package)
Lpkg1/pkg2/Outer$Inner; Member class
Notice that this method is never called from more than one thread at a time. In other words, implementations of this method need not be synchronized.
findIClass in class IClassLoadertype - field descriptor of the to load, e.g. "Lpkg1/pkg2/Outer$Inner;"null if a the type could not be foundjava.lang.ClassNotFoundException - if an exception was raised while loading the IClassprivate IClass defineIClassFromSourceResource(Resource sourceResource, java.lang.String className) throws java.lang.ClassNotFoundException
sourceResource, remember it in
Compiler.this.parsedCompilationUnits (it may declare other classes that
are needed later), find the declaration of the type with the given
className, and define it in the IClassLoader.
Notice that the CU is not compiled here!
java.lang.ClassNotFoundExceptionprivate IClass defineIClassFromClassFileResource(Resource classFileResource) throws java.lang.ClassNotFoundException
classFileResource, read its contents, define it in the
IClassLoader, and resolve it (this step may involve loading more classes).java.lang.ClassNotFoundException