Skip to content

[Java.Interop] Fix RawCallStaticObjectMethodA PInvoke call#1411

Open
jonathanpeppers wants to merge 1 commit intomainfrom
jonathanpeppers/fix-pinvoke-instance-arg
Open

[Java.Interop] Fix RawCallStaticObjectMethodA PInvoke call#1411
jonathanpeppers wants to merge 1 commit intomainfrom
jonathanpeppers/fix-pinvoke-instance-arg

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

Summary

Remove undeclared instance variable from the PInvoke path in RawCallStaticObjectMethodA. The call was passing 6 arguments to a 5-parameter PInvoke: (env, out thrown, clazz, instance, jmethodID, args).

The correct call should only pass: (env, out thrown, clazz, jmethodID, args).

Context

Found while investigating the Mono.Android.NET_Tests-Debug test failure in dotnet/android#11171. The test failure itself appears to be a flaky emulator reboot (lowmemorykiller dropped, SystemServer restarted) — not caused by the Java.Interop changes. However, this latent bug was introduced in #1410 and should be fixed.

This is currently dead code since modern builds use function pointers (FEATURE_JNIENVIRONMENT_JI_FUNCTION_POINTERS), but would cause a compilation error if the PInvoke path (FEATURE_JNIENVIRONMENT_JI_PINVOKES) is ever re-enabled.

Remove undeclared `instance` variable from the PInvoke path in
RawCallStaticObjectMethodA. The call was passing 6 arguments to a
5-parameter PInvoke: (env, out thrown, clazz, instance, jmethodID, args).

This is currently dead code since modern builds use function pointers
(FEATURE_JNIENVIRONMENT_JI_FUNCTION_POINTERS), but would cause a
compilation error if the PInvoke path is ever re-enabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 17:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an incorrect P/Invoke invocation in the FEATURE_JNIENVIRONMENT_JI_PINVOKES path for RawCallStaticObjectMethodA by removing an extra (undeclared) instance argument so the call matches the native signature.

Changes:

  • Remove the stray instance argument from java_interop_jnienv_call_static_object_method_a invocation in RawCallStaticObjectMethodA.
  • Ensure the P/Invoke call argument list aligns with the native API (env, thrown, clazz, jmethodID, args).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants