On Fri, 18 Sep 2026 11:35:27 GMT, Dušan Bálek <[email protected]> wrote:

> 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).

test/jdk/tools/jlink/JLinkReproducible4Test.java line 40:

> 38:  * @library /test/lib
> 39:  * @build jdk.test.lib.util.FileUtils
> 40:  * @run main JLinkReproducible4Test

Can this test be made JEP 493-enabled-jdk-compatible, please:

Suggestion:

 * @run main/othervm JLinkReproducible4Test

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32948#discussion_r4046574441

Reply via email to