Skip to content

[jnimarshalmethod-gen] Finish support of delegates for methods with 15+ parameters #11909

Closed

Description

@radekdoulik

Commit 857b9a9405c6d69de9a95771044289e8f895427b introduced the support of 15+ parameters methods. The changes in jnimarshalmethod-gen are incomplete though and we end up with a generated code, which uses reflection to get a type, which doesn't exist.

Like the generated code here (from Mono.Android-JniMarshalMethods.dll):

    IL_0122:  ldstr      "Delegate18$1"
    IL_0127:  ldc.i4.1
    IL_0128:  call       [mscorlib]System.Type [mscorlib]System.Type::GetType(string, bool)

It happens, because the Delegate18$1 type is created by SLE on the fly and exists in memory only. jnimarshalmethod-gen doesn't know about that yet.

We need to save the in-memory-only type to our marshaling class and change the name to reflect the parameter types.

Currently the in-memory-only type is placed in Snippets assembly. An example:

assembly qualified name: Delegate18$1, Snippets, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
the delegate:            lambda (__jnienv, __class, srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight, srcDepth) => {var __envp;var __jvm; ... }

We should save the type from the example to the assembly containing the marshaling __<$>_jni_marshal_methods class and name it something like __<$>_JniMarshal_PPIIIIIIIIIIIIIII_V or maybe to be more consistent as __<$>_jni_marshal_PPIIIIIIIIIIIIIII_V. And also update the generated code to use it.

Activity

  1. self-assigned this
    on Sep 7, 2020
  2. changed the title [-]Fix delegates for methods with 15+ parameters[/-] [+][jnimarshalmethod-gen] Finish support of delegates for methods with 15+ parameters[/+] on Sep 7, 2020
  3. added
    enhancementProposed change to current functionality.
    on Sep 8, 2020
  4. added theissue type on Apr 29, 2025
  5. removed
    enhancementProposed change to current functionality.
    on Apr 29, 2025
  6. added
    java-interopIssues migrated from dotnet/java-interop / relates to the Java.Interop subtree
    needs-triageIssues that need to be assigned.
    Area: BindingsIssues in Java Library Binding projects.
    on Jul 1, 2026
  7. dotnet-policy-service commented on Jul 1, 2026

    @dotnet-policy-service

    We suspect this issue is stale and no longer relevant. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

  8. dotnet-policy-service commented on Jul 15, 2026

    @dotnet-policy-service

    This issue will now be closed since it had been marked "possibly-stale" but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  9. locked and limited conversation to collaborators on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: BindingsIssues in Java Library Binding projects.java-interopIssues migrated from dotnet/java-interop / relates to the Java.Interop subtreeneeds-triageIssues that need to be assigned.possibly-staleIssues that are potentially no longer relevant.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions