Releases: miho/JCompiler
Releases · miho/JCompiler
v0.5.0
Dependencies via URL classloader improved
Dependencies specified via URL classloader are recognized by compiler. This is done by adding urls of the classloader to the classpath of the compile task.
API documentation improved, debug output removed
v0.3 preparing next release (removed debug output)
Classloading fixed.
v0.2 Merge branch 'master' of github.com:miho/InMemoryJavaCompiler
Initial Release with new API
The new API separates the steps between compilation and classloading:
CompilationResult result = JCompiler.newInstance().compile("public class MyClass {}").checkErrors();
Class<?> myClass = result.loadClasses().get("MyClass");
Additionally, it is not necessary anymore to specify the class name manually:
JCompiler.newInstance().addSource("MyClass", "public class MyClass {}").compileAll();
is now reduced to
JCompiler.newInstance().addSource("public class MyClass {}").compileAll();
The name is inferred from the code.
Classes are grouped by compilation unit:
CompilationResult result = //...
List<CompiledUnit> compiledUnits = result.getCompiledUnits();
for(CompiledUnit cu : compiledUnits) {
List<CompiledClass> classes = cu.getClasses();
for(CompiledClass cc : classes) {
// do something with cc
}
}
Internal classes and non public classes are also loaded and included in the result.
Furthermore, this version is compatible with the old InMemoryJavaCompiler API. The old API is driven by the new JCompiler class. It is tested against the existing test cases for the old API.
The new API is partly inspired by PRs from @ruediste and @benor1470.