Keimpe,

While your use-case is about accessing alternate versions of javac, the underlying mechanism you are looking for is more general and not specific to javac.

The ability that you need, and which you're currently missing, is the ability to load code (modules) from an alternate JDK image.

If you could do that, you could load the module(s) you want into a new Layer, then from the Layer create a ServiceLoader, and from the ServiceLoader, iterate to find the desired impl of javax.tools.JavaCompiler, and thus avoid the need to use com.sun.tools.javac.api.JavacTool directly.

-- Jon


On 10/08/2015 09:47 AM, Keimpe Bronkhorst wrote:
Jon,

Users of JDeveloper want to be able to compile and run their code with
any JDK on their filesystem, not just compile and run with the JDK
JDeveloper is running on.

The compile I could make work in JDK8 and before by getting a
javax.tools.JavaCompiler from com.sun.tools.javac.api.JavacTool.create()
all loaded through a classloader from tools.jar of the JDK the user
wanted to use.

I remember you previously mentioned you were considering a way to
use JSR199 from any JDK other than the one of the current process.

Keimpe Bronkhorst
JDeveloper


On 10/07/2015 06:01 PM, Keimpe Bronkhorst wrote:
/The underlying exception I get is: />/"Class oracle.jdevimpl.javacompiler.JDevJavaCompiler can not access a />/member of class com.sun.tools.javac.api.JavacTool (module />/jdk.compiler) with modifiers "public static", module jdk.compiler does />/not export com.sun.tools.javac.api to <unnamed module @1cfeea20>" />//>/Will there be a "public API" way to run JSR199 of any JDK9 installation? />//>/Keimpe Bronkhorst />/JDeveloper />//>/On 10/7/2015 6:54 PM, Keimpe Bronkhorst wrote: />>/It is possible in JDK8 and before to run JSR199 compilations using a />>/class loader that loads from tools.jar. I can't do something similar />>/in JDK9 using a new jigsaw build, trying to load from jrt-fs.jar. I />>/get this: Warning: Cannot use jsr199 Javac from jrt-fs.jar". />>//>>/Does this mean you can only use the JSR199 as provided by />>/ToolProvider.getSystemJavaCompiler() of the current process in JDK9? />>//>>/Keimpe Bronkhorst />>/JDeveloper />//
Keimpe,

While we know that some "friends of javac" have been using its internal
API, it would be good to know what specific internal features you have
been using, so that we can see if there are alternatives on the public
API, and maybe provide additional public API where appropriate.

You can run tools like jdeps to find what dependencies you have on any
internal API.

-- Jon



Reply via email to