On Mon, 14 Sep 2020 20:35:24 GMT, Ian Graves <igra...@openjdk.org> wrote:
> Related to [JDK-8252730 jlink does not create reproducible builds on different > servers](https://bugs.openjdk.java.net/browse/JDK-8252730). Introduces > ordering based on `Archive` module names to > ensure stable files (and file signatures) across generated JDK images by > jlink. Sorting the Archive instances makes more sense to me than trying to add hashCode/equals to Archive. I note that the instances added to the ResourcePoolManager are stored in a LinkedHashMap, so the sorted order should be preserved. I'll defer to Alan and Jim as to whether sorting by module name is the right thing. Additional code comments to follow. src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java line 274: > 272: e.getResourcePoolEntryName(), e)) > 273: .forEach(resources::add); > 274: }); I'm somewhat allergic to nested forEach plus statement lambdas. I note that the original code mixed an imperative for-loop with a stream, which was kind of odd; converting to a straight nested for-loop might be reasonable. Alternatively, the nested forEaches could be converted to a flatMap as follows: ` archives.stream() .map(Archive::moduleName) .sorted() .flatMap(mn -> entriesForModule.get(mn).stream() .map(e -> new ArchiveEntryResourcePoolEntry(mn, e.getResourcePoolEntryName(), e))) .forEach(resources::add); ` ------------- PR: https://git.openjdk.java.net/jdk/pull/156