RFR: 8252730: jlink does not create reproducible builds on different servers

Ian Graves igraves at openjdk.java.net
Mon Sep 14 21:41:35 UTC 2020


On Mon, 14 Sep 2020 21:32:19 GMT, Stuart Marks <smarks at 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.
>
> 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);

This is a good catch. I'm partial to flatMap, but unsure if that gets too clever what we're trying to do here or not.

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

PR: https://git.openjdk.java.net/jdk/pull/156


More information about the core-libs-dev mailing list