Skip to content

[TrimmableTypeMap] Trimmable typemap test exclusions inventory #11170

@simonrozsival

Description

@simonrozsival

Summary

The trimmable typemap (_AndroidTypeMapImplementation=trimmable) excludes several tests that fail under this configuration. Tests in our code use [Category("TrimmableIgnore")] and are excluded via ExcludeCategories in the .csproj. Tests from the external Java.Interop-Tests assembly are excluded by name in NUnitInstrumentation.cs.

All failures share common root causes: the trimmable typemap does not generate Java-side classes for types in Java.Interop-Tests that use JavaObject (not Java.Lang.Object) or rely on net.dot.jni.test.* / net.dot.jni.internal.* Java classes, and some runtime behaviors differ (wrong exception types, missing proxy resolution, etc.).

How to reproduce

make prepare && make all CONFIGURATION=Release
./dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj \
    -t:RunTestApp -c Release \
    -p:_AndroidTypeMapImplementation=trimmable \
    -p:UseMonoRuntime=false

To see the failures, temporarily clear ExcludedTestNames in NUnitInstrumentation.cs and remove TrimmableIgnore from the ExcludeCategories in the .csproj.


❌ Tests excluded via [Category("TrimmableIgnore")] (in our code)

Test File Error
ObjectTest.GetObject_ReturnsMostDerivedType Java.Lang/ObjectTest.cs Returns Java.Lang.Object instead of Java.Lang.String — typemap doesn't resolve most-derived type
JnienvTest.NewOpenGenericTypeThrows Java.Interop/JnienvTest.cs Open generic creation succeeds when it should throw
JnienvTest.ActivatedDirectThrowableSubclassesShouldBeRegistered Java.Interop/JnienvTest.cs Throwable subclass not registered
JavaObjectExtensionsTests.JavaCast_BaseToGenericWrapper Java.Interop/JavaObjectExtensionsTests.cs Cannot create instance of open generic type
JavaObjectExtensionsTests.JavaCast_BadInterfaceCast Java.Interop/JavaObjectExtensionsTests.cs NotSupportedException instead of InvalidCastException
JavaObjectExtensionsTests.JavaCast_InvalidTypeCastThrows Java.Interop/JavaObjectExtensionsTests.cs NotSupportedException instead of InvalidCastException
JavaObjectExtensionsTests.JavaCast_CheckForManagedSubclasses Java.Interop/JavaObjectExtensionsTests.cs NotSupportedException instead of InvalidCastException

❌ Tests excluded via ExcludedTestNames (external Java.Interop-Tests)

Missing Java Classes

Test(s) Count Missing Class
JavaObjectTest.DisposeAccessesThis 1 net.dot.jni.test.GetThis — cannot register native members
InvokeVirtualFromConstructorTests.* 3 net.dot.jni.test.CallVirtualFromConstructorDerived
JniTypeManagerTests.CanCreateGenericHolder, CannotCreateGenericHolderFromJava 2 net.dot.jni.test.GenericHolder

JavaProxyObject / JavaProxyThrowable Not Available

Test(s) Count Error
JavaObjectArray_object_ContractTest.* 16 Fixture setup fails — JavaProxyObject native member registration
JniValueMarshaler_object_ContractTests.* 7 NoClassDefFoundError: net.dot.jni.internal.JavaProxyObject
JavaExceptionTests.InnerExceptionIsNotAProxy 1 Proxy throwable creation fails

Proxy Resolution / Trimmer Gaps

Test(s) Count Error
JniValueMarshaler_IJavaPeerable_ContractTests.CreateGenericValue, CreateValue 2 No JavaPeerProxy for java/lang/Object with IJavaPeerable target
JavaPeerableExtensionsTests.JavaAs 1 IJavaInterfaceInvoker ctor trimmed
JavaPeerableExtensionsTests.JavaAs_Exceptions 1 Wrong exception type (ClassNotFoundException vs ArgumentException)
JavaPeerableExtensionsTests.JavaAs_InstanceThatDoesNotImplementInterfaceReturnsNull 1 No JavaPeerProxy for IAndroidInterface

JNI Method Remapping Not Supported

Test(s) Count
JniPeerMembersTests.ReplaceInstanceMethodName 1
JniPeerMembersTests.ReplaceInstanceMethodWithStaticMethod 1
JniPeerMembersTests.ReplacementTypeUsedForMethodLookup 1
JniPeerMembersTests.ReplaceStaticMethodName 1

Other

Test Error
JniTypeManagerTests.GetType JniPrimitiveArrayInfo lookup fails

✅ Previously excluded, now passing

Test Notes
CustomWidgetTests.InflateCustomView_ShouldNotLeakGlobalRefs Was [Category("TrimmableIgnore")], exclusion removed

Summary Table

Category Count Mechanism
[Category("TrimmableIgnore")] (our code) 7 ExcludeCategories in .csproj
Missing Java classes 6 ExcludedTestNames
JavaProxyObject/JavaProxyThrowable 24 ExcludedTestNames
Proxy resolution / trimmer gaps 4 ExcludedTestNames
JNI method remapping 4 ExcludedTestNames
Other (JniPrimitiveArrayInfo) 1 ExcludedTestNames
Total excluded 46
Now passing (removed) 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Unit TestsIssues with repo unit tests.needs-triageIssues that need to be assigned.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions