Interface ISimpleCompiler

  • All Superinterfaces:
    ICookable
    All Known Implementing Classes:
    SimpleCompiler, SimpleCompiler

    public interface ISimpleCompiler
    extends ICookable
    A simplified Java compiler that can compile only a single compilation unit. (A "compilation unit" is the document stored in a ".java" file.)

    Opposed to a normal ".java" file, you can declare multiple public classes here.

    To set up an ISimpleCompiler object, proceed as follows:

    1. Create an ISimpleCompiler-implementing object
    2. Optionally set an alternate parent class loader through setParentClassLoader(ClassLoader).
    3. Call any of the ICookable.cook(String, Reader) methods to scan, parse, compile and load the compilation unit into the JVM.
    4. Call getClassLoader() to obtain a ClassLoader that you can use to access the compiled classes.

    Comptibility notice:

    The methods setPermissions(Permissions permissions) and void setNoPermissions() were removed in version 3.1.1 (2020-03-09) and replaced by the Sandbox.

    • Method Detail

      • setParentClassLoader

        void setParentClassLoader​(@Nullable
                                  ClassLoader parentClassLoader)
        The "parent class loader" is used to load referenced classes. Useful values are:
        System.getSystemClassLoader() The running JVM's class path
        Thread.currentThread().getContextClassLoader() or null The class loader effective for the invoking thread
        ClassLoaders.BOOTCLASSPATH_CLASS_LOADER The running JVM's boot class path

        The parent class loader defaults to the current thread's context class loader.

      • setDebuggingInformation

        void setDebuggingInformation​(boolean debugSource,
                                     boolean debugLines,
                                     boolean debugVars)
        Determines what kind of debugging information is included in the generates classes. The default is typically "-g:none".
      • setWarningHandler

        void setWarningHandler​(@Nullable
                               WarningHandler warningHandler)
        By default, warnings are discarded, but an application my install a custom WarningHandler.
        Parameters:
        warningHandler - null to indicate that no warnings be issued