Problems with JavacTool & -L
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Dec 28 02:13:51 PST 2011
On 12/28/2011 04:02 AM, Jesse Glick wrote:
> On 12/27/2011 09:37 PM, Mandy Chung wrote:
>> Jigsaw JDK is built using jigsaw langtools on top of JDK 7 as the
>> boot JDK. So I expect it should work to run on top of JRE 7.
>
> That is what I hoped.
>
>> How do you run it?
>
> Using JSR 199, in a URLClassLoader which makes sure all of
> com.sun.source, com.sun.tools, javax.annotation.processing,
> javax.lang, and javax.tools are loaded from Jigsaw langtools rather
> than the host JRE/JDK 7. More or less like:
>
> File moduleInfoJava = ...;
> JavaCompiler jc = (JavaCompiler)
> Class.forName("com.sun.tools.javac.api.JavacTool").newInstance();
> StringWriter out = new StringWriter();
> CompilationTask task = jc.getTask(out, null, null,
> Arrays.asList("-source", "8"), null, jc.getStandardFileManager(null,
> null, null).getJavaFileObjects(moduleInfoJava));
> task.setProcessors(...);
> task.call();
>
> which returns false and prints the error about java.lang to the output
> writer. Loading JavacTool by name seems to be necessary as
> ToolProvider.getSystemJavaCompiler gives me a CCE (investigating).
We need to revisit the impl of ToolProvider in the Jigsaw world, since
the JDK 7 code creates a URLClassLoader for tools.jar is the classes are
not found on the bootclasspath. tools.jar is going away, so we should
probably rewrite ToolProvider to use the module services mechanism.
-- Jon
More information about the jigsaw-dev
mailing list