Skip to content

[TrimmableTypeMap] Trimmable typemap test exclusions inventory #11170

@simonrozsival

Description

@simonrozsival

Summary

The trimmable typemap (_AndroidTypeMapImplementation=trimmable) has 48 tests that are currently excluded because they fail due to fundamental trimmable-typemap limitations. They are excluded by exact name in NUnitInstrumentation.cs, guarded by RuntimeFeature.TrimmableTypeMap, so they only apply to trimmable builds.

The goal is to fix these one by one and remove each exclusion as it's resolved.

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

Results: 859 passed, 48 excluded, 10 ignored (by NativeTypeMap/Export/CoreCLRIgnore/NTLM — not trimmable-specific).

To see the raw failures, temporarily remove the ExcludedTestNames block from NUnitInstrumentation.cs.


❌ Missing Java classes (5 tests)

Test(s) Count Missing Class Error
JavaObjectTest.DisposeAccessesThis 1 net.dot.jni.test.GetThis Cannot register native members
InvokeVirtualFromConstructorTests.* 3 net.dot.jni.test.CallVirtualFromConstructorDerived NoClassDefFoundError
JniTypeManagerTests.CannotCreateGenericHolderFromJava 1 net.dot.jni.test.GenericHolder Returns null instead of throwing NotSupportedException

JavaProxyObject / JavaProxyThrowable not available (24 tests)

Test(s) Count Error
JavaObjectArray_object_ContractTest.* 16 TestFixtureSetUp FailedJavaProxyObject native member registration fails
JniValueMarshaler_object_ContractTests.* (Create*, SpecificTypesAreUsed) 7 NoClassDefFoundError: net.dot.jni.internal.JavaProxyObject
JavaExceptionTests.InnerExceptionIsNotAProxy 1 Proxy throwable creation fails

❌ Proxy resolution / trimmer gaps (4 tests)

Test Error
JniValueMarshaler_IJavaPeerable_ContractTests.*.CreateGenericValue No JavaPeerProxy for java/lang/Object with IJavaPeerable target
JniValueMarshaler_IJavaPeerable_ContractTests.*.CreateValue No JavaPeerProxy for java/lang/Object with IJavaPeerable target
JavaPeerableExtensionsTests.JavaAs MissingMethodExceptionIJavaInterfaceInvoker ctor trimmed
JavaPeerableExtensionsTests.JavaAs_Exceptions Wrong exception type (ClassNotFoundException vs ArgumentException)
JavaPeerableExtensionsTests.JavaAs_InstanceThatDoesNotImplementInterfaceReturnsNull No JavaPeerProxy for IAndroidInterface

❌ JavaCast proxy resolution (4 tests)

Test Error
JavaObjectExtensionsTests.JavaCast_BadInterfaceCast NotSupportedException instead of InvalidCastException
JavaObjectExtensionsTests.JavaCast_CheckForManagedSubclasses NotSupportedException instead of InvalidCastException
JavaObjectExtensionsTests.JavaCast_InvalidTypeCastThrows NotSupportedException instead of InvalidCastException
JavaObjectExtensionsTests.JavaCast_BaseToGenericWrapper Cannot create instance of open generic type

❌ Open generic types / registration (4 tests)

Test Error
JnienvTest.NewOpenGenericTypeThrows Open generic creation succeeds when it should throw NotSupportedException
JnienvTest.ActivatedDirectThrowableSubclassesShouldBeRegistered Throwable subclass not registered (Expected: True, But was: False)
ObjectTest.GetObject_ReturnsMostDerivedType Returns Java.Lang.Object instead of Java.Lang.String
ObjectTest.JnienvCreateInstance_RegistersMultipleInstances Instance identity differs after JNI round-trip

❌ JNI method remapping not supported (4 tests)

Test Error
JniPeerMembersTests.ReplaceInstanceMethodName NoSuchMethodError — remapped method not found
JniPeerMembersTests.ReplaceInstanceMethodWithStaticMethod NoSuchMethodError
JniPeerMembersTests.ReplaceStaticMethodName NoSuchMethodError
JniPeerMembersTests.ReplacementTypeUsedForMethodLookup Returns wrong hash code

❌ Other (3 tests)

Test Error
JniTypeManagerTests.GetType InvalidOperationException — no JniPrimitiveArrayInfo for JavaBooleanArray
CustomWidgetTests.InflateCustomView_ShouldNotLeakGlobalRefs 256 extra global refs after inflating/GC'ing 100 custom views

✅ Previously excluded, now (re)enabled (45 tests)

As of PR #11091, all over-broad exclusions were replaced with precise per-test exclusions. 45 tests that were previously silently excluded now run and pass:

  • GetObjectArray (was CoreCLRIgnore)
  • 3 NTLM negotiate auth tests (were NTLM category)
  • JavaExceptionTests.InnerException, StackTrace
  • JavaObjectExtensionsTests.JavaAs
  • 11 JavaObjectTest tests (Ctor, Dispose, GC, registration, etc.)
  • JavaPeerableExtensionsTests.JavaAs_NullSelfReturnsNull
  • 4 JniPeerMembersTests tests (Ctor, desugaring, fallback lookup, virtual invoke)
  • 3 JniTypeManagerTests tests (CanCreateGenericHolder, GetTypeSignature×2)
  • 16 JniValueMarshaler_IJavaPeerable_ContractTests tests
  • 3 JniValueMarshaler_object_ContractTests tests
  • 3 CustomWidgetTests inflate tests

Summary Table

Root Cause Count
Missing net.dot.jni.test.* Java classes 5
JavaProxyObject/JavaProxyThrowable not available 24
Proxy resolution / trimmer gaps 5
JavaCast proxy resolution 4
Open generic types / registration 4
JNI method remapping 4
Other 2
Total excluded 48
Previously excluded, now (re)enabled 45

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