Add an uncaught exception handler in 844-exception.

The test requires an exception to be returned from the top of the call
stack. To not depend on the Java naming of which thread is throwing that
exception, add an uncaught exception handler.

Test: 844-exception
Change-Id: I14c26e9daf2065ee35a3ef49c293c75742b7220e
diff --git a/test/844-exception/expected-stderr.txt b/test/844-exception/expected-stderr.txt
index 9804bd0..e69de29 100644
--- a/test/844-exception/expected-stderr.txt
+++ b/test/844-exception/expected-stderr.txt
@@ -1,5 +0,0 @@
-Exception in thread "Thread-1" java.lang.Error: 
-	at Main.callMethodThatThrows(Main.java:57)
-	at Main$Inner2.<clinit>(Main.java:38)
-	at Main$Inner.<clinit>(Main.java:32)
-	at Main$MyThread.run(Main.java:24)
diff --git a/test/844-exception/expected-stdout.txt b/test/844-exception/expected-stdout.txt
index 6a5618e..7ddf8e3 100644
--- a/test/844-exception/expected-stdout.txt
+++ b/test/844-exception/expected-stdout.txt
@@ -1 +1,2 @@
 JNI_OnLoad called
+Caught exception
diff --git a/test/844-exception/src/Main.java b/test/844-exception/src/Main.java
index 79d61cc..6237844 100644
--- a/test/844-exception/src/Main.java
+++ b/test/844-exception/src/Main.java
@@ -47,6 +47,9 @@
     // Execute the test in a different thread, to ensure we still
     // return a 0 exit status.
     Thread t = new MyThread();
+    t.setUncaughtExceptionHandler((th, e) -> {
+      System.out.println("Caught exception");
+    });
     t.start();
     t.join();
   }