RFR: 8214230: Classes generated by SystemModulesPlugin.java are not reproducable
Claes Redestad
claes.redestad at oracle.com
Wed Nov 28 13:49:37 UTC 2018
Hi Erik,
looks good to me!
(Nit) You could consider the old TreeMap trick to ensure key-sorted map
iteration order:
// convert to a TreeMap to ensure sorted iteration order for (var e :
new TreeMap<>(map).entrySet()) { Thanks!
/Claes
On 2018-11-28 10:59, Erik Helin wrote:
> Hi all,
>
> this small patch ensures that two classes generated by jlink's
> SystemModulePlugin (SystemModules$default and SystemModules$all) are
> generated in a reproducible manner. That is, if you run jlink two
> times in a row with identical input, then the generated classes from
> both runs should be identical. This was almost the case already, the
> only issue is that some code in SystemModulesPlugin.java are iterating
> over Sets, and Set does not have a specified iteration order (the
> iteration order did differ between runs).
>
> This patch ensures that the iteration order over the sets is
> well-defined by creating an ArrayList from the Set, sorting that
> ArrayList and then finally iterate over the sorted ArrayList instead
> of the Set.
>
> For smaller programs jlink will now produce reproducible results, the
> entire lib/modules file will be reproducible [0]. I have added a JTReg
> test to verify this property (again, for smaller programs).
>
> Webrev:
> https://cr.openjdk.java.net/~ehelin/8214230/00/
>
> Bug:
> https://bugs.openjdk.java.net/browse/JDK-8214230
>
> Testing:
> - tier1, tier2 and tier3 on macOS, Windows, Linux (all x86-64).
> - Run newly developed JTReg test on macOS, Windows, Linux (all x86-64).
> - Run newly developed JTReg test with the fix absent and verified that
> the test failed.
>
> Many thanks to Alan Bateman for helping out with the patch!
>
> Thanks,
> Erik
>
> [0]: https://reproducible-builds.org/docs/definition/
More information about the jigsaw-dev
mailing list