Merge "Make NativeBN's error-handling more robust."
diff --git a/luni/src/test/java/libcore/java/lang/OldThreadTest.java b/luni/src/test/java/libcore/java/lang/OldThreadTest.java
index 03031ac..9632680 100644
--- a/luni/src/test/java/libcore/java/lang/OldThreadTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldThreadTest.java
@@ -193,7 +193,7 @@
         st = new Thread() {
             public void run() {
                 try {
-                    sleep(10000);
+                    sleep(1000);
                 } catch(InterruptedException ie) {
                     wasInterrupted = true;
                 }
@@ -203,7 +203,7 @@
         st.start();
 
         try {
-            Thread.sleep(5000);
+            Thread.sleep(500);
         } catch(InterruptedException e) {
             fail("Unexpected InterruptedException was thrown");
         }
@@ -211,7 +211,7 @@
         st.interrupt();
 
         try {
-            Thread.sleep(5000);
+            Thread.sleep(500);
         } catch(InterruptedException e) {
             fail("Unexpected InterruptedException was thrown");
         }
@@ -240,7 +240,7 @@
         st = new Thread() {
             public void run() {
                 try {
-                    sleep(10000, 99999);
+                    sleep(1000, 9999);
                 } catch(InterruptedException ie) {
                     wasInterrupted = true;
                 }
@@ -250,7 +250,7 @@
         st.start();
 
         try {
-            Thread.sleep(5000, 99999);
+            Thread.sleep(500, 9999);
         } catch(InterruptedException e) {
             fail("Unexpected InterruptedException was thrown");
         }
@@ -258,7 +258,7 @@
         st.interrupt();
 
         try {
-            Thread.sleep(5000);
+            Thread.sleep(500);
         } catch(InterruptedException e) {
             fail("Unexpected InterruptedException was thrown");
         }
@@ -275,7 +275,7 @@
         }
         Counter countersYeld = new Counter(true);
         try {
-            Thread.sleep(11000);
+            Thread.sleep(1100);
         } catch(InterruptedException ie) {}
 
         for(Counter c:countersNotYeld) {
@@ -293,7 +293,7 @@
         }
 
         public void run() {
-            for(int i = 0; i < 10000; i++) {
+            for(int i = 0; i < 1000; i++) {
                 if(isDoYield)
                     yield();
                 counter ++;
diff --git a/luni/src/test/java/libcore/java/lang/SystemTest.java b/luni/src/test/java/libcore/java/lang/SystemTest.java
index f16c380..2dc9d49 100644
--- a/luni/src/test/java/libcore/java/lang/SystemTest.java
+++ b/luni/src/test/java/libcore/java/lang/SystemTest.java
@@ -126,8 +126,8 @@
     public void testArrayCopyConcurrentModification() {
         final AtomicBoolean done = new AtomicBoolean();
 
-        final Object[] source = new Object[1024 * 1024];
-        String[] target = new String[1024 * 1024];
+        final Object[] source = new Object[512 * 1024];
+        String[] target = new String[512 * 1024];
 
         new Thread() {
             @Override public void run() {
@@ -140,7 +140,7 @@
             }
         }.start();
 
-        for (int i = 0; i < 8192; i++) {
+        for (int i = 0; i < 2048; i++) {
             try {
                 System.arraycopy(source, 0, target, 0, source.length);
                 assertNull(target[source.length - 1]); // make sure the wrong type didn't sneak in
diff --git a/luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java b/luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java
index d71b5b0..55e70033 100644
--- a/luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java
+++ b/luni/src/test/java/libcore/java/lang/ref/FinalizeTest.java
@@ -102,11 +102,9 @@
      * to finalize. Check that objects near that limit are okay.
      */
     public void testWatchdogDoesNotFailForObjectsThatAreNearTheDeadline() throws Exception {
-        CountDownLatch latch = new CountDownLatch(5);
+        CountDownLatch latch = new CountDownLatch(3);
         createSlowFinalizer(   1, latch);
         createSlowFinalizer(1000, latch);
-        createSlowFinalizer(2000, latch);
-        createSlowFinalizer(4000, latch);
         createSlowFinalizer(8000, latch);
         FinalizationTester.induceFinalization();
         latch.await();
diff --git a/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java b/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
index a251963..b21689e 100644
--- a/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
+++ b/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
@@ -73,7 +73,7 @@
      * Test for b/27763633.
      */
     public void testConcurrentServerSocketCloseReliablyThrows() {
-        int numIterations = 200;
+        int numIterations = 100;
         for (int i = 0; i < numIterations; i++) {
             checkConnectIterationAndCloseSocket("Iteration " + (i+1) + " of " + numIterations,
                     /* msecPerIteration */ 50);
diff --git a/luni/src/test/java/libcore/java/util/regex/OldMatcherTest.java b/luni/src/test/java/libcore/java/util/regex/OldMatcherTest.java
index deb0626..0116a31 100644
--- a/luni/src/test/java/libcore/java/util/regex/OldMatcherTest.java
+++ b/luni/src/test/java/libcore/java/util/regex/OldMatcherTest.java
@@ -576,10 +576,10 @@
         final Matcher m = p.matcher("");
 
         ArrayList<Thread> threads = new ArrayList<Thread>();
-        for (int i = 0; i < 10; ++i) {
+        for (int i = 0; i < 5; ++i) {
             Thread t = new Thread(new Runnable() {
                 public void run() {
-                    for (int i = 0; i < 4096; ++i) {
+                    for (int i = 0; i < 1024; ++i) {
                         String s = "some example text";
                         m.reset(s);
                         try {