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

Mandy Chung mchung at openjdk.java.net
Thu Nov 18 23:52:43 UTC 2021


On Thu, 18 Nov 2021 11:40:24 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

>> @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
>> ?
>
> Fair enough, that's a good answer. I did not know the origin of these values. If they are in command line order, I completely agree with you that this is the behavior we want.

@magicus Thanks for clarifying for my question.

@andrew-m-leonard Keeping it as the command-line order is good.   I suggest to add a comment to describe the order of  entries of `filesMap` and the order of the values.

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

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


More information about the compiler-dev mailing list