summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2017-10-16 18:03:35 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-10-16 18:03:35 +0000
commit44f520b12bab27ef4c0719f9dd296d76c79b23cb (patch)
treef6c6669471d67192cc7ffd8ea68cc52e5a845b12
parent776f0b98414fe0d996928e7dce982c93195fc113 (diff)
parent148b723aadf04153a397bda6bc4f52cf64691515 (diff)
Merge "Make test testStopRecur in test 1934 not throw SOEs"
-rw-r--r--test/1934-jvmti-signal-thread/src/art/Test1934.java32
1 files changed, 10 insertions, 22 deletions
diff --git a/test/1934-jvmti-signal-thread/src/art/Test1934.java b/test/1934-jvmti-signal-thread/src/art/Test1934.java
index 3e97b20bce..3ab4cf663b 100644
--- a/test/1934-jvmti-signal-thread/src/art/Test1934.java
+++ b/test/1934-jvmti-signal-thread/src/art/Test1934.java
@@ -173,11 +173,13 @@ public class Test1934 {
destroyNativeMonitor(native_monitor_id);
}
- public static void doRecur(Runnable r) {
+ public static void doRecurCnt(Runnable r, int cnt) {
if (r != null) {
r.run();
}
- doRecur(r);
+ if (cnt != 0) {
+ doRecurCnt(r, cnt - 1);
+ }
}
public static void testStopRecur() throws Exception {
@@ -186,27 +188,15 @@ public class Test1934 {
Thread target = new Thread(() -> {
sem.release();
while (true) {
- try {
- doRecur(null);
- } catch (StackOverflowError e) {}
+ doRecurCnt(null, 50);
}
}, "recuring thread!");
target.setUncaughtExceptionHandler((t, e) -> { out_err[0] = e; });
target.start();
sem.acquire();
System.out.println("stopping other thread recurring");
- do {
- // Due to the fact that dex has a specific instruction to get the current exception it is
- // possible for the 'stop-thread' to be unintentionally caught. We just retry in this case.
- try {
- Threads.stopThread(target, new Error("AWESOME!"));
- } catch (Exception e) {
- // If we just missed the thread dying we would get a JVMTI_ERROR_THREAD_NOT_ALIVE so we
- // catch that here.
- }
- // Wait for 1 second.
- target.join(1000);
- } while (target.isAlive());
+ Threads.stopThread(target, new Error("AWESOME!"));
+ target.join();
System.out.println("Other thread Stopped by: " + out_err[0]);
if (PRINT_STACK_TRACE && out_err[0] != null) {
out_err[0].printStackTrace();
@@ -219,11 +209,9 @@ public class Test1934 {
Thread target = new Thread(() -> {
sem.release();
while (true) {
- try {
- doRecur(() -> {
- if (Thread.currentThread().isInterrupted()) { throw new Error("Interrupted!"); }
- });
- } catch (StackOverflowError e) { }
+ doRecurCnt(() -> {
+ if (Thread.currentThread().isInterrupted()) { throw new Error("Interrupted!"); }
+ }, 50);
}
}, "recuring thread!");
target.setUncaughtExceptionHandler((t, e) -> { out_err[0] = e; });