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
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 plainobjectvalues inJavaObjectArray<object>:TrimmableTypeMapTypeManagerTests.JavaProxyObject_ObjectMethodsUseJavaIdentitySemanticsJavaObjectArray_object_ContractTestcollection/list contract tests:Contains,CopyTo,CopyTo_SequenceComparison,IndexOf,Item,ToArrayCurrent behavior
The trimmable value manager avoids the old reflection/value-marshaler path. For plain
object,TrimmableTypeMapValueManager.CreateLocalObjectReferenceArgumentCore()falls through toJavaConvert.ToLocalJniHandle(value), which wraps the value asAndroid.Runtime.JavaObject(mono/android/runtime/JavaObject).The tests expect the Java.Interop object proxy path (
Java.Interop.JavaProxyObject, JNI typenet/dot/jni/internal/JavaProxyObject) so object identity/equality/hashCode/toString semantics can round-trip correctly.Investigation notes
JavaProxyObjectuses[JniAddNativeMethodRegistrationAttribute]to register native implementations forequals,hashCode, andtoString. The trimmable typemap path does not support runtimeRegisterNativeMembers()and expects native method registration to be generated/static instead.We need to decide how
JavaProxyObjectshould be supported in the trimmable typemap runtime, or document/replace the behavior if it is intentionally unsupported.Related