test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java
changeset 48171 7ad2d33a0f05
parent 48098 b38d8aadcada
child 48397 ead47ddf5844
--- a/test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java	Thu Nov 30 16:00:34 2017 -0500
+++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java	Thu Nov 30 14:25:33 2017 -0800
@@ -86,6 +86,9 @@
 
         logTestCase("5");
         testBootAppendClass();
+
+        logTestCase("6");
+        testBootAppendExtraDir();
     }
 
     private static void logTestCase(String msg) {
@@ -241,4 +244,28 @@
             }
         }
     }
+
+    // Test #6: This is similar to Test #5. During runtime, an extra dir
+    //          is appended to the bootclasspath. It should not invalidate
+    //          the shared archive.
+    public static void testBootAppendExtraDir() throws Exception {
+        for (String mode : modes) {
+            CDSOptions opts = (new CDSOptions())
+                .setXShareMode(mode).setUseVersion(false)
+                .addPrefix("-Xbootclasspath/a:" + bootAppendJar + File.pathSeparator + appJar,
+                           "-showversion", "--limit-modules=java.base", "-cp", appJar)
+                .addSuffix("-Xlog:class+load=info",
+                           APP_CLASS, BOOT_APPEND_CLASS_NAME);
+
+            OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
+            CDSTestUtils.checkExec(out, opts, "[class,load] nonjdk.myPackage.MyClass");
+
+            // If CDS is enabled, the nonjdk.myPackage.MyClass should be loaded
+            // from the shared archive.
+            if (mode.equals("on")) {
+                CDSTestUtils.checkExec(out, opts,
+                    "[class,load] nonjdk.myPackage.MyClass source: shared objects file");
+            }
+        }
+    }
 }