Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

No description provided.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 8, 2025
@rakachan
Copy link
Member

rakachan commented May 8, 2025

This is the preliminary PR that kickstarts the work on #10239 and #4625.
For trying it out, run espresso with --experimental-options --java.UseEspressoLibs=true

Currently, this is only runs Hello World.

For impl details:

  • We are re-using the Espresso substitution mechanisms to implement guest native methods. These substitutions get associated with a given "library" through the group annotation value. This allows associating java.lang._ methods to libjava and sun.nio._ methods to libnio for example.
  • The EspressoLibsNativeAccess class intercepts the various requests to load native libraries, and provides handles to our own substitution groups. The VM is in control of how libjava is loaded.
  • By providing our own "native" implementation for NativeLibraries.load and NativeLibraries.findBuiltinLib, we can intercept the loading of known libraries (Such as libnio, libzip, etc), and link against our own.
  • Note: Though created with the same mechanisms, these native-"Substitutions" are not like the original substitutions: They do not replace the guest call unconditionally, and are required to be native-linked (in Method.findJniCallTarget) before they can be executed. As such, methods that are not native can not be substituted this way.

@graalvmbot graalvmbot closed this May 10, 2025
@graalvmbot graalvmbot deleted the tg/e/java_libjava_v2 branch May 10, 2025 11:21
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