Is Caching JrtFileSystem acceptable?

Jayaprakash Arthanareeswaran jarthana at
Mon Nov 2 09:48:24 UTC 2015


We recently changed our code in Eclipse to support JRE 8 when loading
classes from a Java 9 images (discussion at [1]). The change was to use a
JrtFileSystem with a class loader. The file system is then cached and
re-used for every request to get something from the JRE 9 images. The code
is something like this:

URL url = Paths.get(jdkHome, "jrt-fs.jar").toUri().toURL();
URLClassLoader loader = new URLClassLoader(new URL[] { url });
FileSystem jrt = FileSystems.newFileSystem("jrt:/", env, loader);

After this change, we have started getting an NPE in the file system (We
are randomly hitting this and at this point no idea what is causing it):

Daemon Thread [Java indexing] (Suspended (exception NullPointerException))
	ByteArrayInputStream.<init>(byte[]) line: 106
	JrtFileSystem.newByteChannel(byte[], Set<OpenOption>,
FileAttribute<?>...) line: 600
	JrtPath.newByteChannel(Set<OpenOption>, FileAttribute<?>...) line:
	JrtFileSystemProvider.newByteChannel(Path, Set<OpenOption>,
FileAttribute<?>...) line: 218
	Files.newByteChannel(Path, Set<OpenOption>, FileAttribute<?>...)
line: 361
	Files.newByteChannel(Path, OpenOption...) line: 407
	Files.readAllBytes(Path) line: 3152

I have confirmed that the JrtFileSystem that is used in the above stack and
what we cached are the same objects. And the path that is being passed in
the beginning is a valid JrtPath. I would like to know if this is a bug in
the file system implementation or something to do with our code.

Of course, I don't have the source for JrtFileSystem, so unable to debug
this further. Thanks for any pointers in trouble-shooting this further.



More information about the jigsaw-dev mailing list