Skip to content

[generator] Bind List<ValueClass> as IList<ValueClass> #13668

Open

Description

@jonathanpeppers

Android framework version

net12.0-android (Preview)

Affected platform version

dotnet/android main with #13581

Description

A Kotlin value class in a generic type argument is passed boxed. #13581 binds it as Java.Lang.Object, because JavaList<T> cannot hold a struct:

fun lengths(count: Int): List<Meters>
public static IList<Java.Lang.Object> Lengths (int count);

Callers must convert each item with Meters.FromJniHandle (item.Handle, JniHandleOwnership.DoNotTransfer). Each item that C# reads also creates a managed peer (a GC handle plus an object) before it is unboxed.

Expected: bind List<Meters> as IList<Meters> (and similar for Set, Map, Collection), using a typed adapter that calls unbox-impl/box-impl for each item and creates no peer.

Steps to Reproduce

  1. Bind a Kotlin library with fun lengths(count: Int): List<Meters>, where Meters is a @JvmInline value class.
  2. The generated method returns IList<Java.Lang.Object>.

Did you find any workaround?

Meters.FromJniHandle (item.Handle, JniHandleOwnership.DoNotTransfer) for each item.

Relevant log output

N/A

Activity

  1. added this to the .NET 12 milestone on Nov 19, 2026
  2. added
    enhancement
    java-interop
    on Nov 19, 2026
  3. added
    needs-triage
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: Mono.Bindingsenhancementjava-interopneeds-triage

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions