public final class CompilerUtil extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
compile(DiagnosticCollector<JavaFileObject> diagnostics,
JavaCompiler.CompilationTask task)
Execute compilation task and report errors if it fails.
|
static Class<?> |
compileAndLoad(String className,
DiagnosticCollector<JavaFileObject> diagnostics,
JavaFileManager fileManager,
JavaCompiler.CompilationTask task)
Compile and load a class.
|
static Class<?> |
compileInMemory(String className,
Map<String,CharSequence> sources)
|
static Class<?> |
compileOnDisk(String className,
Map<String,CharSequence> sources)
|
static Collection<File> |
persist(Map<String,CharSequence> sources)
Persist source files to disc.
|
public static Class<?> compileInMemory(String className, Map<String,CharSequence> sources) throws ClassNotFoundException
className
- to return after compilation.sources
- to be compiled.ClassNotFoundException
- of the named class cannot be found.public static Class<?> compileOnDisk(String className, Map<String,CharSequence> sources) throws ClassNotFoundException, IOException
className
- to return after compilation.sources
- to be compiled.ClassNotFoundException
- of the named class cannot be found.IOException
- if an error occurs when writing to disk.public static Class<?> compileAndLoad(String className, DiagnosticCollector<JavaFileObject> diagnostics, JavaFileManager fileManager, JavaCompiler.CompilationTask task) throws ClassNotFoundException
className
- name of the class to compile.diagnostics
- attached to the compilation task.fileManager
- to load compiled class from disk.task
- compilation task.Class
for the compiled class or null
if compilation fails.ClassNotFoundException
- if compiled class was not loaded.public static boolean compile(DiagnosticCollector<JavaFileObject> diagnostics, JavaCompiler.CompilationTask task)
diagnostics
- attached to the compilation task.task
- compilation to be executed.true
if compilation succeeds.public static Collection<File> persist(Map<String,CharSequence> sources) throws IOException
sources
- to persist.File
objects pointing to the persisted sources.IOException
- in case of I/O errors.Copyright © 2014-2021 Real Logic Limited. All Rights Reserved.