RFR: 8345431: Improve jar --validate to detect duplicate or invalid entries [v12]
Jaikiran Pai
jpai at openjdk.org
Thu May 22 11:59:02 UTC 2025
On Thu, 22 May 2025 01:29:12 GMT, Henry Jen <henryjen at openjdk.org> wrote:
>> This PR check the jar file to ensure entries are consistent from the central directory and local file header. Also check there is no duplicate entry names that could override the desired content by accident.
>
> Henry Jen has updated the pull request incrementally with one additional commit since the last revision:
>
> Validator to take a file, use term JAR file
test/jdk/tools/jar/ValidatorTest.java line 293:
> 291: } catch (IOException e) {
> 292: var err = e.getMessage();
> 293: assertTrue(err.contains("Warning: Central directory and local file header entries are not in the same order"));
Unlike in other tests, we are missing a `System.out.println(err)` before the assert here.
test/jdk/tools/jar/ValidatorTest.java line 308:
> 306: System.out.println(err);
> 307: for (var entryName : invalidEntryNames) {
> 308: assertTrue(err.contains("Warning: entry name " + entryName + " is not valid"));
To help debug any failures, it might be better to include the entryName that failed the assert, something like:
assertTrue(err.contains("Warning: entry name " + entryName + " is not valid"), "missing warning for " + entryName);
test/jdk/tools/jar/ValidatorTest.java line 325:
> 323: try {
> 324: int rc = JAR_TOOL.run(jarOut, err, cmdline.split(" +"));
> 325: if (rc != 0) {
Nit - should we add a `System.out.println("exit code: " + rc);`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24430#discussion_r2102370169
PR Review Comment: https://git.openjdk.org/jdk/pull/24430#discussion_r2102374499
PR Review Comment: https://git.openjdk.org/jdk/pull/24430#discussion_r2102379182
More information about the core-libs-dev
mailing list