Class JavaSourceIClassLoader


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

    Notice that it does not compile them!

    • Field Detail

      • optionalCharacterEncoding

        private java.lang.String optionalCharacterEncoding
      • unitCompilers

        private final java.util.Set<UnitCompiler> unitCompilers
        Collection of parsed compilation units.
      • optionalCompileErrorHandler

        private ErrorHandler optionalCompileErrorHandler
      • optionalWarningHandler

        private WarningHandler optionalWarningHandler
    • Constructor Detail

      • JavaSourceIClassLoader

        public JavaSourceIClassLoader​(ResourceFinder sourceFinder,
                                      java.lang.String optionalCharacterEncoding,
                                      IClassLoader optionalParentIClassLoader)
    • Method Detail

      • getUnitCompilers

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

        public void setSourceFinder​(ResourceFinder pathResourceFinder)
        Parameters:
        pathResourceFinder - The source path
      • setCharacterEncoding

        public void setCharacterEncoding​(java.lang.String optionalCharacterEncoding)
        Parameters:
        optionalCharacterEncoding - The name of the charset that is used to read source files, or null to use the platform's 'default charset'
      • findIClass

        public IClass findIClass​(java.lang.String fieldDescriptor)
                          throws java.lang.ClassNotFoundException
        Description copied from class: IClassLoader
        Find a new IClass by descriptor; return null if a class for that descriptor could not be found.

        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/Cls; (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 synchronized.

        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

        protected Java.CompilationUnit 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