On Wed, 22 Jun 2022 21:45:25 GMT, Naoto Sato <na...@openjdk.org> wrote:

>> IIUC, once this fix makes it to the repository, the build will be 
>> reproducible. Making it to be sorted is a welcome enhancement (I compare the 
>> generated bundles manually from time to time), but it may be costly so it 
>> could defy the performance improvement?
>
> BTW, this can utilize the new `HashMap.newHashMap()`, although I don't think 
> resizing would be occurring in this case.

> once this fix makes it to the repository, the build will be reproducible

Yes, we always produce the same source code. Given the same order of 
modifications, a hashmap will produce the same iteration order.

> LinkedHashMap could be used to retain the iteration order.

Just added. The input maps were always sorted in some order (they were either 
LinkedHashMaps or TreeMaps), and now we preserve that order.
This means a lot of changes in the generated output files now, but hopefully in 
the future the changes will be much easier to review.

TIL: `put` / `putIfAbsent` on an existing entry does not change the iteration 
order of a `LinkedHashMap` unless `accessOrder` is true.

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

PR: https://git.openjdk.org/jdk/pull/9243

Reply via email to