JDK-8352437 : Support --add-exports with -XX:+AOTClassLinking
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-03-19
  • Updated: 2025-05-15
  • Resolved: 2025-04-02
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 b17Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Description
When --add-exports 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-exports java.base/jdk.internal.misc=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.addexports=java.base/jdk.internal.misc=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-exports for AOT cache, and allow the AOT cache to be used as long as the exact same set of options --add-exports are used during assembly phase and production run.
Comments
Changeset: 096e70de Branch: master Author: Ioi Lam <iklam@openjdk.org> Date: 2025-04-02 01:37:27 +0000 URL: https://git.openjdk.org/jdk/commit/096e70de2d3009040d7ce30f3766167f43de4a96
02-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/24124 Date: 2025-03-20 04:46:21 +0000
27-03-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