RFR: 8276764: Enable deterministic file content ordering for Jar and Jmod
Magnus Ihse Bursie
ihse at openjdk.java.net
Thu Nov 18 11:45:41 UTC 2021
On Thu, 18 Nov 2021 11:05:54 GMT, Andrew Leonard <aleonard at openjdk.org> wrote:
>> 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
> ?
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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6395
More information about the compiler-dev
mailing list