JDK-8352003 : Support --add-opens with -XX:+AOTClassLinking
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 25
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-03-14
  • Updated: 2025-05-15
  • Resolved: 2025-04-25
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 b21Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
When --add-opens is specified with "java -XX:AOTMode=create", AOTClassLinking is disabled:

=================================
$ java -cp HelloWorld.jar -XX:AOTMode=record \
       -XX:AOTConfiguration=hw.aotconfig HelloWorld
Hello World
AOTConfiguration recorded: hw.aotconfig

$ java -Xlog:cds -XX:+AOTClassLinking --add-opens java.base/java.lang=ALL-UNNAMED \
       -cp HelloWorld.jar -XX:AOTMode=create -XX:AOTCache=hw.aot \
       -XX:AOTConfiguration=hw.aotconfig
[...]
[0.000s][info][cds] optimized module handling: disabled due to incompatible property: jdk.module.addopens=java.base/java.lang=ALL-UNNAMED
[...]
[0.456s][info][cds] Number of classes 1043
[0.456s][info][cds]     instance classes   =   891, aot-linked =     0, inited =     0
=================================

Proposal:

We should support --add-opens for AOT cache, and allow the AOT cache to be used as long as the exact same set of options --add-opens are used during assembly phase and production run.


Comments
Changeset: 597bcc69 Branch: master Author: Calvin Cheung <ccheung@openjdk.org> Date: 2025-04-25 16:12:35 +0000 URL: https://git.openjdk.org/jdk/commit/597bcc695347544b9feffc5280741b1e9e1715f7
25-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/24695 Date: 2025-04-16 18:21:41 +0000
16-04-2025

Request for --add-opens posted on https://www.reddit.com/r/java/comments/1jtk60f/aotlinking_classes_in_jdk24_not_supported_with/
10-04-2025

One Leyden user reported that they have an app that depends on the following --add-exports and --add-opens options: --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/jdk.internal.util.random=ALL-UNNAMED --add-exports=java.base/sun.net.dns=ALL-UNNAMED --add-exports=java.base/sun.net.util=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED --add-exports=java.management/sun.management=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED --add-exports=java.xml/com.sun.org.apache.xerces.internal.jaxp=ALL-UNNAMED --add-exports=java.base/jdk.internal.util.random=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.regex=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.stream=ALL-UNNAMED --add-opens=java.base/java.util.stream=ALL-UNNAMED --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED --add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.fs=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED --add-opens=java.base/sun.security.x509=ALL-UNNAMED --add-opens=java.base/javax.net.ssl=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.file=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/java.time.format=ALL-UNNAMED --add-opens=java.sql/java.sql=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED
24-03-2025