Class JavaSourceIClassLoader


  • public class JavaSourceIClassLoader
    extends IClassLoader
    This IClassLoader finds, scans and parses compilation units.

    Notice that it does not compile them!

    • Method Detail

      • setSourceVersion

        public void setSourceVersion​(int version)
      • setTargetVersion

        public void setTargetVersion​(int version)
      • getUnitCompilers

        public java.util.Set<UnitCompiler> getUnitCompilers()
        Returns the set of UnitCompilers that were created so far.
      • setSourceFinder

        public void setSourceFinder​(ResourceFinder sourceFinder)
        Parameters:
        sourceFinder - The source path
      • setSourceCharset

        public void setSourceCharset​(java.nio.charset.Charset sourceCharset)
        Parameters:
        sourceCharset - The charset that is used to read source files
      • options

        public java.util.EnumSet<JaninoOption> options()
        Returns:
        A reference to the currently effective compilation options; changes to it take effect immediately
      • findIClass

        @Nullable
        public IClass findIClass​(java.lang.String fieldDescriptor)
                          throws java.lang.ClassNotFoundException
        Description copied from class: IClassLoader
        Finds a new IClass by descriptor and calls IClassLoader.defineIClass(IClass).

        Similar 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.

        Specified by:
        findIClass in class IClassLoader
        Parameters:
        fieldDescriptor - Field descriptor of the IClass to load, e.g. "Lpkg1/pkg2/Outer$Inner;"
        Returns:
        null if a class with that descriptor could not be found
        Throws:
        java.lang.ClassNotFoundException - An exception was raised while loading the IClass
      • 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:
        null iff the source file could not be found
        Throws:
        java.io.IOException
        CompileException