Skip to content

Commit

Permalink
Revert "Update Object.GetObject() to use JniRuntime.JniValueManager"
Browse files Browse the repository at this point in the history
This reverts commit f3c122e.

This doens't build, because d3cde47 turns all warnings into errors,
and this commit introduces a warning.

PR #9728 is the proper fix.
  • Loading branch information
jonpryor committed Jan 30, 2025
1 parent f3c122e commit 7376e72
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Mono.Android/Java.Lang/Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,13 @@ protected void SetHandle (IntPtr value, JniHandleOwnership transfer)
if (handle == IntPtr.Zero)
return null;

var p = JNIEnvInit.ValueManager!.GetPeer (new JniObjectReference (handle), type);
JNIEnv.DeleteRef (handle, transfer);
return p;
var r = PeekObject (handle, type);
if (r != null) {
JNIEnv.DeleteRef (handle, transfer);
return r;
}

return Java.Interop.TypeManager.CreateInstance (handle, transfer, type);
}

[EditorBrowsable (EditorBrowsableState.Never)]
Expand Down

0 comments on commit 7376e72

Please sign in to comment.