Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Target net9.0 #1279

Merged
merged 4 commits into from
Feb 18, 2025
Merged

[build] Target net9.0 #1279

merged 4 commits into from
Feb 18, 2025

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Nov 21, 2024

We want to add a call to Debugger.BreakForUserUnhandledException (which was added in .NET 9) in Java.Interop.JniRuntime as part of #1258.

In order to do this we need to update java-interop to be based on .NET 9 instead of .NET 8.

Contains fixes for new trimming warnings that were surfaced when targeting .NET 9.

Requires companion changes in dotnet/android: dotnet/android#9793.

@jpobst jpobst force-pushed the net9 branch 3 times, most recently from 02786d6 to 303597e Compare November 22, 2024 19:12
@jonpryor
Copy link
Member

jonpryor commented Nov 25, 2024

Requires: dotnet/runtime#109579

…against .NET 9.

@jpobst
Copy link
Contributor Author

jpobst commented Nov 26, 2024

Additionally produces the following trimmer errors:

error IL2092: Java.Interop.JreTypeManager.RegisterNativeMembers(JniType,Type,ReadOnlySpan`1<Char>): 'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 'type' of method 'Java.Interop.JreTypeManager.RegisterNativeMembers(JniType,Type,ReadOnlySpan`1<Char>)' don't match overridden parameter 'type' of method 'Java.Interop.JniRuntime.JniTypeManager.RegisterNativeMembers(JniType,Type,ReadOnlySpan`1<Char>)'. All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop\Java.Interop\JniRuntime.JniValueManager.cs(693): AOT analysis error IL3050: Java.Interop.JniRuntime.JniValueManager.<GetObjectArrayMarshaler>g__MakeGenericMethod|41_0(MethodInfo,Type): Using member 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop\Java.Interop\JniRuntime.JniValueManager.cs(409): AOT analysis error IL3050: Java.Interop.JniRuntime.JniValueManager.<GetInvokerType>g__MakeGenericType|31_1(Type,Type[]): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Runtime.Environment\Java.Interop\JreTypeManager.cs(22): Trim analysis error IL2067: Java.Interop.JreTypeManager.RegisterNativeMembers(JniType,Type,ReadOnlySpan`1<Char>): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicNestedTypes' in call to 'Java.Interop.JniRuntime.JniTypeManager.TryRegisterNativeMembers(JniType,Type,ReadOnlySpan`1<Char>)'. The parameter 'type' of method 'Java.Interop.JreTypeManager.RegisterNativeMembers(JniType,Type,ReadOnlySpan`1<Char>)' 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. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Runtime.Environment\Java.Interop\ManagedValueManager.cs(235): Trim analysis error IL2072: Java.Interop.ManagedValueManager.ActivateViaReflection(JniObjectReference,ConstructorInfo,Object[]): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' 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. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Runtime.Environment\Java.Interop\JreTypeManager.cs(68): Trim analysis error IL2070: Java.Interop.JreTypeManager.AddInterfaceMethods(Dictionary`2<ValueTuple`2<String,String>,MethodInfo>,Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The parameter 'type' of method 'Java.Interop.JreTypeManager.AddInterfaceMethods(Dictionary`2<ValueTuple`2<String,String>,MethodInfo>,Type)' 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. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Runtime.Environment\Java.Interop\JreTypeManager.cs(73): Trim analysis error IL2062: Java.Interop.JreTypeManager.AddInterfaceMethods(Dictionary`2<ValueTuple`2<String,String>,MethodInfo>,Type): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Runtime.Environment\Java.Interop\JreTypeManager.cs(92): Trim analysis error IL2070: Java.Interop.JreTypeManager.AddClassMethods(Dictionary`2<ValueTuple`2<String,String>,MethodInfo>,Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'type' of method 'Java.Interop.JreTypeManager.AddClassMethods(Dictionary`2<ValueTuple`2<String,String>,MethodInfo>,Type)' 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. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Runtime.Environment\Java.Interop\JreTypeManager.cs(95): Trim analysis error IL2070: Java.Interop.JreTypeManager.AddClassMethods(Dictionary`2<ValueTuple`2<String,String>,MethodInfo>,Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The parameter 'type' of method 'Java.Interop.JreTypeManager.AddClassMethods(Dictionary`2<ValueTuple`2<String,String>,MethodInfo>,Type)' 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. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(141): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'System.Linq.Expressions.Expression.Property(Expression,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(144): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'System.Linq.Expressions.Expression.Property(Expression,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(149): Trim analysis error IL2067: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'Java.Interop.JniRuntime.JniValueManager.GetValueMarshaler(Type)'. The parameter 'type' of method 'Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type)' 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. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(150): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'Java.Interop.JniValueMarshaler.CreateParameterToManagedExpression(JniValueMarshalerContext,ParameterExpression,ParameterAttributes,Type)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. System.Linq.Expression usage may trim away required code. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(150): AOT analysis error IL3050: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'Java.Interop.JniValueMarshaler.CreateParameterToManagedExpression(JniValueMarshalerContext,ParameterExpression,ParameterAttributes,Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. System.Linq.Expression usage may trim away required code. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(168): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'Java.Interop.JniValueMarshaler.CreateParameterToManagedExpression(JniValueMarshalerContext,ParameterExpression,ParameterAttributes,Type)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. System.Linq.Expression usage may trim away required code. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(168): AOT analysis error IL3050: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'Java.Interop.JniValueMarshaler.CreateParameterToManagedExpression(JniValueMarshalerContext,ParameterExpression,ParameterAttributes,Type)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. System.Linq.Expression usage may trim away required code. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(196): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'Java.Interop.JniValueMarshaler.CreateReturnValueFromManagedExpression(JniValueMarshalerContext,ParameterExpression)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. System.Linq.Expression usage may trim away required code. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(196): AOT analysis error IL3050: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'Java.Interop.JniValueMarshaler.CreateReturnValueFromManagedExpression(JniValueMarshalerContext,ParameterExpression)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. System.Linq.Expression usage may trim away required code. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(226): AOT analysis error IL3050: Java.Interop.MarshalMemberBuilder.CreateMarshalToManagedExpression(MethodInfo,JavaCallableAttribute,Type): Using member 'System.Linq.Expressions.Expression.Lambda(Expression,IEnumerable`1<ParameterExpression>)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Delegate creation requires dynamic code generation. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(435): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateConstructActivationPeerExpression(ConstructorInfo): Using member 'System.Linq.Expressions.Expression.Property(Expression,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(411): Trim analysis error IL2111: Java.Interop.MarshalMemberBuilder..cctor(): Method 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(45): Trim analysis error IL2070: Java.Interop.MarshalMemberBuilder.<CreateExportedMemberRegistrationIterator>d__4.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.TypeInfo.DeclaredMethods.get'. The parameter 'declaringType' of method 'Java.Interop.MarshalMemberBuilder.CreateExportedMemberRegistrationIterator(Type)' 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. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(248): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.GetMarshalerType(Type,List`1<Type>,Type): Using member 'System.Reflection.Assembly.GetType(String,Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop\Java.Interop\JniRuntime.JniTypeManager.cs(284): AOT analysis error IL3050: Java.Interop.JniRuntime.JniTypeManager.MakeGenericType(Type,Type): Using member 'System.Type.MakeGenericType(Type[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for this instantiation might not be available at runtime. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop\Java.Interop\JniRuntime.JniTypeManager.cs(277): AOT analysis error IL3050: Java.Interop.JniRuntime.JniTypeManager.MakeArrayType(Type): Using member 'System.Type.MakeArrayType()' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The code for an array of the specified type might not be available. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(274): AOT analysis error IL3050: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Using member 'System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly(AssemblyName,AssemblyBuilderAccess)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Defining a dynamic assembly requires dynamic code. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Using member 'System.Delegate.Delegate(Object,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The target method might be removed. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2111: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Method 'System.Delegate.Delegate(Type,String)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Using member 'System.Delegate.CreateDelegate(Type,Object,String,Boolean,Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The target method might be removed. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2111: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Method 'System.Delegate.CreateDelegate(Type,Type,String,Boolean,Boolean)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Using member 'System.Delegate.CreateDelegate(Type,Object,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The target method might be removed. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Using member 'System.Delegate.CreateDelegate(Type,Object,String,Boolean)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The target method might be removed. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2111: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Method 'System.Delegate.CreateDelegate(Type,Type,String)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2111: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Method 'System.Delegate.CreateDelegate(Type,Type,String,Boolean)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2026: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Using member 'System.MulticastDelegate.MulticastDelegate(Object,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The target method might be removed. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]
D:\a\_work\1\s\src\Java.Interop.Export\Java.Interop\MarshalMemberBuilder.cs(288): Trim analysis error IL2111: Java.Interop.MarshalMemberBuilder.CreateMarshalDelegateType(String,Type,List`1<Type>): Method 'System.MulticastDelegate.MulticastDelegate(Type,String)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method. [D:\a\_work\1\s\samples\Hello-NativeAOTFromJNI\Hello-NativeAOTFromJNI.csproj]

@jpobst
Copy link
Contributor Author

jpobst commented Jan 15, 2025

This still fails on .NET 9.0.1. It looks like the backport should be in 9.0.2:
dotnet/runtime#110163

@filipnavara
Copy link
Member

Time to revisit this now that .NET 9.0.2 shipped?

Most of these callsites are not called on Android anyway. We can silence them as a way to not introduce new warnings.
@jonathanpeppers
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jpobst jpobst marked this pull request as ready for review February 18, 2025 17:40
@jpobst jpobst requested a review from jonpryor February 18, 2025 17:40
@jonpryor
Copy link
Member

Draft commit message:

Context: 356485ee41fb61570e84c11ba120d6f8cf81ae09
Context: https://github.com/dotnet/java-interop/issues/1258
Context: https://github.com/dotnet/android/pull/9793

We want to add a call to [Debugger.BreakForUserUnhandledException][0]
-- which was added in .NET 9 -- into `Java.Interop.JniRuntime` as
part of Issues #1258.

In order to do this we need to update `dotnet/java-interop` to build
with .NET 9 instead of .NET 8.

This also contains fixes for new trimming warnings that were surfaced
when targeting .NET 9.

Requires companion changes in `dotnet/android`: dotnet/android#9793

[0]: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.debugger.breakforuserunhandledexception

@jonpryor jonpryor merged commit f30e420 into main Feb 18, 2025
4 checks passed
@jonpryor jonpryor deleted the net9 branch February 18, 2025 20:46
jonpryor pushed a commit to dotnet/android that referenced this pull request Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants