8169816: Move src.zip and jrt-fs.jar under the lib directory
authormchung
Mon, 28 Nov 2016 11:37:00 -0800
changeset 42316 f0c7eeac7273
parent 42315 503b68f63f1e
child 42317 debe8d32a0a4
8169816: Move src.zip and jrt-fs.jar under the lib directory Reviewed-by: alanb, erikj
jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java
jdk/src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java
jdk/test/jdk/internal/jrtfs/remote/Main.java
jdk/test/jdk/internal/jrtfs/remote/RemoteRuntimeImageTest.java
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java	Mon Nov 28 17:48:53 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystemProvider.java	Mon Nov 28 11:37:00 2016 -0800
@@ -115,7 +115,7 @@
     private FileSystem newFileSystem(String targetHome, URI uri, Map<String, ?> env)
             throws IOException {
         Objects.requireNonNull(targetHome);
-        Path jrtfs = FileSystems.getDefault().getPath(targetHome, JRT_FS_JAR);
+        Path jrtfs = FileSystems.getDefault().getPath(targetHome, "lib", JRT_FS_JAR);
         if (Files.notExists(jrtfs)) {
             throw new IOException(jrtfs.toString() + " not exist");
         }
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java	Mon Nov 28 17:48:53 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/SystemImage.java	Mon Nov 28 11:37:00 2016 -0800
@@ -113,12 +113,16 @@
         if (cs == null)
             return System.getProperty("java.home");
 
-        // assume loaded from $TARGETJDK/jrt-fs.jar
+        // assume loaded from $TARGETJDK/lib/jrt-fs.jar
         URL url = cs.getLocation();
         if (!url.getProtocol().equalsIgnoreCase("file"))
-            throw new RuntimeException(url + " loaded in unexpected way");
+            throw new InternalError(url + " loaded in unexpected way");
         try {
-            return Paths.get(url.toURI()).getParent().toString();
+            Path lib = Paths.get(url.toURI()).getParent();
+            if (!lib.getFileName().toString().equals("lib"))
+                throw new InternalError(url + " unexpected path");
+
+            return lib.getParent().toString();
         } catch (URISyntaxException e) {
             throw new InternalError(e);
         }
--- a/jdk/test/jdk/internal/jrtfs/remote/Main.java	Mon Nov 28 17:48:53 2016 +0000
+++ b/jdk/test/jdk/internal/jrtfs/remote/Main.java	Mon Nov 28 11:37:00 2016 -0800
@@ -68,7 +68,7 @@
     }
 
     private static FileSystem createFsWithURLClassloader(String javaHome) throws IOException{
-        URL url = Paths.get(javaHome, "jrt-fs.jar").toUri().toURL();
+        URL url = Paths.get(javaHome, "lib", "jrt-fs.jar").toUri().toURL();
         URLClassLoader loader = new URLClassLoader(new URL[] { url });
         return FileSystems.newFileSystem(URI.create("jrt:/"),
                                                     Collections.emptyMap(),
--- a/jdk/test/jdk/internal/jrtfs/remote/RemoteRuntimeImageTest.java	Mon Nov 28 17:48:53 2016 +0000
+++ b/jdk/test/jdk/internal/jrtfs/remote/RemoteRuntimeImageTest.java	Mon Nov 28 11:37:00 2016 -0800
@@ -64,7 +64,7 @@
         String java = jdk8Path.resolve("bin/java").toAbsolutePath().toString();
         String javac = jdk8Path.resolve("bin/javac").toAbsolutePath().toString();
         Files.createDirectories(Paths.get(".", CLASSES_DIR));
-        String jrtJar = Paths.get(TEST_JAVAHOME, JRTFS_JAR).toAbsolutePath().toString();
+        String jrtJar = Paths.get(TEST_JAVAHOME, "lib", JRTFS_JAR).toAbsolutePath().toString();
 
         // Compose command-lines for compiling and executing tests
         List<List<String>> cmds = Arrays.asList(