Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-57608] Support --enable-native-access hosted option in native image #10076

Merged
merged 7 commits into from
Nov 29, 2024

Conversation

graalvmbot
Copy link
Collaborator

@graalvmbot graalvmbot commented Nov 12, 2024

This adds support for the --enable-native-access hosted option in the context of JEP 472: Prepare to Restrict the Use of JNI. The modules specified by this flags will be allowed to perform native access at run time. Note that similar to Hotspot, this flag only applied to the boot layer.

This change aligns the native access checks in native image to those in the JDK as outline in JEP 472.

Implementation Notes

To allow constant folding of native access checks at build time, the following optimizations are needed:

  • Annotate DynamicHub#module with @Stable. This now matches the Class@module definition.
  • Ensure that Module.EnableNativeAccess#isNativeAccessEnabled constant folds if Module#enableNativeAccess field is true. This "reimplements" the @Stable field optimization for Module#enablenativeAccess, which does not trigger because the field is only accessed via Unsafe.
  • Add an @Alias for Module.layer to make it non-final. The actual run-time value is set via reflection in ModuleLayerFeatureUtils#patchModuleLayerField, which is called after analysis. Thus, we cannot leave it final, because the analysis might otherwise constant-fold the initial null value.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 12, 2024
@zapster zapster self-assigned this Nov 12, 2024
@graalvmbot graalvmbot force-pushed the je/svm-adopt-JDK-8331671-master branch 5 times, most recently from 830a611 to ed86994 Compare November 13, 2024 12:03
@graalvmbot graalvmbot force-pushed the je/svm-adopt-JDK-8331671-master branch from ed86994 to 646135b Compare November 21, 2024 12:01
@graalvmbot graalvmbot changed the title RFC [GR-57608] Support --enable-native-access hosted option in native image [GR-57608] Support --enable-native-access hosted option in native image Nov 21, 2024
@graalvmbot graalvmbot force-pushed the je/svm-adopt-JDK-8331671-master branch from 646135b to 68c0f82 Compare November 28, 2024 08:44
@graalvmbot graalvmbot force-pushed the je/svm-adopt-JDK-8331671-master branch from e598c0c to b7a35bc Compare November 28, 2024 13:54
@graalvmbot graalvmbot closed this Nov 29, 2024
@graalvmbot graalvmbot deleted the je/svm-adopt-JDK-8331671-master branch November 29, 2024 10:16
@graalvmbot graalvmbot merged commit f1710cc into master Nov 29, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants