"Scanning" module contents
Roman Shevchenko
roman.shevchenko at jetbrains.com
Mon Jan 5 20:19:54 UTC 2015
Thanks! Yep, I was looking exactly for the IDE case.
Regarding scanning JDK 9 from other JDK 9 - I'm extremly interested in
this case too. Is there any way I may be notified once the case is resolved?
On 01.01.2015 10:16, Alan Bateman wrote:
> On 30/12/2014 17:18, Roman Shevchenko wrote:
>> Hi Rémi,
>>
>> do you by any chance know if there is a legitimate way of doing the
>> same from another JVM, not the one the scanning code is loaded into?
>> I've seen your jigsaw-jrtfs, but that patch() part of it feels hacky
>> and (if I got it right) does not scale to more then one JDK instance.
>>
> At this time you can get a reference to jrt:/ for the current runtime
> (as per Remi's reply and example).
>
> It is also possible for a tool running on JDK 8 to create a jrt:/ that
> provides access to the contents of a JDK 9 runtime image. For this to
> work then it requires putting $JDK9/jrt-fs.jar on the class path
> (jrt-fs.jar is intended to be a supported interface, see JEP 220 [1]).
> Alternatively, for the IDE-like case where you target a runtime image
> selected by the user then you can use code such as following:
>
> String jdkHome = "/yonder/jdk9";
>
> URL url = Paths.get(jdkHome, "jrt-fs.jar").toUri().toURL();
> URLClassLoader loader = new URLClassLoader(new URL[] { url });
> FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"),
> Collections.emptyMap(),
> loader);
> Path top = fs.getPath("/");
> Files.walk(top).filter(Files::isRegularFile).forEach(System.out::println);
>
>
> In time then we expect to improve on this so that jrt-fs.jar is loaded
> automatically from the target runtime image. That will allow a tool
> running on one JDK 9 runtime image to access the contents of another
> JDK 9 runtime image for example. There are a few issues to sort out
> before we can get there.
>
> -Alan
>
> [1] http://openjdk.java.net/jeps/220
More information about the jigsaw-dev
mailing list