On Mon, 26 Oct 2026 06:34:56 GMT, Alan Bateman <[email protected]> wrote:

> Module$ReflectionData stores the additions to readability, exports/opens and 
> service use when the reflective APIs are used at runtime. Unfortunately a 
> short cut in JDK 9 means it is also being used for the --add-reads command 
> line option and the special read edge to allow automatic modules read all 
> unnamed modules. Not an issue until an AOT cache is created with an automatic 
> module or with the--add-reads CLI option. As the ReflectionData is not in the 
> AOT cache then the production run will have an incomplete module graph.
> 
> The changes proposed means that ReflectionData is added added to creating an 
> automatic module when when handling the --add-reads CLI option. Any runtime 
> uses of Module.addReads will add to RD as before.
> 
> A new test it added to ensure that ReflectionData is "empty" at startup. Ioi 
> has contributed a new test to runtime/cds/appcds/aotCache/ that creates an 
> AOT cache with an automatic module and checks that the expected readability 
> is present in the production run.
> 
> Testing: tier1-3
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Marked as reviewed by liach (Reviewer).

test/hotspot/jtreg/runtime/cds/appcds/aotCache/AutomaticModuleTest.java line 26:

> 24: 
> 25: /*
> 26:  * @test automatic modules can read all unnamed modules, and vice versa, 
> even if AOT cache is used.

Suggestion:

 * @test
 * @summary automatic modules can read all unnamed modules, and vice versa, 
even if AOT cache is used.

test/jdk/java/lang/ModuleTests/reflectionData/java.base/java/lang/ModuleHelper.java
 line 27:

> 25: 
> 26: /**
> 27:  * Helper class to patch to java.base and provide access to 
> java.lang.Module internals.

Might be helpful if we can provide a comment that we avoid using exports/opens 
due to the fragility of the test?

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

PR Review: https://git.openjdk.org/jdk/pull/33559#pullrequestreview-5672229939
PR Review Comment: https://git.openjdk.org/jdk/pull/33559#discussion_r4392527215
PR Review Comment: https://git.openjdk.org/jdk/pull/33559#discussion_r4392518918

Reply via email to