JDK-8354083 : Support --add-reads with -XX:+AOTClassLinking
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 25
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-04-08
  • Updated: 2025-05-23
  • Resolved: 2025-05-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b24Fixed
Related Reports
Causes :  
Relates :  
Relates :  
Description
According to https://openjdk.org/jeps/261

<quote>
Increasing readability
When testing and debugging it is sometimes necessary to arrange for one module to read some other module, even though the first module does not depend upon the second via a requires clause in its module declaration. This may be needed to, e.g., enable a module under test to access the test harness itself, or to access libraries related to the harness. The --add-reads option can be used, at both compile time and run time, to do this. Its syntax is:

--add-reads <source-module>=<target-module>

where <source-module> and <target-module> are module names.
</quote>

In JDK 24, if an AOT cache is built with -XX:+AOTClassLinking (which is the default), the cache will not be useable if --add-reads is used for testing purposes as described above. This might hinder testing (e.g., for bugs that show up only when the AOT cache is enabled).

========
Proposal: Support  --add-reads for AOT caches created with -XX:+AOTClassLinking, as long as identical setting is applied to the training/assembly/production runs.

========
Work around: create AOT cache with -XX:-AOTClassLinking, but this will significantly limit the amount of available AOT optimizations.
Comments
Changeset: efdbb6af Branch: master Author: Calvin Cheung <ccheung@openjdk.org> Date: 2025-05-15 21:14:42 +0000 URL: https://git.openjdk.org/jdk/commit/efdbb6afce4116140c066641128264ab42697912
15-05-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25109 Date: 2025-05-08 00:19:17 +0000
08-05-2025

I fixed the title. It should be --add-reads. [~dholmes]
10-04-2025

This bug is about supporting "--add-opens" but the quote references "--add-reads". Which is it?
10-04-2025