|Doc about EclipseCompiler for JSR 199? [message #1839111]
||Sun, 14 March 2021 17:55
| Olivier Cailloux
Registered: July 2009
I have been successfully using EclipseCompiler as an instance of JavaCompiler, to compile Java classes in memory.|
Here is a sample code.
JavaCompiler compiler = new EclipseCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(fileDiagnostics, Locale.US, StandardCharsets.UTF_8);
StringWriter compilationOutputReceiver = new StringWriter();
boolean compiled = compiler.getTask(compilationOutputReceiver, fileManager, compilerDiagnostics, ImmutableList.of(), null, fileManager.getJavaFileObjectsFromPaths(sourcePaths)).call();
String compilationOutput = compilationOutputReceiver.toString();
I use org.eclipse.jdt:ecj:3.24.0, which defines org.eclipse.jdt.internal.compiler.tool.EclipseCompiler.
Can I find some documentation about this implementation of JSR 199? (I have read Compiling Java code but I do not think it is related to what I try to do as the code I want to compile is not in an Eclipse workspace and I am not developing an Eclipse plug-in.)
In particular, I wonder how to pass this compiler an equivalent of the option -properties <file> that can be used with the batch compiler. Other things I wonder about are what Eclipse will give me (by contract) as file manager diagnostics; as compile task diagnostics; and as mere output (compilationOutput in my code sample).
Is there some documentation about all this somewhere? Or should I use another jar for accessing Eclipse's implementation of JSR 199? (I am also a bit puzzled by the EclipseCompiler being in an "internal" package.)
[Updated on: Sun, 14 March 2021 17:57]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01444 seconds