Package org.mdkt.compiler
Class InMemoryJavaCompiler
- java.lang.Object
-
- org.mdkt.compiler.InMemoryJavaCompiler
-
public final class InMemoryJavaCompiler extends java.lang.ObjectCompile Java sources in-memory. This API is kept in this project to stay backwards compatible. The implementation has been completely replaced by the newJCompilerAPI.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InMemoryJavaCompileraddSource(java.lang.String className, java.lang.String sourceCode)Add source code to the compilerjava.lang.Class<?>compile(java.lang.String className, java.lang.String sourceCode)Compile single sourcejava.util.Map<java.lang.String,java.lang.Class<?>>compileAll()Compile all sourcesjava.lang.ClassLoadergetClassloader()InMemoryJavaCompilerignoreWarnings()Ignore non-critical compiler output, like unchecked/unsafe operation warnings.static InMemoryJavaCompilernewInstance()InMemoryJavaCompileruseOptions(java.lang.String... options)Options used by the compiler, e.g.InMemoryJavaCompileruseParentClassLoader(java.lang.ClassLoader parent)
-
-
-
Method Detail
-
newInstance
public static InMemoryJavaCompiler newInstance()
-
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.ExceptionCompile 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.ExceptionCompile 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
-
-