From fd31f6a1663de0e06accdf015a71086346aa0d98 Mon Sep 17 00:00:00 2001 From: Maxim Kartashev Date: Tue, 5 Dec 2023 17:17:14 +0000 Subject: [PATCH] 8321183: Incorrect warning from cds about the modules file Reviewed-by: ccheung, iklam --- src/hotspot/share/cds/filemap.cpp | 34 ++++++++++--------- .../runtime/cds/appcds/WrongClasspath.java | 2 +- .../appcds/dynamicArchive/MainModuleOnly.java | 2 +- .../dynamicArchive/WrongTopClasspath.java | 2 +- .../jigsaw/modulepath/MainModuleOnly.java | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 951077dcd46..0810c17c00a 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -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); + } } } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/WrongClasspath.java b/test/hotspot/jtreg/runtime/cds/appcds/WrongClasspath.java index 20cc0426dd1..9fb88e0b00c 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/WrongClasspath.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/WrongClasspath.java @@ -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."); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java index 095f4bb8349..0dd4af2e450 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java @@ -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. diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/WrongTopClasspath.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/WrongTopClasspath.java index f1fa509a67c..54c5e66ab18 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/WrongTopClasspath.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/WrongTopClasspath.java @@ -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.");}); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java index 83a4d73fdce..50191b91e1e 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java @@ -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 {