diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index bbc62917f68f96..7ff2bc5006b9f3 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -607,17 +607,6 @@ - - - - - - - - - - - diff --git a/src/tasks/AndroidAppBuilder/Templates/monodroid-nativeaot.cs b/src/tasks/AndroidAppBuilder/Templates/monodroid-nativeaot.cs index 963c1bef392caa..736d7cc33893e2 100644 --- a/src/tasks/AndroidAppBuilder/Templates/monodroid-nativeaot.cs +++ b/src/tasks/AndroidAppBuilder/Templates/monodroid-nativeaot.cs @@ -120,15 +120,18 @@ internal unsafe struct JNIEnv { fixed (JNIEnv* thisptr = &this) { - byte* chars = NativeInterface->GetStringUTFChars(thisptr, str, out byte isCopy); + byte* chars = NativeInterface->GetStringUTFChars(thisptr, str, null); if (chars is null) return null; - string result = Marshal.PtrToStringUTF8((nint)chars)!; - if (isCopy != 0) + try + { + return Marshal.PtrToStringUTF8((nint)chars)!; + } + finally + { NativeInterface->ReleaseStringUTFChars(thisptr, str, chars); - - return result; + } } } @@ -383,7 +386,7 @@ unsafe struct JNINativeInterface void* NewStringUTF; delegate* unmanaged[Cdecl] GetStringUTFLength; - public delegate* unmanaged[Cdecl] GetStringUTFChars; + public delegate* unmanaged[Cdecl] GetStringUTFChars; public delegate* unmanaged[Cdecl] ReleaseStringUTFChars; public delegate* unmanaged[Cdecl] GetArrayLength;