mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-11 08:23:26 +00:00
8174101: Bootclasspath append should not invalidate CDS archive
Reviewed-by: iklam, jiangli
This commit is contained in:
parent
d470bc0546
commit
40f06dc0e3
@ -139,7 +139,8 @@ bool SharedPathsMiscInfo::check() {
|
||||
bool SharedPathsMiscInfo::check(jint type, const char* path) {
|
||||
switch (type) {
|
||||
case BOOT:
|
||||
if (os::file_name_strcmp(path, Arguments::get_sysclasspath()) != 0) {
|
||||
// In the future we should perform the check based on the content of the mapped archive.
|
||||
if (UseAppCDS && os::file_name_strcmp(path, Arguments::get_sysclasspath()) != 0) {
|
||||
return fail("[BOOT classpath mismatch, actual =", Arguments::get_sysclasspath());
|
||||
}
|
||||
break;
|
||||
|
||||
@ -86,6 +86,9 @@ public class BootAppendTests {
|
||||
|
||||
logTestCase("5");
|
||||
testBootAppendClass();
|
||||
|
||||
logTestCase("6");
|
||||
testBootAppendExtraDir();
|
||||
}
|
||||
|
||||
private static void logTestCase(String msg) {
|
||||
@ -241,4 +244,28 @@ public class BootAppendTests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@ public class BootClassPathMismatch {
|
||||
|
||||
BootClassPathMismatch test = new BootClassPathMismatch();
|
||||
test.testBootClassPathMismatch();
|
||||
test.testBootClassPathMismatch2();
|
||||
test.testBootClassPathMatch();
|
||||
}
|
||||
|
||||
@ -78,6 +79,26 @@ public class BootClassPathMismatch {
|
||||
}
|
||||
}
|
||||
|
||||
/* 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"};
|
||||
OutputAnalyzer dumpOutput = TestCommon.dump(appJar, appClasses);
|
||||
OutputAnalyzer execOutput = TestCommon.exec(
|
||||
appJar, "-verbose:class", "-Xbootclasspath/a:" + appJar, "Hello");
|
||||
try {
|
||||
TestCommon.checkExec(execOutput, mismatchMessage);
|
||||
} catch (java.lang.RuntimeException re) {
|
||||
String cause = re.getMessage();
|
||||
if (!mismatchMessage.equals(cause)) {
|
||||
throw re;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* No error if:
|
||||
* dump time: -Xbootclasspath/a:${testdir}/hello.jar
|
||||
* run-time : -Xbootclasspath/a:${testdir}/hello.jar
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user