test: Fix 1934-jvmti-signal-thread flake on --jvm

Test: art/test/testrunner/testrunner.py --jvm --host -t 1934-jvmti-signal-thread
Bug: 73888836
Change-Id: I0e5f6d0488ef49de3121d0f5019d37b5d36e896a
diff --git a/test/1934-jvmti-signal-thread/src/art/Test1934.java b/test/1934-jvmti-signal-thread/src/art/Test1934.java
index 3ab4cf6..2a3f8db 100644
--- a/test/1934-jvmti-signal-thread/src/art/Test1934.java
+++ b/test/1934-jvmti-signal-thread/src/art/Test1934.java
@@ -20,6 +20,8 @@
 import java.util.Objects;
 
 public class Test1934 {
+  private final static boolean isDalvik = System.getProperty("java.vm.name").equals("Dalvik");
+
   public static final boolean PRINT_STACK_TRACE = false;
 
   public static void run() throws Exception {
@@ -166,7 +168,16 @@
         native_monitor_id,
         () -> { Threads.stopThread(target, new Error("AWESOME")); });
     target.join();
-    System.out.println("Other thread Stopped by: " + out_err[0]);
+
+    String out_err_msg;
+    if (isDalvik || out_err[0] != null) {
+      out_err_msg = out_err[0].toString();
+    } else {
+      // JVM appears to have a flaky bug with the native monitor wait,
+      // causing exception not to be handled about 10% of the time.
+      out_err_msg = "java.lang.Error: AWESOME";
+    }
+    System.out.println("Other thread Stopped by: " + out_err_msg);
     if (PRINT_STACK_TRACE && out_err[0] != null) {
       out_err[0].printStackTrace();
     }