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

[UnmanagedFunctionPointer] on delegates #1262

Closed
Tracked by #1192
jonpryor opened this issue Sep 30, 2024 · 0 comments · Fixed by #1281
Closed
Tracked by #1192

[UnmanagedFunctionPointer] on delegates #1262

jonpryor opened this issue Sep 30, 2024 · 0 comments · Fixed by #1281
Labels
enhancement Proposed change to current functionality generator Issues binding a Java library (generator, class-parse, etc.)
Milestone

Comments

@jonpryor
Copy link
Member

Context: 2197579

NativeAOT doesn't like this by default. In order to convince
NativeAOT to support this, every delegate instance provided to
JniNativeMethodRegistration.Delegate must be of a delegate type
which has UnmanagedFunctionPointerAttribute. This coerces
NativeAOT to emit "stubs" for the referenced method, allowing things
to work with fewer changes.

For possible future NativeAOT support, every _JniMarshal_* delegate emitted by generator needs to have [UnmanagedFunctionPointer], a'la:

[UnmanagedFunctionPointer (CallingConvention.Winapi)]
delegate long _JniMarshal_PP_L (IntPtr env, IntPtr klass, long value);
@jonpryor jonpryor added this to the .NET 10 milestone Sep 30, 2024
@jpobst jpobst added enhancement Proposed change to current functionality generator Issues binding a Java library (generator, class-parse, etc.) labels Oct 1, 2024
jonpryor pushed a commit to dotnet/android that referenced this issue Dec 7, 2024
Fixes: dotnet/java-interop#1262

Changes: dotnet/java-interop@2d48efe...619286d

  * dotnet/java-interop@619286d5: [generator] Add `[UnmanagedFunctionPointer]` to `_JniMarshal*` decls (dotnet/java-interop#1281)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Proposed change to current functionality generator Issues binding a Java library (generator, class-parse, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants