< prev index next >

test/hotspot/jtreg/runtime/appcds/BootClassPathMismatch.java

Print this page

        

*** 32,41 **** --- 32,43 ---- * jdk.jartool/sun.tools.jar * @compile test-classes/Hello.java * @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; import java.nio.file.FileAlreadyExistsException; import java.nio.file.StandardCopyOption;
*** 50,63 **** copyHelloToNewDir(); BootClassPathMismatch test = new BootClassPathMismatch(); test.testBootClassPathMismatch(); test.testBootClassPathMismatch2(); test.testBootClassPathMatch(); } ! /* Error should be detected if: * dump time: -Xbootclasspath/a:${testdir}/hello.jar * run-time : -Xbootclasspath/a:${testdir}/newdir/hello.jar */ public void testBootClassPathMismatch() throws Exception { String appJar = JarBuilder.getOrCreateHelloJar(); --- 52,68 ---- copyHelloToNewDir(); BootClassPathMismatch test = new BootClassPathMismatch(); test.testBootClassPathMismatch(); test.testBootClassPathMismatch2(); + test.testBootClassPathMismatchWithAppend(); test.testBootClassPathMatch(); } ! /* 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 */ public void testBootClassPathMismatch() throws Exception { String appJar = JarBuilder.getOrCreateHelloJar();
*** 69,92 **** TestCommon.run( "-cp", appJar, "-verbose:class", "-Xbootclasspath/a:" + otherJar, "Hello") .assertAbnormalExit(mismatchMessage); } ! /* Error should be detected if: ! * dump time: <no bootclasspath specified> ! * 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: * dump time: -Xbootclasspath/a:${testdir}/hello.jar * run-time : -Xbootclasspath/a:${testdir}/hello.jar */ public void testBootClassPathMatch() throws Exception { String appJar = TestCommon.getTestJar("hello.jar"); --- 74,86 ---- TestCommon.run( "-cp", appJar, "-verbose:class", "-Xbootclasspath/a:" + otherJar, "Hello") .assertAbnormalExit(mismatchMessage); } ! /* 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 */ public void testBootClassPathMatch() throws Exception { String appJar = TestCommon.getTestJar("hello.jar");
*** 97,106 **** --- 91,131 ---- "-cp", appJar, "-verbose:class", "-Xbootclasspath/a:" + appJar, "Hello") .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: <no bootclasspath specified> + * 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"; try { Files.createDirectory(Paths.get(dstDir));
< prev index next >