public class CompilerUtil extends Object
JavaCompiler
相关功能Modifier and Type | Field and Description |
---|---|
static JavaCompiler |
SYSTEM_COMPILER
java 编译器
|
Constructor and Description |
---|
CompilerUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
compile(String... sourceFiles)
编译指定的源码文件
|
static JavaSourceCompiler |
getCompiler(ClassLoader parent)
|
static StandardJavaFileManager |
getFileManager()
|
static StandardJavaFileManager |
getFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener)
|
static JavaCompiler.CompilationTask |
getTask(JavaFileManager fileManager,
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Iterable<String> options,
Iterable<? extends JavaFileObject> compilationUnits)
新建编译任务
|
public static final JavaCompiler SYSTEM_COMPILER
public static boolean compile(String... sourceFiles)
sourceFiles
- 源码文件路径public static StandardJavaFileManager getFileManager()
StandardJavaFileManager
public static StandardJavaFileManager getFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener)
diagnosticListener
- 异常收集器StandardJavaFileManager
public static JavaCompiler.CompilationTask getTask(JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<? extends JavaFileObject> compilationUnits)
fileManager
- JavaFileManager
,用于管理已经编译好的文件diagnosticListener
- 诊断监听options
- 选项,例如 -cpXXX等compilationUnits
- 编译单元,即需要编译的对象JavaCompiler.CompilationTask
public static JavaSourceCompiler getCompiler(ClassLoader parent)
parent
- 父ClassLoader
JavaSourceCompiler
JavaSourceCompiler.create(ClassLoader)
Copyright © 2024. All rights reserved.