Skip to content

Remove unnecessary DAM attributes#1481

Open
simonrozsival wants to merge 9 commits into
mainfrom
dev/simonrozsival/remove-dam-attributes
Open

Remove unnecessary DAM attributes#1481
simonrozsival wants to merge 9 commits into
mainfrom
dev/simonrozsival/remove-dam-attributes

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • remove DynamicallyAccessedMembers annotations from runtime type/value manager and marshaler extensibility points where broad rooting is more harmful than useful
  • update NativeAOT samples, unshipped API entries, and test overrides to match the updated signatures

Testing

  • dotnet build tests/Java.Interop-Tests/Java.Interop-Tests.csproj --nologo -m:1
  • dotnet build --nologo -m:1

simonrozsival and others added 2 commits June 23, 2026 18:51
Remove DynamicallyAccessedMembers annotations from runtime extensibility points where broad rooting is more harmful than useful.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove test-side DAM annotations that no longer match the updated runtime signatures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 23, 2026 16:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces trimming/AOT rooting pressure by removing DynamicallyAccessedMembers annotations from several runtime type/value-manager and marshaler extensibility points, shifting responsibility to explicit RequiresUnreferencedCode/feature-guarded call sites and updating tests/samples/PublicAPI accordingly.

Changes:

  • Removed broad DynamicallyAccessedMembers annotations from JniTypeManager/JniValueManager/JniValueMarshaler APIs and related overrides.
  • Introduced/adjusted trimming annotations (RequiresUnreferencedCode, FeatureGuard) around reflection-heavy paths.
  • Updated tests, NativeAOT samples, and PublicAPI.Unshipped.txt to match signature/API removals.
Show a summary per file
File Description
tests/Java.Interop-Tests/Java.Interop/JniValueMarshalerContractTests.cs Updates test marshaler override signature to match removed DAM annotations.
tests/Java.Interop-Tests/Java.Interop/JavaVMFixture.cs Removes return DAM annotation from test override.
src/Java.Runtime.Environment/Java.Interop/JreTypeManager.cs Updates override signature to match removed DAM annotations.
src/Java.Interop/PublicAPI.Unshipped.txt Removes unshipped API entries for removed type(s)/member(s).
src/Java.Interop/Java.Interop/RuntimeFeature.cs Adds feature guard for trimming, but currently introduces a switch-caching behavior change.
src/Java.Interop/Java.Interop/ManagedPeer.cs Adds RequiresUnreferencedCode and removes suppressions tied to prior DAM behavior.
src/Java.Interop/Java.Interop/JniValueMarshaler.cs Removes DAM-related constants/annotations from marshaler extensibility points.
src/Java.Interop/Java.Interop/JniStringValueMarshaler.cs Updates override signature to match removed DAM annotations.
src/Java.Interop/Java.Interop/JniRuntime.ReflectionJniValueManager.cs Removes DAM usage and updates type enumeration to GetTypes. Adds RequiresUnreferencedCode to reflection-heavy marshalers.
src/Java.Interop/Java.Interop/JniRuntime.ReflectionJniTypeManager.cs Removes GetReflectionConstructibleTypes and DAM annotations in overrides/registration.
src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs Removes DAM annotations from several APIs (except where still retained), updating generic marshaler APIs/signatures.
src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs Removes DAM annotations and removes the ReflectionConstructibleType API surface.
src/Java.Interop/Java.Interop/JniBuiltinMarshalers.cs Adjusts placement of builtin marshaler map, but is T4-generated and should be updated via the .tt template.
src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs Removes DAM annotations from marshaling entrypoints.
src/Java.Interop/Java.Interop/JavaObjectArray.cs Adjusts generic parameter annotation formatting and removes now-unneeded DAM usage in marshaler override signature.
src/Java.Interop/Java.Interop/JavaArray.cs Removes DAM annotation from JavaPrimitiveArray<T>.
samples/Hello-NativeAOTFromJNI/NativeAotTypeManager.cs Removes DAM return annotation, but suppression text now references removed DAM behavior.
samples/Hello-NativeAOTFromAndroid/NativeAotTypeManager.cs Removes DAM return annotation, but suppression text now references removed DAM behavior.

Copilot's findings

  • Files reviewed: 18/18 changed files
  • Comments generated: 4

Comment thread src/Java.Interop/Java.Interop/RuntimeFeature.cs
Comment thread src/Java.Interop/Java.Interop/JniBuiltinMarshalers.cs
Comment thread samples/Hello-NativeAOTFromJNI/NativeAotTypeManager.cs
Comment thread samples/Hello-NativeAOTFromAndroid/NativeAotTypeManager.cs
simonrozsival and others added 5 commits June 23, 2026 19:08
Update the builtin marshaler template and NativeAOT sample suppression justifications after removing broad DAM annotations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, thanks! label Jun 24, 2026
@simonrozsival simonrozsival enabled auto-merge (squash) June 24, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, thanks!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants