Package org.codehaus.janino
Class JavaSourceIClassLoader
- java.lang.Object
-
- org.codehaus.janino.IClassLoader
-
- org.codehaus.janino.JavaSourceIClassLoader
-
public class JavaSourceIClassLoader extends IClassLoader
ThisIClassLoaderfinds, scans and parses compilation units.Notice that it does not compile them!
-
-
Field Summary
Fields Modifier and Type Field Description private ErrorHandlercompileErrorHandlerprivate static java.util.logging.LoggerLOGGERprivate java.util.EnumSet<JaninoOption>optionsprivate java.nio.charset.CharsetsourceCharsetprivate ResourceFindersourceFinderprivate intsourceVersionprivate inttargetVersionprivate java.util.Set<UnitCompiler>unitCompilersCollection of parsed compilation units.private WarningHandlerwarningHandler-
Fields inherited from class org.codehaus.janino.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
Constructors Constructor Description JavaSourceIClassLoader(ResourceFinder sourceFinder, java.lang.String sourceCharsetName, IClassLoader parentIClassLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected Java.AbstractCompilationUnitfindCompilationUnit(java.lang.String className)Finds the Java source file for the named class through the configured 'source resource finder' and parses it.IClassfindIClass(java.lang.String fieldDescriptor)Finds a newIClassby descriptor and callsIClassLoader.defineIClass(IClass).ResourceFindergetSourceFinder()java.util.Set<UnitCompiler>getUnitCompilers()Returns the set ofUnitCompilers that were created so far.java.util.EnumSet<JaninoOption>options()JavaSourceIClassLoaderoptions(java.util.EnumSet<JaninoOption> options)Sets the options for all future compilations.voidsetCharacterEncoding(java.lang.String sourceCharsetName)Deprecated.UsesetSourceCharset(Charset)insteadvoidsetCompileErrorHandler(ErrorHandler compileErrorHandler)voidsetSourceCharset(java.nio.charset.Charset sourceCharset)voidsetSourceFinder(ResourceFinder sourceFinder)voidsetSourceVersion(int version)voidsetTargetVersion(int version)voidsetWarningHandler(WarningHandler warningHandler)-
Methods inherited from class org.codehaus.janino.IClassLoader
createJavacLikePathIClassLoader, defineIClass, getArrayIClass, getArrayIClass, getParentIClassLoader, loadIClass, postConstruct
-
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
sourceFinder
private ResourceFinder sourceFinder
-
sourceCharset
private java.nio.charset.Charset sourceCharset
-
options
private java.util.EnumSet<JaninoOption> options
-
unitCompilers
private final java.util.Set<UnitCompiler> unitCompilers
Collection of parsed compilation units.
-
sourceVersion
private int sourceVersion
-
targetVersion
private int targetVersion
-
compileErrorHandler
@Nullable private ErrorHandler compileErrorHandler
-
warningHandler
@Nullable private WarningHandler warningHandler
-
-
Constructor Detail
-
JavaSourceIClassLoader
public JavaSourceIClassLoader(ResourceFinder sourceFinder, @Nullable java.lang.String sourceCharsetName, @Nullable IClassLoader parentIClassLoader)
-
-
Method Detail
-
setSourceVersion
public void setSourceVersion(int version)
-
setTargetVersion
public void setTargetVersion(int version)
-
getUnitCompilers
public java.util.Set<UnitCompiler> getUnitCompilers()
Returns the set ofUnitCompilers that were created so far.
-
setSourceFinder
public void setSourceFinder(ResourceFinder sourceFinder)
- Parameters:
sourceFinder- The source path
-
getSourceFinder
public ResourceFinder getSourceFinder()
-
setCharacterEncoding
@Deprecated public void setCharacterEncoding(@Nullable java.lang.String sourceCharsetName)
Deprecated.UsesetSourceCharset(Charset)instead
-
setSourceCharset
public void setSourceCharset(java.nio.charset.Charset sourceCharset)
- Parameters:
sourceCharset- The charset that is used to read source files
-
setCompileErrorHandler
public void setCompileErrorHandler(@Nullable ErrorHandler compileErrorHandler)
-
setWarningHandler
public void setWarningHandler(@Nullable WarningHandler warningHandler)
-
options
public java.util.EnumSet<JaninoOption> options()
- Returns:
- A reference to the currently effective compilation options; changes to it take effect immediately
-
options
public JavaSourceIClassLoader options(java.util.EnumSet<JaninoOption> options)
Sets the options for all future compilations.
-
findIClass
@Nullable public IClass findIClass(java.lang.String fieldDescriptor) throws java.lang.ClassNotFoundException
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:
java.lang.ClassNotFoundException- An exception was raised while loading theIClass
- Get an
-
findCompilationUnit
@Nullable protected Java.AbstractCompilationUnit findCompilationUnit(java.lang.String className) throws java.io.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:
java.io.IOExceptionCompileException
-
-