Package org.codehaus.janino
Class IClassLoader
java.lang.Object
org.codehaus.janino.IClassLoader
- Direct Known Subclasses:
ClassLoaderIClassLoader
,JavaSourceIClassLoader
,ResourceFinderIClassLoader
Loads an
IClass
by type name.-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IClassLoader
createJavacLikePathIClassLoader
(File[] optionalBootClassPath, File[] optionalExtDirs, File[] classPath) Create anIClassLoader
that looks for classes in the given "boot class path", then in the given "extension directories", and then in the given "class path".protected final void
defineIClass
(IClass iClass) Define anIClass
in the context of thisIClassLoader
.protected abstract IClass
findIClass
(String descriptor) final IClass
loadIClass
(String fieldDescriptor) Get anIClass
by field descriptor.protected final void
This method must be called by the constructor of the directly derived class.
-
Field Details
-
JAVA_LANG_OBJECT
-
JAVA_LANG_STRING
-
JAVA_LANG_CLASS
-
JAVA_LANG_THROWABLE
-
JAVA_LANG_RUNTIMEEXCEPTION
-
JAVA_LANG_ERROR
-
JAVA_LANG_CLONEABLE
-
JAVA_LANG_ASSERTIONERROR
-
JAVA_LANG_OVERRIDE
-
JAVA_IO_SERIALIZABLE
-
JAVA_LANG_BOOLEAN
-
JAVA_LANG_BYTE
-
JAVA_LANG_CHARACTER
-
JAVA_LANG_SHORT
-
JAVA_LANG_INTEGER
-
JAVA_LANG_LONG
-
JAVA_LANG_FLOAT
-
JAVA_LANG_DOUBLE
-
-
Constructor Details
-
IClassLoader
-
-
Method Details
-
postConstruct
protected final void postConstruct()This method must be called by the constructor of the directly derived class. (The reason being is that this method invokes abstractloadIClass(String)
which will not work until the implementing class is constructed.) -
loadIClass
Get anIClass
by field descriptor.- Parameters:
fieldDescriptor
- E.g. 'Lpkg1/pkg2/Outer$Inner;'- Returns:
null
if anIClass
could not be loaded- Throws:
ClassNotFoundException
- An exception was raised while loading theIClass
-
findIClass
Find a newIClass
by descriptor; returnnull
if a class for thatdescriptor
could not be found.Similar
ClassLoader.findClass(java.lang.String)
, this method must- Get an
IClass
object from somewhere for the given type - Call
defineIClass(IClass)
with thatIClass
object as the argument - Return the
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.
- Returns:
null
if a class with that descriptor could not be found- Throws:
ClassNotFoundException
- if an exception was raised while loading the class
- Get an
-
defineIClass
Define anIClass
in the context of thisIClassLoader
. If anIClass
with that descriptor already exists, aRuntimeException
is thrown.This method should only be called from an implementation of
findIClass(String)
.- Throws:
RuntimeException
- A differentIClass
object is already defined for this type
-
createJavacLikePathIClassLoader
public static IClassLoader createJavacLikePathIClassLoader(File[] optionalBootClassPath, File[] optionalExtDirs, File[] classPath) Create anIClassLoader
that looks for classes in the given "boot class path", then in the given "extension directories", and then in the given "class path".The default for the
optionalBootClassPath
is the path defined in the system property "sun.boot.class.path", and the default for theoptionalExtensionDirs
is the path defined in the "java.ext.dirs" system property.
-