RFR: 8276764: Enable deterministic file content ordering for Jar and Jmod

Magnus Ihse Bursie ihse at openjdk.java.net
Wed Nov 17 19:25:45 UTC 2021


On Mon, 15 Nov 2021 18:47:34 GMT, Andrew Leonard <aleonard at openjdk.org> wrote:

> Both jar and jmod utilise java.io file operations whose methods define no ordering of the return file lists, and in fact rely on OS query file ordering, which can differ by underlying OS architecture.
> This PR adds sort processing to the creation of such jar's and jmod's to enable a deterministic content ordering.
> 
> Signed-off-by: Andrew Leonard <anleonar at redhat.com>

Overall I think the change looks sane. A 1% performance penalty for tens of thousands of files in a single directory might be acceptable, since that is unusual.

Alan or someone else have to say if this needs a CSR, and/or a implNote.

src/jdk.jartool/share/classes/sun/tools/jar/Main.java line 828:

> 826:                     String[] dirFiles = f.list();
> 827:                     // Ensure files list is sorted for reproducible jar content
> 828:                     if (dirFiles != null)

Style issue. I strongly dislike multi-line if statements without braces. I don't know if that style is followed in the rest of the code, but if it seems to fit in I strongly recommend using braces.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6395


More information about the compiler-dev mailing list