--- old/test/hotspot/jtreg/runtime/appcds/BootClassPathMismatch.java 2018-05-16 22:33:57.651946977 -0400 +++ new/test/hotspot/jtreg/runtime/appcds/BootClassPathMismatch.java 2018-05-16 22:33:56.315869590 -0400 @@ -34,6 +34,8 @@ * @run main BootClassPathMismatch */ +import jdk.test.lib.cds.CDSOptions; +import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; import java.io.File; import java.nio.file.Files; @@ -52,10 +54,13 @@ BootClassPathMismatch test = new BootClassPathMismatch(); test.testBootClassPathMismatch(); test.testBootClassPathMismatch2(); + test.testBootClassPathMismatchWithAppend(); test.testBootClassPathMatch(); } - /* Error should be detected if: + /* Archive contains boot classes only, with Hello class on -Xbootclasspath/a path. + * + * Error should be detected if: * dump time: -Xbootclasspath/a:${testdir}/hello.jar * run-time : -Xbootclasspath/a:${testdir}/newdir/hello.jar */ @@ -71,20 +76,9 @@ .assertAbnormalExit(mismatchMessage); } - /* Error should be detected if: - * dump time: - * run-time : -Xbootclasspath/a:${testdir}/hello.jar - */ - public void testBootClassPathMismatch2() throws Exception { - String appJar = JarBuilder.getOrCreateHelloJar(); - String appClasses[] = {"Hello"}; - TestCommon.dump(appJar, appClasses); - TestCommon.run( - "-cp", appJar, "-verbose:class", "-Xbootclasspath/a:" + appJar, "Hello") - .assertAbnormalExit(mismatchMessage); - } - - /* No error if: + /* Archive contains boot classes only, with Hello loaded from -Xbootclasspath/a at dump time. + * + * No error if: * dump time: -Xbootclasspath/a:${testdir}/hello.jar * run-time : -Xbootclasspath/a:${testdir}/hello.jar */ @@ -99,6 +93,37 @@ .assertNormalExit("[class,load] Hello source: shared objects file"); } + /* Archive contains boot classes only, runtime add -Xbootclasspath/a path. + * + * No error: + * dump time: No -Xbootclasspath/a + * run-time : -Xbootclasspath/a:${testdir}/hello.jar + */ + public void testBootClassPathMismatchWithAppend() throws Exception { + CDSOptions opts = new CDSOptions().setUseVersion(false); + OutputAnalyzer out = CDSTestUtils.createArchive(opts); + CDSTestUtils.checkDump(out); + + String appJar = JarBuilder.getOrCreateHelloJar(); + opts.addPrefix("-Xbootclasspath/a:" + appJar, "-showversion").addSuffix("Hello"); + CDSTestUtils.runWithArchiveAndCheck(opts); + } + + /* Archive contains app classes, with Hello on -cp path at dump time. + * + * Error should be detected if: + * dump time: + * run-time : -Xbootclasspath/a:${testdir}/hello.jar + */ + public void testBootClassPathMismatch2() throws Exception { + String appJar = JarBuilder.getOrCreateHelloJar(); + String appClasses[] = {"Hello"}; + TestCommon.dump(appJar, appClasses); + TestCommon.run( + "-cp", appJar, "-verbose:class", "-Xbootclasspath/a:" + appJar, "Hello") + .assertAbnormalExit(mismatchMessage); + } + private static void copyHelloToNewDir() throws Exception { String classDir = System.getProperty("test.classes"); String dstDir = classDir + File.separator + "newdir";