[TrimmableTypeMap] Implement reflection-free TrimmableTypeMapValueManager and TrimmableTypeMapTypeManager#11617
Draft
simonrozsival wants to merge 47 commits into
Draft
[TrimmableTypeMap] Implement reflection-free TrimmableTypeMapValueManager and TrimmableTypeMapTypeManager#11617simonrozsival wants to merge 47 commits into
simonrozsival wants to merge 47 commits into
Conversation
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
42a1b8e to
47450cf
Compare
Member
Author
|
Rebased onto #11622 (external/Java.Interop d7dbad5) and revalidated targeted Mono.Android build locally.\n\n/azp run |
Member
Author
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
Member
Author
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
Member
Author
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
Bumps [external/Java.Interop](https://github.com/dotnet/java-interop) from `b881d21` to `d7dbad5`. - [Commits](dotnet/java-interop@b881d21...d7dbad5) --- updated-dependencies: - dependency-name: external/Java.Interop dependency-version: d7dbad5e30a8f03743a508a95c4e9159fe1f6607 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
Split the Android JavaMarshal value manager into CoreCLR and trimmable implementations that share peer registration and GC bridge integration through a reusable helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the trimmable typemap value manager on the abstract JniValueManager base, sharing only peer registration and GC bridge state with the CoreCLR value manager. Leave value marshaling unsupported for now until Android has trimmable-specific marshalers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move TrimmableTypeMapTypeManager off ReflectionJniTypeManager and implement type lookup through explicit built-in mappings plus the generated trimmable typemap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove newly added UnconditionalSuppressMessage attributes, propagate Requires annotations from reflection-backed managers, and carry DAM annotations through JavaPeerProxy/TrimmableTypeMap target type metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace newly added suppressions on reflection-backed managers with RequiresUnreferencedCode and RequiresDynamicCode propagation. Leave trimmable value/type managers free of UnconditionalSuppressMessage attributes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace remaining UnconditionalSuppressMessage attributes in the reflection-backed Android manager implementations with RequiresUnreferencedCode/RequiresDynamicCode where appropriate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace invoker lookup and legacy TypeManager peer creation suppressions with RequiresUnreferencedCode/RequiresDynamicCode propagation. Keep GetObject suppression because adding DAM there breaks delegate/reflection table use sites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Annotate runtime feature switches with FeatureGuard and structure manager factory branches so reflection-backed manager creation is guarded by the relevant runtime feature instead of broad Requires annotations on the factory methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the single-use JavaMarshalReflectionValueManagerBase and keep the shared peer/GC bridge state in JavaMarshalPeerManager, directly delegated by the CoreCLR value manager. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make both TrimmableTypeMapTypeManager RegisterNativeMembers overloads throw UnreachableException directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make unused trimmable JniTypeManager paths fail loudly, remove ManagedPeer from trimmable runtime artifacts, and add an initial AOT-safe value-marshaling implementation for the trimmable value manager. Update tests and trimmable runtime coverage to use feature switches via AppContext and enable the value-marshaling test bucket for follow-up triage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the Java.Interop proxy and peerable value marshalers from the trimmable value manager instead of duplicating peerable marshaling locally. This also updates the Java.Interop submodule to the follow-up branch with the shared proxy marshaler and re-enables the trimmable tests now covered by the shared marshalers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Handle Java peerable elements and Java primitive array wrappers without reflection in the trimmable value manager. This lets JavaObjectArray<JavaObject> preserve peer identity and JavaObjectArray<JavaInt32Array> create and read int-array elements correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines successfully started running 1 pipeline(s). |
Add Android trimmable RenameClass fixture variants without ManagedPeer.construct so JniPeerMembersTests.ReplacementTypeUsedForMethodLookup can exercise replacement-type method lookup on device. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Add Android trimmable CallNonvirtual fixture variants without ManagedPeer.construct so MethodBindingTests can validate virtual dispatch behavior under the trimmable typemap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Use the existing InnerException member directly in throwable unwrapping paths instead of adding a redundant Exception property. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Keep the PR focused by reverting NativeAOT manager wiring and ManagedTypeManager cleanup, removing Android-local ManagedPeer fixture replacements, and dropping ManagedPeer absence assertions. Unsupported ManagedPeer-dependent Java.Interop tests remain skipped by category. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Record the benchmark finding that the current Type.GetTypeCode plus explicit nullable checks path is zero-allocation, and avoid Nullable.GetUnderlyingType because it allocates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Move each top-level Java marshal value manager type into its own source file and route JavaObjectArray state creation through JniValueManager so the trimmable path no longer needs a value-marshaler implementation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove unused trimmable value-marshaler helper code and keep only the object-reference state path needed for JavaObjectArray element assignment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Update the trimmable value manager to return standalone local JNI references for JavaObjectArray element assignment and remove the remaining marshaler-state cleanup path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Update the trimmable value manager override to match the CreateLocalObjectReferenceArgument naming from Java.Interop. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Integrate the Java.Interop value-manager/type-manager split into dotnet/android while keeping the trimmable typemap runtime path reflection-free, AOT-friendly, and covered by targeted tests.
This PR is specifically about making the Android runtime use the new Java.Interop abstractions safely. Broader cleanup such as removing ManagedPeer support or changing NativeAOT runtime policy is intentionally left to follow-up PRs.
What changed
Java.Interop integration
JavaObjectArray<T>.SetElementAt():CreateLocalObjectReferenceArgument(Type type, object? value)returns an owned localJniObjectReferencefor element assignment. Callers must dispose the returned reference.JavaObjectArray<T>.Clear()now directly writes Java null into each slot; it no longer needs value-manager or value-marshaler state.GetValueMarshaler*()forJavaObjectArray<T>element assignment.Runtime manager wiring
ReflectionJniTypeManager/ReflectionJniValueManagerbase implementations.TrimmableTypeMapTypeManagerresolves generated proxy/type-map data without reflection fallback.TrimmableTypeMapValueManagerconstructs and marshals generated peers without the reflection-backed value manager.JavaConvertfallback cases are handled without reflection fallback.JavaMarshalValueManager.csimplementation into per-type files.SimpleValueManagerpath.Trimmable typemap build fixes
Microsoft.Android.Runtime.ManagedTypeMappingfor linker/type-map steps that still need it.[JniAddNativeMethodRegistrationAttribute]diagnostics focused on user assemblies; framework/runtime internal users are handled by generated replacements or intentionally unsupported runtime paths.RequiresUnreferencedCodeannotation fromExportFieldAttribute.[ExportField]is handled by generated trimmable type-map code and does not need to warn simply for constructing the attribute.Test strategy
TrimmableTypeMapUnsupportedvia test categories.[Export]/[ExportField]trimmable codegen,Review notes / intentional non-goals
Type→JniTypeSignaturemapping intentionally keeps the currentType.GetTypeCode+ explicit nullabletypeofchecks. Benchmarking showedNullable.GetUnderlyingType()allocates and should not be used on this path.Local validation
Validated locally on this branch with:
dotnet build external/Java.Interop/src/Java.Interop/Java.Interop.csproj \ -p:Configuration=Debug \ -m:1 \ -nodeReuse:false \ --no-restore \ -v:minimal dotnet test tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests.csproj \ -v minimal \ --no-restoreResults:
562passed).dotnet build src/Mono.Android/Mono.Android.csproj -p:Configuration=Debug -p:AndroidSdkDirectory=/Users/simonrozsival/android-toolchain/sdk -m:1 -nodeReuse:false --no-restore -v:minimalcompiledMono.Android.Runtime.dll; the remaining local failure is Android SDK provisioning (extras/android/m2repository.staginganddocs.stagingmissing), not C# or trim-analyzer errors.