RFR: 8214230: Classes generated by SystemModulesPlugin.java are not reproducable

Mandy Chung mandy.chung at oracle.com
Wed Nov 28 17:55:04 UTC 2018



On 11/28/18 1:59 AM, 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/
>

Looks good to me.   I agree with Claes that you could simply use TreeMap.

Mandy


More information about the jigsaw-dev mailing list