Skip to content

Commit 11145de

Browse files
committed
Use JniEnvironment.Runtime.OnUserUnhandledException.
1 parent 98beeaa commit 11145de

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/Java.Interop/Java.Interop/JniRuntime.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,14 @@ public virtual bool ExceptionShouldTransitionToJni (Exception e)
437437

438438
partial class JniRuntime {
439439

440+
public virtual void OnUserUnhandledException (ref JniTransition transition, Exception e)
441+
{
442+
transition.SetPendingException (e);
443+
444+
// TODO: Enable when we move to 'net9.0'
445+
//Debugger.BreakForUserUnhandledException (e);
446+
}
447+
440448
public virtual void RaisePendingException (Exception pendingException)
441449
{
442450
JniEnvironment.Exceptions.Throw (pendingException);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
#nullable enable
2+
virtual Java.Interop.JniRuntime.OnUserUnhandledException(ref Java.Interop.JniTransition transition, System.Exception! e) -> void

tools/generator/SourceWriters/MethodCallback.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ protected override void WriteBody (CodeWriter writer)
9191

9292
writer.WriteLine ("} catch (global::System.Exception __e) {");
9393
writer.Indent ();
94-
writer.WriteLine ("__envp.SetPendingException (__e);");
95-
writer.WriteLine ("global::System.Diagnostics.Debugger.BreakForUserUnhandledException (__e);");
94+
writer.WriteLine ("JniEnvironment.Runtime.OnUserUnhandledException (ref __envp, __e);");
9695

9796
if (!method.IsVoid)
9897
writer.WriteLine ("return default;");

0 commit comments

Comments
 (0)