dotnet / dotnet/android

Trimmable typemap fails Java.Interop value-manager CreateValue contract test

Open
#12,221 0 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 20h
Merged PRs (30d)
257

Description

### Android framework version

net11.0-android (Preview)

### Affected platform version

.NET 11 Preview 7, CoreCLR with `_AndroidTypeMapImplementation=trimmable`

### Description

Restoring `Java.InteropTests.JniRuntimeJniValueManagerTests` device-test coverage shows that four of its five tests pass under the trimmable typemap. `CreateValue` fails because its test `ReflectionJniValueManager` delegates marshaler lookup to the current runtime value manager, and `TrimmableTypeMapValueManager.GetValueMarshalerCore(Type)` throws `NotSupportedException`.

Expected: either the test's reflection value manager can resolve the `IJavaPeerable` marshaler under the trimmable typemap, or the test can be adapted to exercise supported trimmable behavior.

Actual: the test fails with `GetValueMarshalerCore should not be called in the trimmable typemap path.`

This is the only failing method in the restored fixture; `GetValue_ReturnsAlias`, `GetValue_ReturnsNullWithInvalidSafeHandle`, `GetValue_ReturnsNullWithNullHandle`, and `PeekValue` pass.

### Steps to Reproduce

1. Include `external/Java.Interop/tests/Java.Interop-Tests/Java.Interop/JniRuntime.JniValueManagerTests.cs` in `Java.Interop-Tests.NET.csproj`.
2. Build and install `tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj` with `-p:UseMonoRuntime=false -p:_AndroidTypeMapImplementation=trimmable`.
3. Run the on-device test suite.
4. Observe `Java.InteropTests.JniRuntimeJniValueManagerTests.CreateValue` fail.

### Did you find any workaround?

Exclude only `Java.InteropTests.JniRuntimeJniValueManagerTests.CreateValue` by fully-qualified NUnit test name when `RuntimeFeature.TrimmableTypeMap` is enabled. This retains the other four tests and all non-trimmable runtime coverage.

### Relevant log output

```shell
System.NotSupportedException : GetValueMarshalerCore should not be called in the trimmable typemap path.
at Microsoft.Android.Runtime.TrimmableTypeMapValueManager.GetValueMarshalerCore(Type type)
at Java.Interop.JniRuntime.JniValueManager.GetValueMarshaler(Type type)
at Java.Interop.JavaPeerableValueMarshaler.CreateGenericValue(...)
at Java.Interop.JniRuntime.ReflectionJniValueManager.CreateValueCore(...)
at Java.InteropTests.JniRuntimeJniValueManagerTests.CreateValue()
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with external/Java.Interop/tests/Java.Interop-Tests/Java.Interop/JniRuntime.JniValueManagerTests.cs and the CreateValue test, then inspect the trimmable typemap value-manager path named in the failure. Reproduce using the listed project files and _AndroidTypeMapImplementation=trimmable. Done means CreateValue passes while the other four restored tests and non-trimmable coverage remain passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp
Domain
mobile-dev, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.