On Thu, 18 Nov 2021 10:02:45 GMT, Magnus Ihse Bursie <i...@openjdk.org> wrote:

>> @mlchung the way I looked at this was the filesMap is a HashMap, so the 
>> filesMap.keySet() iteration order is not defined (or necessarily 
>> deterministic), the expanded order of the file sets for each version could 
>> be ver1, ver2, ver3 or ver3, ver2, ver1... the next time you run it with the 
>> same parameters.
>> LinkedHashMap will ensure the iterated order is as inserted (or as specified 
>> in the jar args list..)
>> 
>> Although you say "filesMap is sorted by version", I don't see where that is 
>> done?
>
> I'm guessing Mandy asks not if the keys are sorted -- this is changed by your 
> patch, but if the value retrieved -- the String[], is sorted. It's a valid 
> question, I think. It's not apparent to me at least that this is the case. If 
> it is not sorted when it is inserted it needs to be sorted when extracted.

@magicus 
ah right, got you.  So the order of each version's String[] is as ordered on 
the jar cmd line args:
https://github.com/openjdk/jdk/blob/3e87db19bb7e2359e4b1ceaac7c123542345ecb1/src/jdk.jartool/share/classes/sun/tools/jar/Main.java#L664

So for the same jar cmdline input, the output will be deterministic, as in the 
same order.
If we think we need to be deterministic for different jar cmdline input for the 
same set of files, I can add a sort, but that wasn't my aim. eg: both these 
produce the same order?
    jar --create --file my.jar --release 9 v9classesdir1 v9classesdir2
    jar --create --file my.jar --release 9 v9classesdir2 v9classesdir1 
My aim was same input == same output
?

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

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

Reply via email to