public class EclipseJdtCompiler extends Object
| Constructor and Description |
|---|
EclipseJdtCompiler() |
EclipseJdtCompiler(ClassLoader parentLoader) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertTypeAccessible(Class<?> type) |
ClassLoader |
compile(File sourceDir,
ClassLoader parent)
Compiles a set of files contained in source directory directly to bytes in memory,
returning a ClassLoader which is able to access them.
|
void |
compile(File sourceDir,
File binDir)
Compiles a set of files contained in source directory, writing the class
files to binDir
|
byte[] |
compile(String source,
String packageName,
String classSimpleName)
Compile and return the raw bytes of the class file.
|
Class<?> |
compileAndLoad(String source,
String packageName,
String classSimpleName)
Compile and return the (generated) class.
|
String |
formatSource(String code)
Format the source code using the Eclipse text formatter
|
byte[] |
getBytes(String className)
Gets the raw bytes of the classFile that was defined for the given
className by this compiler.
|
Class<?> |
load(String className,
byte[] data) |
public EclipseJdtCompiler()
public EclipseJdtCompiler(ClassLoader parentLoader)
public String formatSource(String code)
public void assertTypeAccessible(Class<?> type) throws IllegalStateException
IllegalStateExceptionpublic Class<?> compileAndLoad(String source, String packageName, String classSimpleName) throws ClassNotFoundException
source - packageName - classSimpleName - ClassNotFoundExceptionpublic byte[] compile(String source, String packageName, String classSimpleName)
source - packageName - classSimpleName - public ClassLoader compile(File sourceDir, ClassLoader parent) throws IOException
sourceDir - the directory (base) from which to find the java source filesparent - the parent ClassLoader to be set for the returned loaderIOExceptionpublic void compile(File sourceDir, File binDir) throws IOException
sourceDir - binDir - IOExceptionpublic Class<?> load(String className, byte[] data) throws ClassNotFoundException
ClassNotFoundExceptionpublic byte[] getBytes(String className)
className - Copyright © 2019 Glasnost. All rights reserved.