Top Description Fields Constructors Methods
org.codehaus.janino

public Class JavaSourceIClassLoader

extends IClassLoader
Class Inheritance
Imports
java.io.IOException, .InputStream, .InputStreamReader, java.nio.charset.Charset, java.util.EnumSet, .HashSet, .Set, java.util.logging.Level, .Logger, org.codehaus.commons.compiler.CompileException, .ErrorHandler, .Location, .WarningHandler, org.codehaus.commons.compiler.util.resource.Resource, .ResourceFinder, org.codehaus.commons.nullanalysis.Nullable, org.codehaus.janino.util.ClassFile

This org.codehaus.janino.IClassLoader finds, scans and parses compilation units.

Notice that it does not compile them!

Field Summary

Modifier and TypeField and Description
private ErrorHandler
private static final Logger
private EnumSet<JaninoOption>
private Charset
private ResourceFinder
private int
private int
private final Set<UnitCompiler>
unitCompilers

Collection of parsed compilation units.

private WarningHandler
Inherited from org.codehaus.janino.IClassLoader:
CTOR_java_lang_StringBuilder__java_lang_StringMETH_java_lang_Enum__ordinalMETH_java_lang_Iterable__iteratorMETH_java_lang_String__concat__java_lang_StringMETH_java_lang_String__equals__java_lang_ObjectMETH_java_lang_String__hashCodeMETH_java_lang_String__valueOf__booleanMETH_java_lang_String__valueOf__charMETH_java_lang_String__valueOf__doubleMETH_java_lang_String__valueOf__floatMETH_java_lang_String__valueOf__intMETH_java_lang_String__valueOf__java_lang_ObjectMETH_java_lang_String__valueOf__longMETH_java_lang_StringBuilder__append__booleanMETH_java_lang_StringBuilder__append__charMETH_java_lang_StringBuilder__append__doubleMETH_java_lang_StringBuilder__append__floatMETH_java_lang_StringBuilder__append__intMETH_java_lang_StringBuilder__append__java_lang_ObjectMETH_java_lang_StringBuilder__append__java_lang_StringMETH_java_lang_StringBuilder__append__longMETH_java_lang_StringBuilder__toStringMETH_java_lang_Throwable__addSuppressedMETH_java_util_Iterator__hasNextMETH_java_util_Iterator__nextTYPE_java_io_SerializableTYPE_java_lang_annotation_RetentionTYPE_java_lang_AssertionErrorTYPE_java_lang_BooleanTYPE_java_lang_ByteTYPE_java_lang_CharacterTYPE_java_lang_ClassTYPE_java_lang_CloneableTYPE_java_lang_DoubleTYPE_java_lang_EnumTYPE_java_lang_ErrorTYPE_java_lang_ExceptionTYPE_java_lang_FloatTYPE_java_lang_IntegerTYPE_java_lang_IterableTYPE_java_lang_LongTYPE_java_lang_ObjectTYPE_java_lang_OverrideTYPE_java_lang_RuntimeExceptionTYPE_java_lang_ShortTYPE_java_lang_StringTYPE_java_lang_StringBuilderTYPE_java_lang_SystemTYPE_java_lang_ThrowableTYPE_java_lang_VoidTYPE_java_util_Iterator

Constructor Summary

AccessConstructor and Description
public
JavaSourceIClassLoader(ResourceFinder sourceFinder, String sourceCharsetName, IClassLoader parentIClassLoader)

Method Summary

Modifier and TypeMethod and Description
protected Java.AbstractCompilationUnit

Returns:

null iff the source file could not be found
findCompilationUnit
(String className)

Finds the Java source file for the named class through the configured 'source resource finder' and parses it.

public IClass
findIClass(final String
Field descriptor of the IClass to load, e.g. "Lpkg1/pkg2/Outer$Inner;"
fieldDescriptor
)

Implements abstract org.codehaus.janino.IClassLoader.findIClass.

Finds a new IClass by descriptor and calls defineIClass(IClass).
public ResourceFinder
public Set<UnitCompiler>
getUnitCompilers()

Returns the set of UnitCompilers that were created so far.

public EnumSet<JaninoOption>

Returns:

A reference to the currently effective compilation options; changes to it take effect immediately
options
()

public JavaSourceIClassLoader
options(EnumSet<JaninoOption> options)

Sets the options for all future compilations.

public void
setCharacterEncoding(String sourceCharsetName)

Deprecated Use setSourceCharset(Charset) instead
public void
setCompileErrorHandler(ErrorHandler compileErrorHandler)

public void
setSourceCharset(Charset
The charset that is used to read source files
sourceCharset
)

public void
setSourceFinder(ResourceFinder
The source path
sourceFinder
)

public void
setSourceVersion(int version)

public void
setTargetVersion(int version)

public void
Inherited from org.codehaus.janino.IClassLoader:
createJavacLikePathIClassLoaderdefineIClassgetArrayIClassgetArrayIClassgetParentIClassLoaderloadIClasspostConstruct

Field Detail

compileErrorHandlerback to summary
private ErrorHandler compileErrorHandler
Annotations
@Nullable
LOGGERback to summary
private static final Logger LOGGER

Hides org.codehaus.janino.IClassLoader.LOGGER.

optionsback to summary
private EnumSet<JaninoOption> options
sourceCharsetback to summary
private Charset sourceCharset
sourceFinderback to summary
private ResourceFinder sourceFinder
sourceVersionback to summary
private int sourceVersion
targetVersionback to summary
private int targetVersion
unitCompilersback to summary
private final Set<UnitCompiler> unitCompilers

Collection of parsed compilation units.

warningHandlerback to summary
private WarningHandler warningHandler
Annotations
@Nullable

Constructor Detail

JavaSourceIClassLoaderback to summary
public JavaSourceIClassLoader(ResourceFinder sourceFinder, String sourceCharsetName, IClassLoader parentIClassLoader)

Method Detail

findCompilationUnitback to summary
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:Java.AbstractCompilationUnit

null iff the source file could not be found

Annotations
@Nullable
findIClassback to summary
public IClass findIClass(final String fieldDescriptor) throws ClassNotFoundException

Implements abstract org.codehaus.janino.IClassLoader.findIClass.

Doc from org.codehaus.janino.IClassLoader.findIClass.

Finds a new IClass by descriptor and calls defineIClass(IClass).

Similar java.lang.ClassLoader#findClass(java.lang.String), this method must

The format of a descriptor is 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.

Parameters
fieldDescriptor:String

Field descriptor of the IClass to load, e.g. "Lpkg1/pkg2/Outer$Inner;"

Returns:IClass

null if a class with that descriptor could not be found

Annotations
@Override
@Nullable
Exceptions
ClassNotFoundException:
An exception was raised while loading the IClass
getSourceFinderback to summary
public ResourceFinder getSourceFinder()
getUnitCompilersback to summary
public Set<UnitCompiler> getUnitCompilers()

Returns the set of UnitCompilers that were created so far.

optionsback to summary
public EnumSet<JaninoOption> options()
Returns:EnumSet<JaninoOption>

A reference to the currently effective compilation options; changes to it take effect immediately

optionsback to summary
public JavaSourceIClassLoader options(EnumSet<JaninoOption> options)

Sets the options for all future compilations.

setCharacterEncodingback to summary
public void setCharacterEncoding(String sourceCharsetName)

Deprecated

Use setSourceCharset(Charset) instead

Annotations
@Deprecated
setCompileErrorHandlerback to summary
public void setCompileErrorHandler(ErrorHandler compileErrorHandler)
See Also
UnitCompiler#setCompileErrorHandler(ErrorHandler)
setSourceCharsetback to summary
public void setSourceCharset(Charset sourceCharset)
Parameters
sourceCharset:Charset

The charset that is used to read source files

setSourceFinderback to summary
public void setSourceFinder(ResourceFinder sourceFinder)
Parameters
sourceFinder:ResourceFinder

The source path

setSourceVersionback to summary
public void setSourceVersion(int version)
setTargetVersionback to summary
public void setTargetVersion(int version)
setWarningHandlerback to summary
public void setWarningHandler(WarningHandler warningHandler)
See Also
Parser#setWarningHandler(WarningHandler), UnitCompiler#setCompileErrorHandler(ErrorHandler)