Package org.mdkt.compiler
Class InMemoryJavaCompiler
- java.lang.Object
-
- org.mdkt.compiler.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 newJCompiler
API.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InMemoryJavaCompiler
addSource(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.ClassLoader
getClassloader()
InMemoryJavaCompiler
ignoreWarnings()
Ignore non-critical compiler output, like unchecked/unsafe operation warnings.static InMemoryJavaCompiler
newInstance()
InMemoryJavaCompiler
useOptions(java.lang.String... options)
Options used by the compiler, e.g.InMemoryJavaCompiler
useParentClassLoader(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.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
-
-