This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Repository navigation
[Java.Interop] Register ManagedPeer natives via blittable function pointers - #1490
Closed
simonrozsival wants to merge 2 commits into
Closed
simonrozsival wants to merge 2 commits into
simonrozsival wants to merge 2 commits into
Conversation
…inters Replace the delegate-based JniNativeMethodRegistration registration of ManagedPeer's construct/registerNativeMembers natives with the blittable RegisterNatives(ReadOnlySpan<JniNativeMethod>) overload, using [UnmanagedCallersOnly] static methods and statically-compiled function pointers. This removes the need for runtime delegate marshaling (and the associated IL3050/dynamic-code requirement), making the registration path NativeAOT-friendly. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Updates ManagedPeer native method registration to use the blittable RegisterNatives(ReadOnlySpan<JniNativeMethod>) path with statically-compiled unmanaged function pointers, removing the prior delegate-marshaling/dynamic-code requirement and improving NativeAOT compatibility.
Changes:
- Switches
ManagedPeer’sconstruct/registerNativeMembersnatives to[UnmanagedCallersOnly]+delegate* unmanaged<>function pointers. - Registers natives via UTF-8 (
u8) name/signature literals passed as fixed pointers. - Removes now-unused
usingdirectives and the prior IL3050/dynamic-code suppression for the static constructor.
Show a summary per file
| File | Description |
|---|---|
| src/Java.Interop/Java.Interop/ManagedPeer.cs | Replaces delegate-based native registration with blittable JniNativeMethod + unmanaged function pointers for AOT-friendly native registration. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 3
…rs log typo Co-authored-by: Copilot <[email protected]>
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the delegate-based
JniNativeMethodRegistrationregistration ofManagedPeer'sconstruct/registerNativeMembersJNI natives with the blittableRegisterNatives(ReadOnlySpan<JniNativeMethod>)overload.Details
[UnmanagedCallersOnly]static methods (Construct,RegisterNativeMembers) and statically-compileddelegate* unmanaged<>function pointers instead of[UnmanagedFunctionPointer]delegates.u8) name/signature literals directly to JNI viafixedpointers.IL3050/dynamic-code suppression on the static constructor is no longer needed — making the registration path NativeAOT-friendly.usingdirectives (System.Linq,System.Linq.Expressions,System.Reflection.Emit,System.Runtime.Serialization).No behavioral change: the same two natives are registered on the same
net/dot/jni/ManagedPeertype; the blittableRegisterNativesoverload preserves the prior pending-exception handling.