8321183: Incorrect warning from cds about the modules file

Reviewed-by: ccheung, iklam
This commit is contained in:
Maxim Kartashev 2023-12-05 17:17:14 +00:00 committed by Calvin Cheung
parent 027b5dbb6a
commit fd31f6a166
5 changed files with 22 additions and 20 deletions

View File

@ -397,23 +397,25 @@ bool SharedClassPathEntry::validate(bool is_class_path) const {
log_warning(cds)("directory is not empty: %s", name);
ok = false;
}
} else if ((has_timestamp() && _timestamp != st.st_mtime) ||
_filesize != st.st_size) {
ok = false;
if (PrintSharedArchiveAndExit) {
log_warning(cds)(_timestamp != st.st_mtime ?
"Timestamp mismatch" :
"File size mismatch");
} else {
const char* bad_jar_msg = "A jar file is not the one used while building the shared archive file:";
log_warning(cds)("%s %s", bad_jar_msg, name);
if (!log_is_enabled(Info, cds)) {
log_warning(cds)("%s %s", bad_jar_msg, name);
}
if (_timestamp != st.st_mtime) {
log_warning(cds)("%s timestamp has changed.", name);
} else {
bool size_differs = _filesize != st.st_size;
bool time_differs = has_timestamp() && _timestamp != st.st_mtime;
if (time_differs || size_differs) {
ok = false;
if (PrintSharedArchiveAndExit) {
log_warning(cds)(time_differs ? "Timestamp mismatch" : "File size mismatch");
} else {
log_warning(cds)("%s size has changed.", name);
const char* bad_file_msg = "This file is not the one used while building the shared archive file:";
log_warning(cds)("%s %s", bad_file_msg, name);
if (!log_is_enabled(Info, cds)) {
log_warning(cds)("%s %s", bad_file_msg, name);
}
if (time_differs) {
log_warning(cds)("%s timestamp has changed.", name);
}
if (size_differs) {
log_warning(cds)("%s size has changed.", name);
}
}
}
}

View File

@ -108,7 +108,7 @@ public class WrongClasspath {
// message should be there.
output = TestCommon.execAuto(
"-cp", jars, "Hello");
output.shouldMatch("A jar file is not the one used while building the shared archive file:.*jar2.jar")
output.shouldMatch("This file is not the one used while building the shared archive file:.*jar2.jar")
.shouldMatch(".warning..cds.*jar2.jar timestamp has changed.");
}
}

View File

@ -204,7 +204,7 @@ public class MainModuleOnly extends DynamicArchiveTestBase {
"--module-path", moduleDir.toString(),
"-m", TEST_MODULE1)
.assertAbnormalExit(
"A jar file is not the one used while building the shared archive file:");
"This file is not the one used while building the shared archive file:");
// create an archive with a non-empty directory in the --module-path.
// The dumping process will exit with an error due to non-empty directory
// in the --module-path.

View File

@ -111,7 +111,7 @@ public class WrongTopClasspath extends DynamicArchiveTestBase {
"assertNotShared:GenericTestApp") // but top archive is not useable
.assertNormalExit(output -> {
output.shouldContain(topArchiveMsg);
output.shouldMatch("A jar file is not the one used while building the shared archive file:.*GenericTestApp.jar");
output.shouldMatch("This file is not the one used while building the shared archive file:.*GenericTestApp.jar");
output.shouldMatch(".warning..cds.*GenericTestApp.jar timestamp has changed.");});
}
}

View File

@ -65,7 +65,7 @@ public class MainModuleOnly {
private static Path moduleDir2 = null;
private static Path destJar = null;
private static final String jarFileError = "A jar file is not the one used while building the shared archive file:";
private static final String jarFileError = "This file is not the one used while building the shared archive file:";
public static void buildTestModule() throws Exception {