Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ee565e4
Improve JavaProxyThrowable by translating managed stack trace
grendello Jul 12, 2023
7c0a507
Update apkdiffs
grendello Jul 12, 2023
6ee31a3
Create JavaProxyThrowable with `Create` and reflection
grendello Jul 12, 2023
7cfc3dc
Oops
grendello Jul 12, 2023
78839fb
Seal the class and add test
grendello Jul 13, 2023
b2b38b1
Merge branch 'main' into throwable-stacktrace
grendello Jul 14, 2023
ada140c
Optionally append java stack trace
grendello Jul 14, 2023
45b3e72
oops
grendello Jul 14, 2023
241ed9b
Merge branch 'main' into throwable-stacktrace
grendello Jul 17, 2023
c1cabbc
oops #2
grendello Jul 17, 2023
4c38c11
Let's see if this works
grendello Jul 17, 2023
7a8964b
Java and managed traces differ, let's see what's the difference
grendello Jul 17, 2023
1bac358
Merge branch 'main' into throwable-stacktrace
grendello Jul 18, 2023
998c012
That should do it
grendello Jul 18, 2023
a25636d
Merge branch 'main' into throwable-stacktrace
grendello Jul 18, 2023
92e5db3
Merge branch 'main' into throwable-stacktrace
grendello Jul 24, 2023
4b5b56e
Update JavaProxyThrowable.cs
grendello Jul 26, 2023
b68dcc2
Merge branch 'main' into throwable-stacktrace
grendello Jul 27, 2023
32130ab
Get the Java stack trace from `self` directly
grendello Jul 27, 2023
603f1e4
Merge branch 'throwable-stacktrace' of github.com:grendello/xamarin-a…
grendello Jul 27, 2023
cdf4714
Merge branch 'main' into throwable-stacktrace
grendello Jul 31, 2023
784014c
Address comments
grendello Jul 31, 2023
a78d466
Merge remote-tracking branch 'origin/main' into throwable-stacktrace
jonpryor Aug 18, 2023
691e075
Update ExceptionTest.cs
jonpryor Aug 22, 2023
af90f92
Fix unit test.
jonpryor Aug 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Seal the class and add test
NOTE: test, umm, untested! Unable to build the project locally
  • Loading branch information
grendello committed Jul 13, 2023
commit 78839fb7a07c94f4a3b1bd9b2326b27a8efd5bbd
4 changes: 2 additions & 2 deletions src/Mono.Android/Android.Runtime/JavaProxyThrowable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

namespace Android.Runtime {

class JavaProxyThrowable : Java.Lang.Error {
sealed class JavaProxyThrowable : Java.Lang.Error {

public readonly Exception InnerException;

protected JavaProxyThrowable (string message, Exception innerException)
JavaProxyThrowable (string message, Exception innerException)
: base (message)
{
InnerException = innerException;
Expand Down
20 changes: 20 additions & 0 deletions tests/Mono.Android-Tests/System/ExceptionTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;

Expand Down Expand Up @@ -34,9 +35,28 @@ public void InnerExceptionIsSet ()
var ex = new InvalidOperationException ("boo!");
using (var source = new Java.Lang.Throwable ("detailMessage", CreateJavaProxyThrowable (ex)))
using (var alias = new Java.Lang.Throwable (source.Handle, JniHandleOwnership.DoNotTransfer)) {
CompareStackTraces (ex, source);
Assert.AreEqual ("detailMessage", alias.Message);
Assert.AreSame (ex, alias.InnerException);
}
}

void CompareStackTraces (Exception ex, Java.Lang.Throwable throwable)
{
var managedTrace = new StackTrace (ex);
StackFrame[] managedFrames = managedTrace.GetFrames ();
Java.Lang.StackTraceElement[] javaFrames = throwable.GetStackTrace ();

Assert.AreEqual (managedFrames.Length, javaFrames.Length, "Java and managed stack traces have a different number of frames");
for (int i = 0; i < managedFrames.Length; i++) {
var mf = managedFrames[i];
var jf = javaFrames[i];

Assert.AreEqual (mf.GetMethod ()?.Name, jf.MethodName, $"Frame {i}: method names differ");
Assert.AreEqual (mf.GetMethod ()?.DeclaringType.FullName, jf.ClassName, $"Frame {i}: class names differ");
Assert.AreEqual (mf.GetFileName (), jf.FileName, $"Frame {i}: file names differ");
Assert.AreEqual (mf.GetFileLineNumber (), jf.LineNumber, $"Frame {i}: line numbers differ");
}
}
}
}