On Mon, 15 Nov 2021 18:47:34 GMT, Andrew Leonard <aleon...@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 <anleo...@redhat.com> src/jdk.jartool/share/classes/sun/tools/jar/Main.java line 131: > 129: // There's also a files array per version > 130: // Use a LinkedHashMap to keep original insertion ordering > 131: Map<Integer,String[]> filesMap = new LinkedHashMap<>(); The entries of `filesMap` is sorted by the version. Is the value of each entry already sorted? Does that matter? It's unclear to me since `expand` is called for each entry's value: private void expand() throws IOException { for (int version : filesMap.keySet()) { String[] files = filesMap.get(version); expand(null, files, pathsMap.get(version), version); } } src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java line 803: > 801: out.writeEntry(in, section, name); > 802: } > 803: } jmod change is okay. test/jdk/tools/jar/ContentOrder.java line 79: > 77: @Test > 78: public void test1() throws IOException { > 79: mkdir("testjar/Ctest1 testjar/Btest2/subdir1 testjar/Atest3"); I suggest to make `mkdir` and `touch` to take a vararg of String or Path and the method body concatenates the input strings to build the command line. ------------- PR: https://git.openjdk.java.net/jdk/pull/6395