changeset 17194:92d5e94796d9

8180574: tools/launcher/modules/patch/systemmodules/PatchSystemModules.java failed in upgradeHashedModule() and patchHashedModule() intermittently Reviewed-by: alanb, bchristi
author mchung
date Fri, 26 May 2017 21:20:16 -0700
parents 99014f394c0c
children 0ff9ad7d067c
files test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java test/tools/launcher/modules/patch/systemmodules/src1/m1/module-info.java test/tools/launcher/modules/patch/systemmodules/src1/m1/p1/Main.java
diffstat 3 files changed, 73 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Fri May 26 09:07:25 2017 -0700
+++ b/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Fri May 26 21:20:16 2017 -0700
@@ -51,7 +51,6 @@
     private static final String JAVA_HOME = System.getProperty("java.home");
 
     private static final Path TEST_SRC = Paths.get(System.getProperty("test.src"));
-    private static final Path PATCH_SRC_DIR = TEST_SRC.resolve("src1");
 
     private static final Path JMODS = Paths.get(JAVA_HOME, "jmods");
     private static final Path MODS_DIR = Paths.get("mods");
@@ -66,6 +65,8 @@
     @BeforeTest
     private void setup() throws Throwable {
         Path src = TEST_SRC.resolve("src");
+        Path src1 = TEST_SRC.resolve("src1");
+
         for (String name : modules) {
             assertTrue(CompilerUtils.compile(src.resolve(name),
                                              MODS_DIR,
@@ -73,11 +74,11 @@
         }
 
         // compile patched source
-        String patchDir = PATCH_SRC_DIR.resolve(JAVA_BASE).toString();
-        assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve(JAVA_BASE),
+        String patchDir = src1.resolve(JAVA_BASE).toString();
+        assertTrue(CompilerUtils.compile(src1.resolve(JAVA_BASE),
                                          PATCH_DIR.resolve(JAVA_BASE),
                                          "--patch-module", "java.base=" + patchDir));
-        assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve("m2"),
+        assertTrue(CompilerUtils.compile(src1.resolve("m2"),
                                          PATCH_DIR.resolve("m2")));
 
         createJars();
@@ -88,10 +89,16 @@
             createImage();
         }
 
-        // create new copy of m1.jar
+        // compile a different version of m1
+        Path tmp = Paths.get("tmp");
+        assertTrue(CompilerUtils.compile(src1.resolve("m1"), tmp,
+                                         "--module-path", MODS_DIR.toString(),
+                                         "--module-source-path", src1.toString()));
+
+        // package new_m1.jar
         jar("--create",
             "--file=" + NEW_M1_JAR.toString(),
-            "-C", MODS_DIR.resolve("m1").toString(), ".");
+            "-C", tmp.resolve("m1").toString(), ".");
     }
 
     /*
@@ -150,13 +157,13 @@
         // Fail to upgrade m1.jar with mismatched hash
         runTestWithExitCode(getJava(IMAGE),
                 "--upgrade-module-path", NEW_M1_JAR.toString(),
-                "-m", "m1/p1.Main", "ShouldNeverRun");
+                "-m", "m1/p1.Main");
 
         // test when SystemModules fast path is not enabled, i.e. exploded image
         runTestWithExitCode(getJava(IMAGE),
                 "--patch-module", "java.base=" + PATCH_DIR.resolve(JAVA_BASE),
                 "--upgrade-module-path", NEW_M1_JAR.toString(),
-                "-m", "m1/p1.Main", "ShouldNeverRun");
+                "-m", "m1/p1.Main");
     }
 
     /*
@@ -173,14 +180,14 @@
         runTestWithExitCode(getJava(IMAGE),
                 "--patch-module", "m1=.jar",
                 "--upgrade-module-path", NEW_M1_JAR.toString(),
-                "-m", "m1/p1.Main", "ShouldNeverRun");
+                "-m", "m1/p1.Main");
 
         // test when SystemModules fast path is not enabled, i.e. exploded image
         runTestWithExitCode(getJava(IMAGE),
                 "--patch-module", "java.base=" + PATCH_DIR.resolve(JAVA_BASE),
                 "--patch-module", "m1=.jar",
                 "--upgrade-module-path", NEW_M1_JAR.toString(),
-                "-m", "m1/p1.Main", "ShouldNeverRun");
+                "-m", "m1/p1.Main");
     }
 
     private void runTestWithExitCode(String... options) throws Throwable {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/launcher/modules/patch/systemmodules/src1/m1/module-info.java	Fri May 26 21:20:16 2017 -0700
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+    requires m2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/launcher/modules/patch/systemmodules/src1/m1/p1/Main.java	Fri May 26 21:20:16 2017 -0700
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+public class Main {
+    public static void main(String[] args) throws Exception {
+        throw new RuntimeException("should not reach here");
+    }
+}