Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Context: dotnet/android#9846

When trying to build Mono.Android-Tests for NativeAOT, I get many warnings like this (that are upgraded to errors):

src\Java.Interop.GenericMarshaler\Java.Interop.GenericMarshaler\JniPeerInstanceMethodsExtensions.cs(10874,17):
error IL2091: 'T' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in 'Java.Interop.JniRuntime.JniValueManager.GetValueMarshaler<T>()'. The generic parameter 'T16' of 'Java.Interop.GenericMarshaler.JniPeerInstanceMethodsExtensions.InvokeGenericVirtualObjectMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(JniInstanceMethods, String, IJavaPeerable, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
Build failed with 2992 error(s) in 4.8s

To solve this here, we can import:

<Import Project="..\..\build-tools\trim-analyzers\trim-analyzers.props" />

To see all the warnings here, and then I added the missing attributes to solve the warnings.

Context: dotnet/android#9846

When trying to build `Mono.Android-Tests` for NativeAOT, I get many
warnings like this (that are upgraded to errors):

    src\Java.Interop.GenericMarshaler\Java.Interop.GenericMarshaler\JniPeerInstanceMethodsExtensions.cs(10874,17):
    error IL2091: 'T' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in 'Java.Interop.JniRuntime.JniValueManager.GetValueMarshaler<T>()'. The generic parameter 'T16' of 'Java.Interop.GenericMarshaler.JniPeerInstanceMethodsExtensions.InvokeGenericVirtualObjectMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(JniInstanceMethods, String, IJavaPeerable, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
    Build failed with 2992 error(s) in 4.8s

To solve this here, we can import:

    <Import Project="..\..\build-tools\trim-analyzers\trim-analyzers.props" />

To see all the warnings *here*, and then I added the missing
attributes to solve the warnings.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

@jonathanpeppers
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@jonpryor jonpryor merged commit 1e7f269 into main Feb 26, 2025
2 checks passed
@jonpryor jonpryor deleted the dev/peppers/GenericMarshalerWarnings branch February 26, 2025 15:04
jonpryor added a commit to dotnet/android that referenced this pull request Feb 26, 2025
Changes: dotnet/java-interop@471afd4...719e615

  * dotnet/java-interop@719e6159: [Hello-Java.Base] Add support for Java Callable Wrappers (dotnet/java-interop#1315)
  * dotnet/java-interop@1e7f269b: [Java.Interop.GenericMarshaler] fix trimmer warnings (dotnet/java-interop#1314)
jonathanpeppers pushed a commit to dotnet/android that referenced this pull request Feb 27, 2025
Changes: dotnet/java-interop@471afd4...719e615

  * dotnet/java-interop@719e6159: [Hello-Java.Base] Add support for Java Callable Wrappers (dotnet/java-interop#1315)
  * dotnet/java-interop@1e7f269b: [Java.Interop.GenericMarshaler] fix trimmer warnings (dotnet/java-interop#1314)
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants