Skip to content

Commit fd31f6a

Browse files
Maxim Kartashevcalvinccheung
Maxim Kartashev
authored andcommitted
8321183: Incorrect warning from cds about the modules file
Reviewed-by: ccheung, iklam
1 parent 027b5db commit fd31f6a

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

src/hotspot/share/cds/filemap.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -397,23 +397,25 @@ bool SharedClassPathEntry::validate(bool is_class_path) const {
397397
log_warning(cds)("directory is not empty: %s", name);
398398
ok = false;
399399
}
400-
} else if ((has_timestamp() && _timestamp != st.st_mtime) ||
401-
_filesize != st.st_size) {
402-
ok = false;
403-
if (PrintSharedArchiveAndExit) {
404-
log_warning(cds)(_timestamp != st.st_mtime ?
405-
"Timestamp mismatch" :
406-
"File size mismatch");
407-
} else {
408-
const char* bad_jar_msg = "A jar file is not the one used while building the shared archive file:";
409-
log_warning(cds)("%s %s", bad_jar_msg, name);
410-
if (!log_is_enabled(Info, cds)) {
411-
log_warning(cds)("%s %s", bad_jar_msg, name);
412-
}
413-
if (_timestamp != st.st_mtime) {
414-
log_warning(cds)("%s timestamp has changed.", name);
400+
} else {
401+
bool size_differs = _filesize != st.st_size;
402+
bool time_differs = has_timestamp() && _timestamp != st.st_mtime;
403+
if (time_differs || size_differs) {
404+
ok = false;
405+
if (PrintSharedArchiveAndExit) {
406+
log_warning(cds)(time_differs ? "Timestamp mismatch" : "File size mismatch");
415407
} else {
416-
log_warning(cds)("%s size has changed.", name);
408+
const char* bad_file_msg = "This file is not the one used while building the shared archive file:";
409+
log_warning(cds)("%s %s", bad_file_msg, name);
410+
if (!log_is_enabled(Info, cds)) {
411+
log_warning(cds)("%s %s", bad_file_msg, name);
412+
}
413+
if (time_differs) {
414+
log_warning(cds)("%s timestamp has changed.", name);
415+
}
416+
if (size_differs) {
417+
log_warning(cds)("%s size has changed.", name);
418+
}
417419
}
418420
}
419421
}

test/hotspot/jtreg/runtime/cds/appcds/WrongClasspath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static void main(String[] args) throws Exception {
108108
// message should be there.
109109
output = TestCommon.execAuto(
110110
"-cp", jars, "Hello");
111-
output.shouldMatch("A jar file is not the one used while building the shared archive file:.*jar2.jar")
111+
output.shouldMatch("This file is not the one used while building the shared archive file:.*jar2.jar")
112112
.shouldMatch(".warning..cds.*jar2.jar timestamp has changed.");
113113
}
114114
}

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public static void doTest(String topArchiveName) throws Exception {
204204
"--module-path", moduleDir.toString(),
205205
"-m", TEST_MODULE1)
206206
.assertAbnormalExit(
207-
"A jar file is not the one used while building the shared archive file:");
207+
"This file is not the one used while building the shared archive file:");
208208
// create an archive with a non-empty directory in the --module-path.
209209
// The dumping process will exit with an error due to non-empty directory
210210
// in the --module-path.

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/WrongTopClasspath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void test(String args[]) throws Exception {
111111
"assertNotShared:GenericTestApp") // but top archive is not useable
112112
.assertNormalExit(output -> {
113113
output.shouldContain(topArchiveMsg);
114-
output.shouldMatch("A jar file is not the one used while building the shared archive file:.*GenericTestApp.jar");
114+
output.shouldMatch("This file is not the one used while building the shared archive file:.*GenericTestApp.jar");
115115
output.shouldMatch(".warning..cds.*GenericTestApp.jar timestamp has changed.");});
116116
}
117117
}

test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class MainModuleOnly {
6565
private static Path moduleDir2 = null;
6666
private static Path destJar = null;
6767

68-
private static final String jarFileError = "A jar file is not the one used while building the shared archive file:";
68+
private static final String jarFileError = "This file is not the one used while building the shared archive file:";
6969

7070
public static void buildTestModule() throws Exception {
7171

0 commit comments

Comments
 (0)