Skip to content

Investigate JavaProxyObject support in trimmable typemap #11703

Description

@simonrozsival

Context

While validating dotnet/java-interop#1478 against dotnet/android CoreCLR trimmable typemap device tests, the unsupported value-marshaler API tests were excluded successfully, but JavaProxyObject-related object-array behavior still fails.

Observed failures

In Mono.Android.NET_Tests-CoreCLRTrimmable, these failures are related to plain object values in JavaObjectArray<object>:

  • TrimmableTypeMapTypeManagerTests.JavaProxyObject_ObjectMethodsUseJavaIdentitySemantics
  • inherited JavaObjectArray_object_ContractTest collection/list contract tests: Contains, CopyTo, CopyTo_SequenceComparison, IndexOf, Item, ToArray

Current behavior

The trimmable value manager avoids the old reflection/value-marshaler path. For plain object, TrimmableTypeMapValueManager.CreateLocalObjectReferenceArgumentCore() falls through to JavaConvert.ToLocalJniHandle(value), which wraps the value as Android.Runtime.JavaObject (mono/android/runtime/JavaObject).

The tests expect the Java.Interop object proxy path (Java.Interop.JavaProxyObject, JNI type net/dot/jni/internal/JavaProxyObject) so object identity/equality/hashCode/toString semantics can round-trip correctly.

Investigation notes

JavaProxyObject uses [JniAddNativeMethodRegistrationAttribute] to register native implementations for equals, hashCode, and toString. The trimmable typemap path does not support runtime RegisterNativeMembers() and expects native method registration to be generated/static instead.

We need to decide how JavaProxyObject should be supported in the trimmable typemap runtime, or document/replace the behavior if it is intentionally unsupported.

Related

Activity

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

    needs-triageIssues that need to be assigned.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions