Class InMemoryJavaCompiler


  • public final class InMemoryJavaCompiler
    extends java.lang.Object
    Compile Java sources in-memory. This API is kept in this project to stay backwards compatible. The implementation has been completely replaced by the new JCompiler API.
    • Method Detail

      • useParentClassLoader

        public InMemoryJavaCompiler useParentClassLoader​(java.lang.ClassLoader parent)
      • getClassloader

        public java.lang.ClassLoader getClassloader()
        Returns:
        the class loader used internally by the compiler
      • useOptions

        public InMemoryJavaCompiler useOptions​(java.lang.String... options)
        Options used by the compiler, e.g. '-Xlint:unchecked'.
        Parameters:
        options -
        Returns:
      • ignoreWarnings

        public InMemoryJavaCompiler ignoreWarnings()
        Ignore non-critical compiler output, like unchecked/unsafe operation warnings.
        Returns:
      • compileAll

        public java.util.Map<java.lang.String,​java.lang.Class<?>> compileAll()
                                                                            throws java.lang.Exception
        Compile all sources
        Returns:
        Map containing instances of all compiled classes
        Throws:
        java.lang.Exception
      • compile

        public java.lang.Class<?> compile​(java.lang.String className,
                                          java.lang.String sourceCode)
                                   throws java.lang.Exception
        Compile single source
        Parameters:
        className -
        sourceCode -
        Returns:
        Throws:
        java.lang.Exception
      • addSource

        public InMemoryJavaCompiler addSource​(java.lang.String className,
                                              java.lang.String sourceCode)
                                       throws java.lang.Exception
        Add source code to the compiler
        Parameters:
        className -
        sourceCode -
        Returns:
        Throws:
        java.lang.Exception