Reading Java 9 bootstrap class bytecode from Java 12?

Ess Kay s.2016.kay at gmail.com
Thu Feb 14 00:33:29 UTC 2019


Is there any way of accessing Java 9's bootstrap classes from within Java
12 to access Java 9's bootstrap classes? If run using Java 12, the snippet
below always finds the Java 12 file system rather than the required Java 9
file system.  My immediate issue is that I am inappropriately finding
java.lang.constant.Constable when searching for the implemented interfaces
of java.lang.invoke.MethodHandle in Java 9 bytecode.

String targetImage = <...Java9_HOME...>
URL url = Paths.get(targetImage, "lib", "jrt-fs.jar").toUri().toURL();
URLClassLoader loader = new URLClassLoader(new URL[] { url });
FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"),
Collections.emptyMap(), loader);


More information about the jigsaw-dev mailing list