final class ExpressionClassLoader
extends java.lang.ClassLoader
ClassLoader
to enable the loading of
a class file stored as a byte array in memory. When a class file is
generated by the expression compiler, it should be stored under its
fully qualified class name using the putClassFile()
method. When the class is subsequently loaded, the ClassFile
is retrieved and removed from this temporary cache, and the
byte array representing the class file is used to load the class
into the JVM.Modifier and Type | Field and Description |
---|---|
private java.util.Map |
cache
Cache of classes already loaded by this class loader.
|
private java.util.Map |
dataMap
Cache of class files created by expression compiler.
|
Constructor and Description |
---|
ExpressionClassLoader() |
Modifier and Type | Method and Description |
---|---|
private byte[] |
getClassData(java.lang.String name)
This method is used to retrieve the byte array containing the class
file information for the class with the specified name.
|
protected java.lang.Class |
loadClass(java.lang.String name,
boolean resolve)
This method is called by the JVM when the class with the specified
name is referenced and needs to be loaded.
|
(package private) void |
putClassFile(java.lang.String name,
ClassFile file)
This method should be called by the class file compiler to
temporarily cache a compiled class in the form of a
ClassFile
instance. |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
private java.util.Map cache
private java.util.Map dataMap
void putClassFile(java.lang.String name, ClassFile file)
ClassFile
instance. This object will be retrieved subsequently and
removed from this cache when it is necessary to load the class into
the JVM.name
- Fully qualified name of the class to be cached.file
- ClassFile object to cache temporarily.private byte[] getClassData(java.lang.String name)
name
- Fully qualified name of class for which the class file
information byte array is required.name
.protected java.lang.Class loadClass(java.lang.String name, boolean resolve) throws java.lang.ClassNotFoundException
name
refers to a system class. If this load fails, an attempt
is then made to find the class in the cache maintained by this class
loader. If the class is not found in the cache, a lookup is
performed to find the byte array containing the class file information
for the class identified by name
, and this byte array is
used to define the class.loadClass
in class java.lang.ClassLoader
name
- Fully qualified name of the class to be loaded.resolve
- True if class should be resolved, else false.Class
object identified by name
.java.lang.ClassNotFoundException
- If no class can be found for the specified name.