Problems with JavacTool & -L

Jesse Glick jesse.glick at oracle.com
Tue Dec 27 20:02:37 PST 2011


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).



More information about the jigsaw-dev mailing list