Class JavaSourceIClassLoader
java.lang.Object
org.codehaus.janino.IClassLoader
org.codehaus.janino.JavaSourceIClassLoader
This
IClassLoader finds, scans and parses compilation units.
Notice that it does not compile them!
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ErrorHandlerprivate static final Loggerprivate EnumSet<JaninoOption> private Charsetprivate ResourceFinderprivate intprivate intprivate final Set<UnitCompiler> Collection of parsed compilation units.private WarningHandlerFields inherited from class IClassLoader
CTOR_java_lang_StringBuilder__java_lang_String, METH_java_lang_Enum__ordinal, METH_java_lang_Iterable__iterator, METH_java_lang_String__concat__java_lang_String, METH_java_lang_String__equals__java_lang_Object, METH_java_lang_String__hashCode, 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__boolean, METH_java_lang_StringBuilder__append__char, METH_java_lang_StringBuilder__append__double, METH_java_lang_StringBuilder__append__float, METH_java_lang_StringBuilder__append__int, METH_java_lang_StringBuilder__append__java_lang_Object, METH_java_lang_StringBuilder__append__java_lang_String, METH_java_lang_StringBuilder__append__long, METH_java_lang_StringBuilder__toString, METH_java_lang_Throwable__addSuppressed, METH_java_util_Iterator__hasNext, METH_java_util_Iterator__next, TYPE_java_io_Serializable, TYPE_java_lang_annotation_Retention, 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_Enum, 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_Override, TYPE_java_lang_RuntimeException, TYPE_java_lang_Short, TYPE_java_lang_String, TYPE_java_lang_StringBuilder, TYPE_java_lang_System, TYPE_java_lang_Throwable, TYPE_java_lang_Void, TYPE_java_util_Iterator -
Constructor Summary
ConstructorsConstructorDescriptionJavaSourceIClassLoader(ResourceFinder sourceFinder, String sourceCharsetName, IClassLoader parentIClassLoader) -
Method Summary
Modifier and TypeMethodDescriptionprotected Java.AbstractCompilationUnitfindCompilationUnit(String className) Finds the Java source file for the named class through the configured 'source resource finder' and parses it.findIClass(String fieldDescriptor) Finds a newIClassby descriptor and callsIClassLoader.defineIClass(IClass).Returns the set ofUnitCompilers that were created so far.options()options(EnumSet<JaninoOption> options) Sets the options for all future compilations.voidsetCharacterEncoding(String sourceCharsetName) Deprecated.voidsetCompileErrorHandler(ErrorHandler compileErrorHandler) voidsetSourceCharset(Charset sourceCharset) voidsetSourceFinder(ResourceFinder sourceFinder) voidsetSourceVersion(int version) voidsetTargetVersion(int version) voidsetWarningHandler(WarningHandler warningHandler) Methods inherited from class IClassLoader
createJavacLikePathIClassLoader, defineIClass, getArrayIClass, getArrayIClass, getParentIClassLoader, loadIClass, postConstruct
-
Field Details
-
LOGGER
-
sourceFinder
-
sourceCharset
-
options
-
unitCompilers
Collection of parsed compilation units. -
sourceVersion
private int sourceVersion -
targetVersion
private int targetVersion -
compileErrorHandler
-
warningHandler
-
-
Constructor Details
-
JavaSourceIClassLoader
public JavaSourceIClassLoader(ResourceFinder sourceFinder, @Nullable String sourceCharsetName, @Nullable IClassLoader parentIClassLoader)
-
-
Method Details
-
setSourceVersion
public void setSourceVersion(int version) -
setTargetVersion
public void setTargetVersion(int version) -
getUnitCompilers
Returns the set ofUnitCompilers that were created so far. -
setSourceFinder
- Parameters:
sourceFinder- The source path
-
getSourceFinder
-
setCharacterEncoding
Deprecated.UsesetSourceCharset(Charset)instead -
setSourceCharset
- Parameters:
sourceCharset- The charset that is used to read source files
-
setCompileErrorHandler
- See Also:
-
setWarningHandler
- See Also:
-
options
- Returns:
- A reference to the currently effective compilation options; changes to it take effect immediately
-
options
Sets the options for all future compilations. -
findIClass
Description copied from class:IClassLoaderFinds a newIClassby descriptor and callsIClassLoader.defineIClass(IClass).Similar
ClassLoader.findClass(java.lang.String), this method must- Get an
IClassobject from somewhere for the given type - Call
IClassLoader.defineIClass(IClass)with thatIClassobject as the argument - Return the
IClassobject
The format of a
descriptoris defined in JVMS 4.3.2. Typical descriptors are:I(Integer)Lpkg1/pkg2/Clazz;(Class declared in package)Lpkg1/pkg2/Outer$Inner;Member class
Notice that this method is never called for array types.
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 thread-safe.
- Specified by:
findIClassin classIClassLoader- Parameters:
fieldDescriptor- Field descriptor of theIClassto load, e.g. "Lpkg1/pkg2/Outer$Inner;"- Returns:
nullif a class with that descriptor could not be found- Throws:
ClassNotFoundException- An exception was raised while loading theIClass
- Get an
-
findCompilationUnit
@Nullable protected Java.AbstractCompilationUnit findCompilationUnit(String className) throws IOException, CompileException Finds the Java source file for the named class through the configured 'source resource finder' and parses it.- Returns:
nulliff the source file could not be found- Throws:
IOExceptionCompileException
-
setSourceCharset(Charset)instead