From 0f14e721b2729dd7f8c1c86d2c9171521b6aba60 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 7 May 2025 09:45:34 -0500 Subject: [PATCH 1/2] [tests] enable `Java.Interop-Tests` for NativeAOT --- .../Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs index d21b35e4aba..215fde081a9 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs @@ -30,17 +30,12 @@ protected NUnitInstrumentation(IntPtr handle, JniHandleOwnership transfer) protected override IList GetTestAssemblies() { Assembly asm = Assembly.GetExecutingAssembly(); - #if !NATIVEAOT // TODO: Java.Interop-Tests not passing yet Assembly ji = typeof (Java.InteropTests.JavaInterop_Tests_Reference).Assembly; - #endif - return new List() { new TestAssemblyInfo (asm, asm.Location ?? String.Empty), - #if !NATIVEAOT new TestAssemblyInfo (ji, ji.Location ?? String.Empty), - #endif }; } } From 76c57ffa4d0c842f550fccbf8aaca7402bca2363 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 7 May 2025 14:48:53 -0500 Subject: [PATCH 2/2] Explicitly set JniAddNativeMethodRegistrationAttributePresent=true --- .../Android.Runtime.NativeAOT/JavaInteropRuntime.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.Android.Runtime.NativeAOT/Android.Runtime.NativeAOT/JavaInteropRuntime.cs b/src/Microsoft.Android.Runtime.NativeAOT/Android.Runtime.NativeAOT/JavaInteropRuntime.cs index 982f1c5a210..ec136214707 100644 --- a/src/Microsoft.Android.Runtime.NativeAOT/Android.Runtime.NativeAOT/JavaInteropRuntime.cs +++ b/src/Microsoft.Android.Runtime.NativeAOT/Android.Runtime.NativeAOT/JavaInteropRuntime.cs @@ -46,6 +46,7 @@ static void init (IntPtr jnienv, IntPtr klass) UseMarshalMemberBuilder = false, JniGlobalReferenceLogWriter = settings.GrefLog, JniLocalReferenceLogWriter = settings.LrefLog, + JniAddNativeMethodRegistrationAttributePresent = true, }; runtime = options.CreateJreVM ();