> Consider the following command: > > jlink --add-modules java.management.rmi,jdk.httpserver --output image > > Running it repeatedly with identical inputs does not always produce the same > `lib/modules` file. The only differing resource is > `java.base/jdk/internal/module/SystemModules$all.class` (or > `SystemModules$default.class`), generated by `SystemModulesPlugin`. The > bytecode of `moduleReads()` differs only in the order in which the > deduplicated sets are created and the local-variable slots in which they are > stored. > > The problem occurs near the beginning of > `SystemModulesPlugin.SystemModulesClassGenerator.generate(...)`, where > duplicate map values are identified and assigned to local-variable slots in a > nondeterministic order. Later in the same method, however, the map entries > are emitted deterministically using a `TreeMap`. > > The proposed change uses the same `TreeMap` for value deduplication and > local-variable-slot assignment, making the generated bytecode deterministic. > > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
Dušan Bálek has updated the pull request incrementally with one additional commit since the last revision: Update test/jdk/tools/jlink/JLinkReproducible4Test.java ------------- Changes: - all: https://git.openjdk.org/jdk/pull/32948/files - new: https://git.openjdk.org/jdk/pull/32948/files/8ba30050..3ed9b054 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=32948&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=32948&range=00-01 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/32948.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/32948/head:pull/32948 PR: https://git.openjdk.org/jdk/pull/32948
