[TrimmableTypeMap] Use trimmable Java proxy runtime sources#11271
[TrimmableTypeMap] Use trimmable Java proxy runtime sources#11271simonrozsival wants to merge 4 commits intomainfrom
Conversation
|
/review |
|
✅ Android PR Reviewer completed successfully! |
There was a problem hiding this comment.
✅ LGTM — Clean, well-structured change
Summary: Introduces trimmable-specific Java runtime jars that replace Java.Interop's JavaProxyObject.java / JavaProxyThrowable.java with versions that don't call ManagedPeer.registerNativeMembers(). This fixes the root cause behind #11170 by providing Java identity implementations of equals/hashCode/toString instead of native methods.
What I verified
- ✅
_AndroidTypeMapImplementationis already in_PropertyCacheItems(line 996), so incremental builds correctly invalidate when switching typemap implementations - ✅ The 4-way condition matrix in
_CollectRuntimeJarFilenamescovers all combinations exhaustively (MonoVM × CoreCLR × default × trimmable) - ✅
_RuntimeOutput.AddItemsmetadata is properly added toInputsfor incremental build tracking - ✅ The
Deleteof staleclasses.dexprevents D8 output from leaking into jars during incremental builds - ✅ New Java files correctly mirror the original Java.Interop implementations minus the
static { registerNativeMembers() }block andnativemethod declarations - ✅ Installer file lists include all 4 new artifacts (trimmable jar+dex for net6 and clr)
- ✅ Re-enabled tests (previously excluded due to
registerNativeMembersfailure) are now validated by 900 passing device tests - ✅ New test coverage validates proxy type, object array usage, and Java identity semantics
Positive callouts
- The
RemoveItems/AddItemsmetadata pattern on_RuntimeOutputis a clean approach to source file swapping — it keeps the build logic centralized in the target without needing separate targets - Good test for
JavaProxyObject_ObjectMethodsUseJavaIdentitySemanticsthat explicitly verifies the behavioral contract of the trimmable proxy - Removing 27 lines of test exclusions from
NUnitInstrumentation.csis a nice cleanup
CI
The PR is in draft status. The dotnet-android check shows neutral (not yet run). CI results should be verified before merging.
3 💡 suggestions posted inline — all documentation/clarity improvements, no required changes.
Generated by Android PR Reviewer for issue #11271 · ● 6.2M
1467afa to
e66930e
Compare
Add trimmable-specific java_runtime jars that replace Java.Interop's JavaProxyObject and JavaProxyThrowable sources only for the trimmable typemap path. Keep the existing runtime jars on Java.Interop's native-registration behavior and select the trimmable jars when _AndroidTypeMapImplementation is trimmable. Re-enable the affected Java.Interop runtime tests and add focused coverage for JavaProxyObject marshaling/object methods under the trimmable typemap path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add comments documenting runtime jar selection and Java proxy identity semantics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e66930e to
0644b70
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the trimmable typemap path to use trimmable-specific Java runtime sources for JavaProxyObject / JavaProxyThrowable, selecting new runtime jars only when _AndroidTypeMapImplementation=trimmable, and re-enables previously excluded Java.Interop tests by adding targeted validation for the new proxy behavior.
Changes:
- Add trimmable Java runtime proxy sources (
src/java-runtime/java-trimmable/...) and build new runtime jar/dex variants for both MonoVM and CoreCLR. - Update MSBuild runtime-jar selection logic to choose trimmable vs non-trimmable runtime jars based on
_AndroidRuntime×_AndroidTypeMapImplementation. - Re-enable previously excluded Java.Interop tests and add focused trimmable coverage around Java proxy marshaling and object-method semantics.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs | Removes prior trimmable exclusions now that trimmable proxy classes are provided. |
| tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/TrimmableTypeMapTypeManagerTests.cs | Adds new tests validating marshaling and Java-side JavaProxyObject behavior under trimmable typemap. |
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Selects trimmable vs non-trimmable runtime jar based on runtime + typemap implementation. |
| src/java-runtime/java-trimmable/net/dot/jni/internal/JavaProxyThrowable.java | Introduces trimmable-specific Java proxy throwable implementation. |
| src/java-runtime/java-trimmable/net/dot/jni/internal/JavaProxyObject.java | Introduces trimmable-specific Java proxy object implementation (no native registration; identity semantics). |
| src/java-runtime/java-runtime.targets | Builds additional trimmable runtime jar/dex outputs and improves incremental inputs / stale classes.dex cleanup. |
| build-tools/installers/create-installers.targets | Ships the new trimmable runtime jar/dex artifacts in installers. |
Use repository Java formatting for trimmable proxy sources and strengthen the proxy hashCode test so it compares against Java identityHashCode instead of itself. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
The merge conflicts are resolved locally:
However, the push is being rejected by the |
Summary
java_runtime_trimmable_net6.jarandjava_runtime_trimmable_clr.jar) that replace Java.Interop's incompatibleJavaProxyObject.java/JavaProxyThrowable.javaonly for_AndroidTypeMapImplementation=trimmable_net6follows the existing historical non-CoreCLR runtime jar naming (java_runtime_net6.jar), not the current .NET TFMjava-trimmablesourcesValidation
dotnet build src/java-runtime/java-runtime.csproj -v:minimaldotnet build src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj -v:minimaldotnet build src/Mono.Android/Mono.Android.csproj -v:minimalMSBUILDDISABLENODEREUSE=1 ./dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj -c Debug -p:_AndroidTypeMapImplementation=trimmable -nr:falsedotnet test tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests.csproj -v minimal900 passed, 0 failedJavaProxyObjectregistration, trimmable runtime jars have direct Java object methods and no static native registrationRelated issues