-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fix known issues with NativeAOT #1192
Labels
enhancement
Proposed change to current functionality
java-interop
Runtime bridge between .NET and Java
Milestone
Comments
jonathanpeppers
changed the title
[NativeAOT] fix places we use
Fix known issues with NativeAOT
Feb 28, 2024
[UnconditionalSuppressMessage ("AOT")]
UpdateWe'll probably actually suppress the warnings like: // FIXME: https://github.com/xamarin/xamarin-android/issues/8724
// IL3050 disabled in source: if someone uses NativeAOT, they will get the warning.
#pragma warning disable IL3050
var dynamic = new DynamicMethod (DynamicMethodNameCounter.GetUniqueName (), ret_type, param_types, typeof (DynamicMethodNameCounter), true);
#pragma warning restore IL3050 |
jonathanpeppers
added a commit
to jonathanpeppers/java.interop
that referenced
this issue
Feb 28, 2024
Context: dotnet/android#8758 (comment) Context: dotnet#1192 In 7d1e705 and b8f6f88, we suppressed IL3050, an AOT-related warning with: // FIXME: dotnet#1192 [UnconditionalSuppressMessage ("AOT", "IL3050")] // Problematic code here We don't immediately *plan* to support NativeAOT on Android in .NET 9, so it would be nice if we could suppress the warning *for now*. But if anyone tried to use this code in a NativeAOT context, they could get a warning. So instead we should use: // FIXME: dotnet#1192 #pragma warning disable IL3050 // Problematic code here #pragma warning restore IL3050 This will prevent us from introducing new `IL3050` and related warnings, but if anyone consumes `Java.Interop.dll` from NativeAOT -- they will see the warning.
jonpryor
pushed a commit
that referenced
this issue
Mar 11, 2024
Context: dotnet/android#8758 (comment) Context: #1192 Context: 2197579 In 7d1e705 and b8f6f88, we suppressed IL3050, an AOT-related warning with: // FIXME: #1192 [UnconditionalSuppressMessage ("AOT", "IL3050")] // Problematic code here We don't immediately *plan* to support NativeAOT on Android in .NET 9, so it would be nice if we could suppress the warning *for now*. However, if/when anyone tried to use this code in a NativeAOT context such as 2197579, they *should* get a warning (but didn't). We should instead use: // FIXME: #1192 #pragma warning disable IL3050 // Problematic code here #pragma warning restore IL3050 This will prevent us from introducing new `IL3050` and related warnings, but if anyone consumes `Java.Interop.dll` from NativeAOT they will see the warning. This (re-)introduces IL3050 warnings in the build for `samples/Hello-NativeAOTFromJNI` (2197579): % dotnet publish -c Release -r osx-x64 … …/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs(665): AOT analysis warning 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. …/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs(381): AOT analysis warning 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. …/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs(789): AOT analysis warning IL3050: Java.Interop.JavaPeerableValueMarshaler.CreateParameterToManagedExpression(JniValueMarshalerContext,ParameterExpression,ParameterAttributes,Type): Using member 'System.Linq.Expressions.Expression.Call(Expression,String,Type[],Expression[])' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Calling a generic method requires dynamic code generation. This can be suppressed if the method is not generic. …/src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs(284): AOT analysis warning 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. …/src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs(277): AOT analysis warning 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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
Proposed change to current functionality
java-interop
Runtime bridge between .NET and Java
Related: #1157
When setting
$(EnableAotAnalyzer)
totrue
, there are several warnings we will suppress for now. These will likely work under Mono, but will need to be fixed one day in .NET 10 or some future release that supports NativeAOT.Ignoring AOT warnings like a reasonable place to start, so we can enable the analyzer and not introduce new warnings.
Creating an issue for now, so I can link to this issue from C# code comments.
Requires fixing, at minimum:
The text was updated successfully, but these errors were encountered: