Merge "WatchServiceTest#test_multipleKeys fix"
diff --git a/OWNERS b/OWNERS
index 72d7fb4..91f818d 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,3 +1,18 @@
-nfuller@google.com
-pszczepaniak@google.com
+# Use this reviewer by default.
 android-libcore-team+review@google.com
+
+# People who can approve changes for submission; don't send review emails to them
+# unless you know what you're doing.
+flooey@google.com
+jsauer@google.com
+narayan@google.com
+nfuller@google.com
+paulduffin@google.com
+peteg@google.com
+pszczepaniak@google.com
+tobiast@google.com
+vichang@google.com
+
+# Don't send these folks any review emails for this project.
+ngeoffray@google.com
+sehr@google.com
diff --git a/dalvik/src/main/java/dalvik/system/DexFile.java b/dalvik/src/main/java/dalvik/system/DexFile.java
index 3cd10e3..bc5d3db 100644
--- a/dalvik/src/main/java/dalvik/system/DexFile.java
+++ b/dalvik/src/main/java/dalvik/system/DexFile.java
@@ -411,7 +411,7 @@
     /**
      * No dexopt should (or can) be done to update the apk/jar.
      *
-     * See {@link #getDexOptNeeded(String, String, int)}.
+     * See {@link #getDexOptNeeded(String, String, String, boolean, boolean)}.
      *
      * @hide
      */
@@ -420,7 +420,7 @@
     /**
      * dex2oat should be run to update the apk/jar from scratch.
      *
-     * See {@link #getDexOptNeeded(String, String, int)}.
+     * See {@link #getDexOptNeeded(String, String, String, boolean, boolean)}.
      *
      * @hide
      */
@@ -430,7 +430,7 @@
      * dex2oat should be run to update the apk/jar because the existing code
      * is out of date with respect to the boot image.
      *
-     * See {@link #getDexOptNeeded(String, String, int)}.
+     * See {@link #getDexOptNeeded(String, String, String, boolean, boolean)}.
      *
      * @hide
      */
@@ -440,7 +440,7 @@
      * dex2oat should be run to update the apk/jar because the existing code
      * is out of date with respect to the target compiler filter.
      *
-     * See {@link #getDexOptNeeded(String, String, int)}.
+     * See {@link #getDexOptNeeded(String, String, String, boolean, boolean)}.
      *
      * @hide
      */
@@ -450,7 +450,7 @@
      * dex2oat should be run to update the apk/jar because the existing code
      * is not relocated to match the boot image.
      *
-     * See {@link #getDexOptNeeded(String, String, int)}.
+     * See {@link #getDexOptNeeded(String, String, String, boolean, boolean)}.
      *
      * @hide
      */
@@ -467,6 +467,8 @@
      * @param newProfile flag that describes whether a profile corresponding
      *        to the dex file has been recently updated and should be considered
      *        in the state of the file.
+     * @param downgrade flag that describes if the purpose of dexopt is to downgrade the
+     *        compiler filter. If set to false, will be evaluated as an upgrade request.
      * @return NO_DEXOPT_NEEDED, or DEX2OAT_*. See documentation
      *         of the particular status code for more information on its
      *         meaning. Returns a positive status code if the status refers to
@@ -481,7 +483,7 @@
      * @hide
      */
     public static native int getDexOptNeeded(String fileName,
-            String instructionSet, String compilerFilter, boolean newProfile)
+            String instructionSet, String compilerFilter, boolean newProfile, boolean downgrade)
             throws FileNotFoundException, IOException;
 
     /**
diff --git a/dalvik/src/main/java/dalvik/system/InMemoryDexClassLoader.java b/dalvik/src/main/java/dalvik/system/InMemoryDexClassLoader.java
index 0fa1e45..0603260 100644
--- a/dalvik/src/main/java/dalvik/system/InMemoryDexClassLoader.java
+++ b/dalvik/src/main/java/dalvik/system/InMemoryDexClassLoader.java
@@ -30,7 +30,6 @@
      * @param dexBuffers array of buffers containing DEX files between
      *                       <tt>buffer.position()</tt> and <tt>buffer.limit()</tt>.
      * @param parent the parent class loader for delegation.
-     * @hide
      */
     public InMemoryDexClassLoader(ByteBuffer[] dexBuffers, ClassLoader parent) {
         super(dexBuffers, parent);
diff --git a/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp b/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
index 9a934f6..f3c552f 100644
--- a/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
+++ b/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
@@ -16,8 +16,8 @@
 
 #define LOG_TAG "NativeTestTarget"
 
-#include "JNIHelp.h"
-#include "JniConstants.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
 
 static void NativeTestTarget_emptyJniStaticSynchronizedMethod0(JNIEnv*, jclass) { }
 static void NativeTestTarget_emptyJniSynchronizedMethod0(JNIEnv*, jclass) { }
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index bb51526..e9b6057 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -89,23 +89,6 @@
   bug: 2985901
 },
 {
-  description: "UTF-16 and UTF-32 encoders don't write big-endian output on little-endian devices",
-  names: [
-    "libcore.java.nio.charset.CharsetEncoderTest#test_defaultReplacementBytesUtf_16",
-    "libcore.java.nio.charset.OldCharset_MultiByte_UTF_16#test_Encode",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_UTF_16",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_UTF_16BE",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_UTF_16LE",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_UTF_32",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_UTF_32BE",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_UTF_32LE",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_x_UTF_16LE_BOM",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_X_UTF_32BE_BOM",
-    "org.apache.harmony.tests.java.nio.charset.CharsetTest#test_X_UTF_32LE_BOM"
-  ],
-  bug: 2702411
-},
-{
   description: "It's not allowed to pass null as parent class loader to a new ClassLoader anymore. Maybe we need
                 to change URLClassLoader to allow this? It's not specified.",
   result: EXEC_FAILED,
@@ -1423,17 +1406,6 @@
   name: "com.android.org.apache.harmony.logging.tests.java.util.logging.LevelTest#testSerializationCompatibility"
 },
 {
-  description: "java.util.beans: the harmony tests were broken by Android commit 19a270e90b1e992c1f6639f355ae13564c2f3a6a",
-  bug: 17394106,
-  names: [
-    "com.android.org.apache.harmony.beans.tests.java.beans.PropertyChangeSupportTest#testSerialization",
-    "com.android.org.apache.harmony.beans.tests.java.beans.PropertyChangeSupportTest#testGetPropertyChangeListener_String_Normal",
-    "com.android.org.apache.harmony.beans.tests.java.beans.PropertyChangeSupportTest#testAddPropertyChangeListener_PropertyChangeListener_String_Duplicate",
-    "com.android.org.apache.harmony.beans.tests.java.beans.PropertyChangeSupportTest#testAddPropertyChangeListener_PropertyChangeListener_String_Normal",
-    "com.android.org.apache.harmony.beans.tests.java.beans.PropertyChangeSupportTest#testAddPropertyChangeListener_PropertyChangeListener_Normal"
-  ]
-},
-{
   description: "java.util.beans: the serialized form references org.apache not com.android.org.apache",
   bug: 17394106,
   names: [
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/String2Test.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/String2Test.java
index eecc601..c3f1202 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/String2Test.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/String2Test.java
@@ -469,13 +469,15 @@
         }
 
         bytes = "-".getBytes("UTF-16");
-        expected = new byte[] { (byte) 0xff, (byte) 0xfe };
+        expected = new byte[] { (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x2d };
         assertEquals(expected[0], bytes[0]);
         assertEquals(expected[1], bytes[1]);
+        assertEquals(expected[2], bytes[2]);
+        assertEquals(expected[3], bytes[3]);
 
         byte[] bytes2 = "-".getBytes("UTF-16LE");
-        assertEquals(bytes2[0], bytes[2]);
-        assertEquals(bytes2[1], bytes[3]);
+        assertEquals(bytes2[0], bytes[3]);
+        assertEquals(bytes2[1], bytes[2]);
     }
 
     /*
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/charset/CharsetTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/charset/CharsetTest.java
index 2cf278d..15842c0 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/charset/CharsetTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/charset/CharsetTest.java
@@ -17,6 +17,7 @@
 package org.apache.harmony.tests.java.nio.charset;
 
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 import java.nio.CharBuffer;
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
@@ -44,12 +45,6 @@
   public void test_allAvailableCharsets() throws Exception {
     // Check that we can instantiate every Charset, CharsetDecoder, and CharsetEncoder.
     for (String charsetName : Charset.availableCharsets().keySet()) {
-      if (charsetName.equals("UTF-32")) {
-        // Our UTF-32 is broken. http://b/2702411
-        // TODO: remove this hack when UTF-32 is fixed.
-        continue;
-      }
-
       Charset cs = Charset.forName(charsetName);
       assertNotNull(cs.newDecoder());
       if (cs.canEncode()) {
@@ -159,7 +154,7 @@
     Charset cs = Charset.forName("UTF-16");
     // Writes big-endian, with a big-endian BOM.
     assertEncodes(cs, "a\u0666", 0xfe, 0xff, 0, 'a', 0x06, 0x66);
-    // Reads whatever the BOM tells it to read...
+    // Reads whatever the BOM tells it to read, and swallows the BOM...
     assertDecodes(cs, "a\u0666", 0xfe, 0xff, 0, 'a', 0x06, 0x66);
     assertDecodes(cs, "a\u0666", 0xff, 0xfe, 'a', 0, 0x66, 0x06);
     // ...and defaults to reading big-endian if there's no BOM.
@@ -170,9 +165,7 @@
     Charset cs = Charset.forName("UTF-16BE");
     // Writes big-endian, with no BOM.
     assertEncodes(cs, "a\u0666", 0, 'a', 0x06, 0x66);
-    // Treats a little-endian BOM as an error and continues to read big-endian.
-    // This test uses REPLACE mode, so we get the U+FFFD replacement character in the result.
-    assertDecodes(cs, "\ufffda\u0666", 0xff, 0xfe, 0, 'a', 0x06, 0x66);
+    // We don't make any assertion about the handling of a little-endian BOM.
     // Accepts a big-endian BOM and includes U+FEFF in the decoded output.
     assertDecodes(cs, "\ufeffa\u0666", 0xfe, 0xff, 0, 'a', 0x06, 0x66);
     // Defaults to reading big-endian.
@@ -185,9 +178,7 @@
     assertEncodes(cs, "a\u0666", 'a', 0, 0x66, 0x06);
     // Accepts a little-endian BOM and includes U+FEFF in the decoded output.
     assertDecodes(cs, "\ufeffa\u0666", 0xff, 0xfe, 'a', 0, 0x66, 0x06);
-    // Treats a big-endian BOM as an error and continues to read little-endian.
-    // This test uses REPLACE mode, so we get the U+FFFD replacement character in the result.
-    assertDecodes(cs, "\ufffda\u0666", 0xfe, 0xff, 'a', 0, 0x66, 0x06);
+    // We don't make any assertion about the handling of a big-endian BOM.
     // Defaults to reading little-endian.
     assertDecodes(cs, "a\u0666", 'a', 0, 0x66, 0x06);
   }
@@ -198,17 +189,20 @@
     assertEncodes(cs, "a\u0666", 0xff, 0xfe, 'a', 0, 0x66, 0x06);
     // Accepts a little-endian BOM and swallows the BOM.
     assertDecodes(cs, "a\u0666", 0xff, 0xfe, 'a', 0, 0x66, 0x06);
-    // Swallows a big-endian BOM, but continues to read little-endian!
-    assertDecodes(cs, "\u6100\u6606", 0xfe, 0xff, 'a', 0, 0x66, 0x06);
+    // We don't make any assertion about the handling of a big-endian BOM.
     // Defaults to reading little-endian.
     assertDecodes(cs, "a\u0666", 'a', 0, 0x66, 0x06);
   }
 
   public void test_UTF_32() throws Exception {
     Charset cs = Charset.forName("UTF-32");
-    // Writes big-endian, with no BOM.
-    assertEncodes(cs, "a\u0666", 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
-    // Reads whatever the BOM tells it to read...
+    // Writes platform-endian, with a BOM.
+    if (ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN)) {
+      assertEncodes(cs, "a\u0666", 0, 0, 0xfe, 0xff, 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
+    } else {
+      assertEncodes(cs, "a\u0666", 0xff, 0xfe, 0, 0, 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
+    }
+    // Reads whatever the BOM tells it to read, and swallows the BOM...
     assertDecodes(cs, "a\u0666", 0, 0, 0xfe, 0xff, 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
     assertDecodes(cs, "a\u0666", 0xff, 0xfe, 0, 0, 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
     // ...and defaults to reading big-endian if there's no BOM.
@@ -219,11 +213,9 @@
     Charset cs = Charset.forName("UTF-32BE");
     // Writes big-endian, with no BOM.
     assertEncodes(cs, "a\u0666", 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
-    // Treats a little-endian BOM as an error and continues to read big-endian.
-    // This test uses REPLACE mode, so we get the U+FFFD replacement character in the result.
-    assertDecodes(cs, "\ufffda\u0666", 0xff, 0xfe, 0, 0, 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
-    // Accepts a big-endian BOM and swallows the BOM.
-    assertDecodes(cs, "a\u0666", 0, 0, 0xfe, 0xff, 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
+    // We don't make any assertion about the handling of a little-endian BOM.
+    // Accepts a big-endian BOM and includes U+FEFF in the decoded output.
+    assertDecodes(cs, "\ufeffa\u0666", 0, 0, 0xfe, 0xff, 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
     // Defaults to reading big-endian.
     assertDecodes(cs, "a\u0666", 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
   }
@@ -232,37 +224,9 @@
     Charset cs = Charset.forName("UTF-32LE");
     // Writes little-endian, with no BOM.
     assertEncodes(cs, "a\u0666", 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
-    // Accepts a little-endian BOM and swallows the BOM.
-    assertDecodes(cs, "a\u0666", 0xff, 0xfe, 0, 0, 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
-    // Treats a big-endian BOM as an error and continues to read little-endian.
-    // This test uses REPLACE mode, so we get the U+FFFD replacement character in the result.
-    assertDecodes(cs, "\ufffda\u0666", 0, 0, 0xfe, 0xff, 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
-    // Defaults to reading little-endian.
-    assertDecodes(cs, "a\u0666", 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
-  }
-
-  public void test_X_UTF_32BE_BOM() throws Exception {
-    Charset cs = Charset.forName("X-UTF-32BE-BOM");
-    // Writes big-endian, with a big-endian BOM.
-    assertEncodes(cs, "a\u0666", 0, 0, 0xfe, 0xff, 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
-    // Treats a little-endian BOM as an error and continues to read big-endian.
-    // This test uses REPLACE mode, so we get the U+FFFD replacement character in the result.
-    assertDecodes(cs, "\ufffda\u0666", 0xff, 0xfe, 0, 0, 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
-    // Swallows a big-endian BOM, and continues to read big-endian.
-    assertDecodes(cs, "a\u0666", 0, 0, 0xfe, 0xff, 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
-    // Defaults to reading big-endian.
-    assertDecodes(cs, "a\u0666", 0, 0, 0, 'a', 0, 0, 0x06, 0x66);
-  }
-
-  public void test_X_UTF_32LE_BOM() throws Exception {
-    Charset cs = Charset.forName("X-UTF-32LE-BOM");
-    // Writes little-endian, with a little-endian BOM.
-    assertEncodes(cs, "a\u0666", 0xff, 0xfe, 0, 0, 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
-    // Accepts a little-endian BOM and swallows the BOM.
-    assertDecodes(cs, "a\u0666", 0xff, 0xfe, 0, 0, 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
-    // Treats a big-endian BOM as an error and continues to read little-endian.
-    // This test uses REPLACE mode, so we get the U+FFFD replacement character in the result.
-    assertDecodes(cs, "\ufffda\u0666", 0, 0, 0xfe, 0xff, 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
+    // Accepts a little-endian BOM and includes U+FEFF in the decoded output.
+    assertDecodes(cs, "\ufeffa\u0666", 0xff, 0xfe, 0, 0, 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
+    // We don't make any assertion about the handling of a big-endian BOM.
     // Defaults to reading little-endian.
     assertDecodes(cs, "a\u0666", 'a', 0, 0, 0, 0x66, 0x06, 0, 0);
   }
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/charset/UTF16CharsetEncoderTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/charset/UTF16CharsetEncoderTest.java
index a0f2ac3..fa92872 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/charset/UTF16CharsetEncoderTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/charset/UTF16CharsetEncoderTest.java
@@ -38,12 +38,12 @@
 	 */
 	protected void setUp() throws Exception {
 		cs = CS;
-		specifiedReplacement = new byte[] { -3, -1 };
-		surrogate = new byte[] { -1, -2 };
-		unibytes = new byte[] { 32, 0, 98, 0, 117, 0, 102, 0, 102, 0, 101, 0,
-				114, 0 };
-		unibytesWithRep = new byte[] { -3, -1, 32, 0, 98, 0, 117, 0, 102, 0,
-				102, 0, 101, 0, 114, 0 };
+		specifiedReplacement = new byte[] { -1, -3 };
+		surrogate = new byte[] { -2, -1 };
+		unibytes = new byte[] { 0, 32, 0, 98, 0, 117, 0, 102, 0, 102, 0, 101,
+				0, 114 };
+		unibytesWithRep = new byte[] { -1, -3, 0, 32, 0, 98, 0, 117, 0, 102,
+				0, 102, 0, 101, 0, 114 };
 		super.setUp();
 	}
 
@@ -112,17 +112,4 @@
 		// return new byte[]{(byte)0xd8, 0x00};
 		return new byte[] { (byte) 0x00, (byte) 0xd8 };
 	}
-
-	void assertByteArray(ByteBuffer out, byte[] expected) {
-		out = out.duplicate();
-		if (out.position() > 0) {
-			out.flip();
-		}
-		try {
-			assertEquals(decoder.decode(out), decoder.decode(ByteBuffer
-					.wrap(expected)));
-		} catch (CharacterCodingException e) {
-			fail(e.toString());
-		}
-	}
 }
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
index 9f749c6..98508e1 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
@@ -158,6 +158,47 @@
     public void testReset() {
     }
 
+    /**
+     * Ensures {@link Matcher#find(int)} resets the matcher state and creates a new snapshot of the
+     * original CharSequence before doing the find. http://b/38021063
+     */
+    public void testFind_invokeReset() {
+        // Assert that find() doesn't reset the matcher by doing multiple find() calls on the same
+        // input.
+        Pattern p = Pattern.compile("a|c");
+        StringBuilder sb = new StringBuilder("abc");
+        Matcher m = p.matcher(sb);
+        assertTrue(m.find());
+        assertEquals(0, m.start());
+        assertTrue(m.find());
+        assertEquals(2, m.start());
+
+        // Assert that find(int) resets the matcher by checking its state.
+        assertTrue(m.find(0));
+        assertEquals(0, m.start());
+
+        // Assert that find(int) refreshes the String being matched against from the input
+        // CharSequence.
+        sb.replace(0, 3, "bac");
+        assertTrue(m.find(0));
+        assertEquals(1, m.start());
+    }
+
+    /**
+     * Ensure {@link Matcher#reset()} creates a new snapshot of the original CharSequence.
+     * http://b/38021063
+     */
+    public void testReset_resetStringCache() {
+        Pattern p = Pattern.compile("a");
+        StringBuilder sb = new StringBuilder("a");
+        Matcher m = p.matcher(sb);
+        assertTrue(m.find());
+
+        sb.replace(0, 1, "c");
+        m.reset();
+        assertFalse(m.find());
+    }
+
     public void testGroupint() {
         String positiveTestString = "ababababbaaabb";
 
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLSessionTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLSessionTest.java
index fde1ff8..978f20b 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLSessionTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLSessionTest.java
@@ -124,22 +124,6 @@
     }
 
     /**
-     * javax.net.ssl.SSLSession#getId()
-     */
-    public void test_getId() throws Exception {
-        byte[] id = clientSession.getId();
-        SSLSession sess = clientSslContext.getClientSessionContext().getSession(id);
-        assertNotNull("Could not find session for id " + id, sess);
-        if (clientSession instanceof ExtendedSSLSession) {
-            assertTrue(sess instanceof ExtendedSSLSession);
-            assertExtendedSSLSessionsEqual((ExtendedSSLSession) clientSession,
-                    (ExtendedSSLSession) sess);
-        } else {
-            assertSSLSessionsEqual(clientSession, sess);
-        }
-    }
-
-    /**
      * javax.net.ssl.SSLSession#getLastAccessedTime()
      */
     public void test_getLastAccessedTime() {
@@ -230,27 +214,27 @@
 
         try {
             s.putValue(null, null);
-            fail("IllegalArgumentException wasn't thrown");
-        } catch (IllegalArgumentException expected) {
+            fail("Exception wasn't thrown");
+        } catch (IllegalArgumentException | NullPointerException expected) {
             // expected
         }
         try {
             s.putValue("ABC", null);
-            fail("IllegalArgumentException wasn't thrown");
-        } catch (IllegalArgumentException expected) {
+            fail("Exception wasn't thrown");
+        } catch (IllegalArgumentException | NullPointerException expected) {
             // expected
         }
         try {
             s.putValue(null, sbl);
-            fail("IllegalArgumentException wasn't thrown");
-        } catch (IllegalArgumentException expected) {
+            fail("Exception wasn't thrown");
+        } catch (IllegalArgumentException | NullPointerException expected) {
             // expected
         }
 
         try {
             s.removeValue(null);
-            fail("IllegalArgumentException wasn't thrown");
-        } catch (IllegalArgumentException expected) {
+            fail("Exception wasn't thrown");
+        } catch (IllegalArgumentException | NullPointerException expected) {
             // expected
         }
     }
@@ -264,8 +248,8 @@
 
         try {
             s.getValue(null);
-            fail("IllegalArgumentException wasn't thrown");
-        } catch (IllegalArgumentException expected) {
+            fail("Exception wasn't thrown");
+        } catch (IllegalArgumentException | NullPointerException expected) {
             // expected
         }
 
diff --git a/include/ScopedIcuLocale.h b/include/ScopedIcuLocale.h
index 64186e3..851de76 100644
--- a/include/ScopedIcuLocale.h
+++ b/include/ScopedIcuLocale.h
@@ -17,8 +17,8 @@
 #ifndef SCOPED_ICU_LOCALE_H_included
 #define SCOPED_ICU_LOCALE_H_included
 
-#include "JNIHelp.h"
-#include "ScopedUtfChars.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedUtfChars.h>
 #include "unicode/locid.h"
 
 class ScopedIcuLocale {
diff --git a/include/ScopedJavaUnicodeString.h b/include/ScopedJavaUnicodeString.h
index c1f487e..a30aa7e 100644
--- a/include/ScopedJavaUnicodeString.h
+++ b/include/ScopedJavaUnicodeString.h
@@ -17,7 +17,7 @@
 #ifndef SCOPED_JAVA_UNICODE_STRING_H_included
 #define SCOPED_JAVA_UNICODE_STRING_H_included
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #include "unicode/unistr.h"
 
 // A smart pointer that provides access to an ICU UnicodeString given a JNI
@@ -56,7 +56,7 @@
  private:
   JNIEnv* mEnv;
   jstring mString;
-  const UChar* mChars;
+  const jchar* mChars;
   icu::UnicodeString mUnicodeString;
 
   // Disallow copy and assignment.
diff --git a/json/src/main/java/org/json/JSONArray.java b/json/src/main/java/org/json/JSONArray.java
index 9b5f2b7..996f449 100644
--- a/json/src/main/java/org/json/JSONArray.java
+++ b/json/src/main/java/org/json/JSONArray.java
@@ -290,7 +290,7 @@
             }
             return value;
         } catch (IndexOutOfBoundsException e) {
-            throw new JSONException("Index " + index + " out of range [0.." + values.size() + ")");
+            throw new JSONException("Index " + index + " out of range [0.." + values.size() + ")", e);
         }
     }
 
diff --git a/json/src/main/java/org/json/JSONException.java b/json/src/main/java/org/json/JSONException.java
index 2c66eb8..05e1ddd 100644
--- a/json/src/main/java/org/json/JSONException.java
+++ b/json/src/main/java/org/json/JSONException.java
@@ -46,4 +46,13 @@
     public JSONException(String s) {
         super(s);
     }
+
+    public JSONException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public JSONException(Throwable cause) {
+        super(cause);
+    }
+
 }
diff --git a/luni/src/main/java/android/system/OsConstants.java b/luni/src/main/java/android/system/OsConstants.java
index 2e6fc1b..72c5734 100644
--- a/luni/src/main/java/android/system/OsConstants.java
+++ b/luni/src/main/java/android/system/OsConstants.java
@@ -261,7 +261,7 @@
     public static final int FD_CLOEXEC = placeholder();
     public static final int FIONREAD = placeholder();
     public static final int F_DUPFD = placeholder();
-    /** @hide */ public static final int F_DUPFD_CLOEXEC = placeholder();
+    public static final int F_DUPFD_CLOEXEC = placeholder();
     public static final int F_GETFD = placeholder();
     public static final int F_GETFL = placeholder();
     public static final int F_GETLK = placeholder();
@@ -366,7 +366,7 @@
     public static final int NI_NUMERICSERV = placeholder();
     public static final int O_ACCMODE = placeholder();
     public static final int O_APPEND = placeholder();
-    /** @hide */ public static final int O_CLOEXEC = placeholder();
+    public static final int O_CLOEXEC = placeholder();
     public static final int O_CREAT = placeholder();
     public static final int O_EXCL = placeholder();
     public static final int O_NOCTTY = placeholder();
@@ -375,7 +375,7 @@
     public static final int O_RDONLY = placeholder();
     public static final int O_RDWR = placeholder();
     public static final int O_SYNC = placeholder();
-    /** @hide */ public static final int O_DSYNC = placeholder();
+    public static final int O_DSYNC = placeholder();
     public static final int O_TRUNC = placeholder();
     public static final int O_WRONLY = placeholder();
     public static final int POLLERR = placeholder();
diff --git a/luni/src/main/java/android/system/StructStat.java b/luni/src/main/java/android/system/StructStat.java
index ce3548f6..a1e8729 100644
--- a/luni/src/main/java/android/system/StructStat.java
+++ b/luni/src/main/java/android/system/StructStat.java
@@ -53,15 +53,24 @@
    */
   public final long st_size; /*off_t*/
 
-  /** Time of last access. */
+  /** Seconds part of time of last access. */
   public final long st_atime; /*time_t*/
 
-  /** Time of last data modification. */
+  /** StructTimespec with time of last access. */
+  public final StructTimespec st_atim;
+
+  /** Seconds part of time of last data modification. */
   public final long st_mtime; /*time_t*/
 
-  /** Time of last status change. */
+  /** StructTimespec with time of last modification. */
+  public final StructTimespec st_mtim;
+
+  /** Seconds part of time of last status change */
   public final long st_ctime; /*time_t*/
 
+  /** StructTimespec with time of last status change. */
+  public final StructTimespec st_ctim;
+
   /**
    * A file system-specific preferred I/O block size for this object.
    * For some file system types, this may vary from file to file.
@@ -77,6 +86,17 @@
   public StructStat(long st_dev, long st_ino, int st_mode, long st_nlink, int st_uid, int st_gid,
                     long st_rdev, long st_size, long st_atime, long st_mtime, long st_ctime,
                     long st_blksize, long st_blocks) {
+    this(st_dev, st_ino, st_mode, st_nlink, st_uid, st_gid,
+        st_rdev, st_size, new StructTimespec(st_atime, 0L), new StructTimespec(st_mtime, 0L),
+        new StructTimespec(st_ctime, 0L), st_blksize, st_blocks);
+  }
+
+  /**
+   * Constructs an instance with the given field values.
+   */
+  public StructStat(long st_dev, long st_ino, int st_mode, long st_nlink, int st_uid, int st_gid,
+                    long st_rdev, long st_size, StructTimespec st_atim, StructTimespec st_mtim,
+                    StructTimespec st_ctim, long st_blksize, long st_blocks) {
     this.st_dev = st_dev;
     this.st_ino = st_ino;
     this.st_mode = st_mode;
@@ -85,9 +105,12 @@
     this.st_gid = st_gid;
     this.st_rdev = st_rdev;
     this.st_size = st_size;
-    this.st_atime = st_atime;
-    this.st_mtime = st_mtime;
-    this.st_ctime = st_ctime;
+    this.st_atime = st_atim.tv_sec;
+    this.st_mtime = st_mtim.tv_sec;
+    this.st_ctime = st_ctim.tv_sec;
+    this.st_atim = st_atim;
+    this.st_mtim = st_mtim;
+    this.st_ctim = st_ctim;
     this.st_blksize = st_blksize;
     this.st_blocks = st_blocks;
   }
diff --git a/luni/src/main/java/android/system/StructTimespec.java b/luni/src/main/java/android/system/StructTimespec.java
new file mode 100644
index 0000000..b5e192e
--- /dev/null
+++ b/luni/src/main/java/android/system/StructTimespec.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.system;
+
+import libcore.util.Objects;;
+
+/**
+ * Corresponds to C's {@code struct timespec} from {@code <time.h>}.
+ */
+public final class StructTimespec implements Comparable<StructTimespec> {
+  /** Seconds part of time of last data modification. */
+  public final long tv_sec; /*time_t*/
+
+  /** Nanoseconds (values are [0, 999999999]). */
+  public final long tv_nsec;
+
+  public StructTimespec(long tv_sec, long tv_nsec) {
+      this.tv_sec = tv_sec;
+      this.tv_nsec = tv_nsec;
+      if (tv_nsec < 0 || tv_nsec > 999_999_999) {
+          throw new IllegalArgumentException(
+                  "tv_nsec value " + tv_nsec + " is not in [0, 999999999]");
+      }
+  }
+
+  @Override
+  public int compareTo(StructTimespec other) {
+      if (tv_sec > other.tv_sec) {
+          return 1;
+      }
+      if (tv_sec < other.tv_sec) {
+          return -1;
+      }
+      if (tv_nsec > other.tv_nsec) {
+          return 1;
+      }
+      if (tv_nsec < other.tv_nsec) {
+          return -1;
+      }
+      return 0;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      StructTimespec that = (StructTimespec) o;
+
+      if (tv_sec != that.tv_sec) return false;
+      return tv_nsec == that.tv_nsec;
+  }
+
+  @Override
+  public int hashCode() {
+      int result = (int) (tv_sec ^ (tv_sec >>> 32));
+      result = 31 * result + (int) (tv_nsec ^ (tv_nsec >>> 32));
+      return result;
+  }
+
+  @Override
+  public String toString() {
+      return Objects.toString(this);
+  }
+}
diff --git a/luni/src/main/java/libcore/util/TimeZoneFinder.java b/luni/src/main/java/libcore/util/TimeZoneFinder.java
index 3c68a37..37e3b4a 100644
--- a/luni/src/main/java/libcore/util/TimeZoneFinder.java
+++ b/luni/src/main/java/libcore/util/TimeZoneFinder.java
@@ -80,6 +80,7 @@
 
     // VisibleForTesting
     public static TimeZoneFinder createInstanceWithFallback(String... tzLookupFilePaths) {
+        IOException lastException = null;
         for (String tzLookupFilePath : tzLookupFilePaths) {
             try {
                 // We assume that any file in /data was validated before install, and the system
@@ -87,12 +88,18 @@
                 // validation cost here.
                 return createInstance(tzLookupFilePath);
             } catch (IOException e) {
-                System.logE("Unable to process file: " + tzLookupFilePath + " Trying next one.", e);
+                // There's expected to be two files, and it's normal for the first file not to
+                // exist so we don't log, but keep the lastException so we can log it if there
+                // are no valid files available.
+                if (lastException != null) {
+                    e.addSuppressed(lastException);
+                }
+                lastException = e;
             }
         }
 
         System.logE("No valid file found in set: " + Arrays.toString(tzLookupFilePaths)
-                + " Falling back to empty map.");
+                + " Printing exceptions and falling back to empty map.", lastException);
         return createInstanceForTests("<timezones><countryzones /></timezones>");
     }
 
diff --git a/luni/src/main/native/ExecStrings.cpp b/luni/src/main/native/ExecStrings.cpp
index 9a408fd..3c68511 100644
--- a/luni/src/main/native/ExecStrings.cpp
+++ b/luni/src/main/native/ExecStrings.cpp
@@ -22,7 +22,7 @@
 
 #include <log/log.h>
 
-#include "ScopedLocalRef.h"
+#include <nativehelper/ScopedLocalRef.h>
 
 ExecStrings::ExecStrings(JNIEnv* env, jobjectArray java_string_array)
     : env_(env), java_array_(java_string_array), array_(NULL) {
diff --git a/luni/src/main/native/IcuUtilities.cpp b/luni/src/main/native/IcuUtilities.cpp
index 6b29e67..43b2f27 100644
--- a/luni/src/main/native/IcuUtilities.cpp
+++ b/luni/src/main/native/IcuUtilities.cpp
@@ -17,13 +17,14 @@
 #define LOG_TAG "IcuUtilities"
 
 #include <android/log.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedUtfChars.h>
 
 #include "IcuUtilities.h"
 
-#include "JniConstants.h"
 #include "JniException.h"
-#include "ScopedLocalRef.h"
-#include "ScopedUtfChars.h"
 #include "unicode/strenum.h"
 #include "unicode/ustring.h"
 #include "unicode/uloc.h"
@@ -44,7 +45,7 @@
     if (maybeThrowIcuException(env, "StringEnumeration::snext", status)) {
       return NULL;
     }
-    ScopedLocalRef<jstring> javaString(env, env->NewString(string->getBuffer(), string->length()));
+    ScopedLocalRef<jstring> javaString(env, jniCreateString(env, string->getBuffer(), string->length()));
     env->SetObjectArrayElement(result, i, javaString.get());
   }
   return result;
diff --git a/luni/src/main/native/JniException.cpp b/luni/src/main/native/JniException.cpp
index 9744777..164281d 100644
--- a/luni/src/main/native/JniException.cpp
+++ b/luni/src/main/native/JniException.cpp
@@ -17,7 +17,7 @@
 #include <stdio.h>  // For BUFSIZ
 
 #include "JniException.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 void jniThrowExceptionWithErrno(JNIEnv* env, const char* exceptionClassName, int error) {
     char buf[BUFSIZ];
diff --git a/luni/src/main/native/NetFd.h b/luni/src/main/native/NetFd.h
index 0397e4d..ae4e5ab 100644
--- a/luni/src/main/native/NetFd.h
+++ b/luni/src/main/native/NetFd.h
@@ -17,7 +17,7 @@
 #ifndef NET_FD_H_included
 #define NET_FD_H_included
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 /**
  * Wraps access to the int inside a java.io.FileDescriptor, taking care of throwing exceptions.
diff --git a/luni/src/main/native/NetworkUtilities.cpp b/luni/src/main/native/NetworkUtilities.cpp
index bf438fa..b259814 100644
--- a/luni/src/main/native/NetworkUtilities.cpp
+++ b/luni/src/main/native/NetworkUtilities.cpp
@@ -17,9 +17,9 @@
 #define LOG_TAG "NetworkUtilities"
 
 #include "NetworkUtilities.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "ScopedLocalRef.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedLocalRef.h>
 
 #include <arpa/inet.h>
 #include <fcntl.h>
diff --git a/luni/src/main/native/Register.cpp b/luni/src/main/native/Register.cpp
index f642211..0c433da 100644
--- a/luni/src/main/native/Register.cpp
+++ b/luni/src/main/native/Register.cpp
@@ -20,8 +20,8 @@
 
 #include "log/log.h"
 
-#include "JniConstants.h"
-#include "ScopedLocalFrame.h"
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedLocalFrame.h>
 
 // DalvikVM calls this on startup, so we can statically register all our native methods.
 jint JNI_OnLoad(JavaVM* vm, void*) {
diff --git a/luni/src/main/native/ZipUtilities.cpp b/luni/src/main/native/ZipUtilities.cpp
index b7d2209..9fd32b5 100644
--- a/luni/src/main/native/ZipUtilities.cpp
+++ b/luni/src/main/native/ZipUtilities.cpp
@@ -17,7 +17,8 @@
 
 #include <memory>
 
-#include "JniConstants.h"
+#include <nativehelper/JniConstants.h>
+
 #include "JniException.h"
 #include "ZipUtilities.h"
 
diff --git a/luni/src/main/native/android_system_OsConstants.cpp b/luni/src/main/native/android_system_OsConstants.cpp
index a517475..826fa1e 100644
--- a/luni/src/main/native/android_system_OsConstants.cpp
+++ b/luni/src/main/native/android_system_OsConstants.cpp
@@ -16,8 +16,8 @@
 
 #define LOG_TAG "OsConstants"
 
-#include "JNIHelp.h"
-#include "JniConstants.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
 #include "Portability.h"
 
 #include <errno.h>
diff --git a/luni/src/main/native/cbigint.h b/luni/src/main/native/cbigint.h
index 2bf5b1b..9f7f715 100644
--- a/luni/src/main/native/cbigint.h
+++ b/luni/src/main/native/cbigint.h
@@ -18,7 +18,7 @@
 #if !defined(cbigint_h)
 #define cbigint_h
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #include <sys/types.h>
 #include <sys/param.h>
diff --git a/luni/src/main/native/java_lang_StringToReal.cpp b/luni/src/main/native/java_lang_StringToReal.cpp
index c321702..7f368b1 100644
--- a/luni/src/main/native/java_lang_StringToReal.cpp
+++ b/luni/src/main/native/java_lang_StringToReal.cpp
@@ -18,11 +18,11 @@
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "JniException.h"
-#include "ScopedUtfChars.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedUtfChars.h>
 #include "cbigint.h"
+#include "JniException.h"
 
 /* ************************* Defines ************************* */
 
diff --git a/luni/src/main/native/java_lang_invoke_MethodHandle.cpp b/luni/src/main/native/java_lang_invoke_MethodHandle.cpp
index 4596b42..4574f59 100644
--- a/luni/src/main/native/java_lang_invoke_MethodHandle.cpp
+++ b/luni/src/main/native/java_lang_invoke_MethodHandle.cpp
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#include "JniConstants.h"
-#include "JNIHelp.h"
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/JNIHelp.h>
 
 static void MethodHandle_invokeExact(JNIEnv* env, jobject, jobjectArray) {
     jniThrowException(env, "java/lang/UnsupportedOperationException",
diff --git a/luni/src/main/native/java_math_NativeBN.cpp b/luni/src/main/native/java_math_NativeBN.cpp
index 5c42be6..066f77e 100644
--- a/luni/src/main/native/java_math_NativeBN.cpp
+++ b/luni/src/main/native/java_math_NativeBN.cpp
@@ -16,12 +16,12 @@
 
 #define LOG_TAG "NativeBN"
 
-#include "JNIHelp.h"
-#include "JniConstants.h"
 #include "JniException.h"
-#include "ScopedPrimitiveArray.h"
-#include "ScopedUtfChars.h"
 #include "jni.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedPrimitiveArray.h>
+#include <nativehelper/ScopedUtfChars.h>
 #include <openssl/bn.h>
 #include <openssl/crypto.h>
 #include <openssl/err.h>
diff --git a/luni/src/main/native/java_util_regex_Matcher.cpp b/luni/src/main/native/java_util_regex_Matcher.cpp
index 2271ba8..11af4bd 100644
--- a/luni/src/main/native/java_util_regex_Matcher.cpp
+++ b/luni/src/main/native/java_util_regex_Matcher.cpp
@@ -20,14 +20,14 @@
 #include <stdlib.h>
 
 #include <android-base/logging.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedPrimitiveArray.h>
+#include <nativehelper/ScopedStringChars.h>
 
 #include "IcuUtilities.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
 #include "JniException.h"
 #include "ScopedJavaUnicodeString.h"
-#include "ScopedPrimitiveArray.h"
-#include "ScopedStringChars.h"
 #include "jni.h"
 #include "unicode/parseerr.h"
 #include "unicode/regex.h"
diff --git a/luni/src/main/native/java_util_regex_Pattern.cpp b/luni/src/main/native/java_util_regex_Pattern.cpp
index 4166da0..f4d23cb 100644
--- a/luni/src/main/native/java_util_regex_Pattern.cpp
+++ b/luni/src/main/native/java_util_regex_Pattern.cpp
@@ -18,8 +18,8 @@
 
 #include <stdlib.h>
 
-#include "JNIHelp.h"
-#include "JniConstants.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
 #include "ScopedJavaUnicodeString.h"
 #include "jni.h"
 #include "unicode/parseerr.h"
diff --git a/luni/src/main/native/libcore_icu_ICU.cpp b/luni/src/main/native/libcore_icu_ICU.cpp
index 0e9a2bc..50a5e9b 100644
--- a/luni/src/main/native/libcore_icu_ICU.cpp
+++ b/luni/src/main/native/libcore_icu_ICU.cpp
@@ -33,16 +33,16 @@
 
 #include <android-base/unique_fd.h>
 #include <log/log.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedUtfChars.h>
+#include <nativehelper/toStringArray.h>
 
 #include "IcuUtilities.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
 #include "JniException.h"
 #include "ScopedIcuLocale.h"
 #include "ScopedJavaUnicodeString.h"
-#include "ScopedLocalRef.h"
-#include "ScopedUtfChars.h"
-#include "toStringArray.h"
 #include "unicode/brkiter.h"
 #include "unicode/calendar.h"
 #include "unicode/datefmt.h"
@@ -172,8 +172,8 @@
     }
 
     int32_t charCount;
-    const jchar* chars = ures_getString(currencyId.get(), &charCount, &status);
-    return (charCount == 0) ? env->NewStringUTF("XXX") : env->NewString(chars, charCount);
+    const UChar* chars = ures_getString(currencyId.get(), &charCount, &status);
+    return (charCount == 0) ? env->NewStringUTF("XXX") : jniCreateString(env, chars, charCount);
 }
 
 static jstring getCurrencyName(JNIEnv* env, jstring javaLanguageTag, jstring javaCurrencyCode, UCurrNameStyle nameStyle) {
@@ -205,7 +205,7 @@
       charCount = icuCurrencyCode.length();
     }
   }
-  return (charCount == 0) ? NULL : env->NewString(chars, charCount);
+  return (charCount == 0) ? NULL : jniCreateString(env, chars, charCount);
 }
 
 static jstring ICU_getCurrencyDisplayName(JNIEnv* env, jclass, jstring javaLanguageTag, jstring javaCurrencyCode) {
@@ -228,7 +228,7 @@
 
   icu::UnicodeString str;
   icuTargetLocale.locale().getDisplayCountry(icuLocale.locale(), str);
-  return env->NewString(str.getBuffer(), str.length());
+  return jniCreateString(env, str.getBuffer(), str.length());
 }
 
 static jstring ICU_getDisplayLanguageNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
@@ -243,7 +243,7 @@
 
   icu::UnicodeString str;
   icuTargetLocale.locale().getDisplayLanguage(icuLocale.locale(), str);
-  return env->NewString(str.getBuffer(), str.length());
+  return jniCreateString(env, str.getBuffer(), str.length());
 }
 
 static jstring ICU_getDisplayScriptNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
@@ -258,7 +258,7 @@
 
   icu::UnicodeString str;
   icuTargetLocale.locale().getDisplayScript(icuLocale.locale(), str);
-  return env->NewString(str.getBuffer(), str.length());
+  return jniCreateString(env, str.getBuffer(), str.length());
 }
 
 static jstring ICU_getDisplayVariantNative(JNIEnv* env, jclass, jstring javaTargetLanguageTag, jstring javaLanguageTag) {
@@ -273,7 +273,7 @@
 
   icu::UnicodeString str;
   icuTargetLocale.locale().getDisplayVariant(icuLocale.locale(), str);
-  return env->NewString(str.getBuffer(), str.length());
+  return jniCreateString(env, str.getBuffer(), str.length());
 }
 
 static jstring ICU_getISO3Country(JNIEnv* env, jclass, jstring javaLanguageTag) {
@@ -346,7 +346,7 @@
 static void setStringArrayField(JNIEnv* env, jobject obj, const char* fieldName, const icu::UnicodeString* valueArray, int32_t size) {
     ScopedLocalRef<jobjectArray> result(env, env->NewObjectArray(size, JniConstants::stringClass, NULL));
     for (int32_t i = 0; i < size ; i++) {
-        ScopedLocalRef<jstring> s(env, env->NewString(valueArray[i].getBuffer(),valueArray[i].length()));
+        ScopedLocalRef<jstring> s(env, jniCreateString(env, valueArray[i].getBuffer(),valueArray[i].length()));
         if (env->ExceptionCheck()) {
             return;
         }
@@ -378,7 +378,7 @@
   }
   ures_close(currentBundle);
   if (U_SUCCESS(status)) {
-    setStringField(env, obj, fieldName, env->NewString(chars, charCount));
+    setStringField(env, obj, fieldName, jniCreateString(env, chars, charCount));
   } else {
     ALOGE("Error setting String field %s from ICU resource (index %d): %s", fieldName, index, u_errorName(status));
   }
@@ -394,7 +394,7 @@
 
 static void setStringField(JNIEnv* env, jobject obj, const char* fieldName, const icu::UnicodeString& value) {
     const UChar* chars = value.getBuffer();
-    setStringField(env, obj, fieldName, env->NewString(chars, value.length()));
+    setStringField(env, obj, fieldName, jniCreateString(env, chars, value.length()));
 }
 
 static void setNumberPatterns(JNIEnv* env, jobject obj, icu::Locale& locale) {
@@ -708,7 +708,7 @@
   icu::UnicodeString& s(scopedString.unicodeString());
   icu::UnicodeString original(s);
   s.toLower(icuLocale.locale());
-  return s == original ? javaString : env->NewString(s.getBuffer(), s.length());
+  return s == original ? javaString : jniCreateString(env, s.getBuffer(), s.length());
 }
 
 static jstring ICU_toUpperCase(JNIEnv* env, jclass, jstring javaString, jstring javaLanguageTag) {
@@ -723,7 +723,7 @@
   icu::UnicodeString& s(scopedString.unicodeString());
   icu::UnicodeString original(s);
   s.toUpper(icuLocale.locale());
-  return s == original ? javaString : env->NewString(s.getBuffer(), s.length());
+  return s == original ? javaString : jniCreateString(env, s.getBuffer(), s.length());
 }
 
 static jstring versionString(JNIEnv* env, const UVersionInfo& version) {
@@ -787,7 +787,7 @@
     return NULL;
   }
 
-  return env->NewString(result.getBuffer(), result.length());
+  return jniCreateString(env, result.getBuffer(), result.length());
 }
 
 static void ICU_setDefaultLocale(JNIEnv* env, jclass, jstring javaLanguageTag) {
diff --git a/luni/src/main/native/libcore_icu_NativeConverter.cpp b/luni/src/main/native/libcore_icu_NativeConverter.cpp
index 1b43a80..bfbb463 100644
--- a/luni/src/main/native/libcore_icu_NativeConverter.cpp
+++ b/luni/src/main/native/libcore_icu_NativeConverter.cpp
@@ -22,16 +22,16 @@
 #include <vector>
 
 #include <android/log.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedPrimitiveArray.h>
+#include <nativehelper/ScopedStringChars.h>
+#include <nativehelper/ScopedUtfChars.h>
+#include <nativehelper/toStringArray.h>
 
 #include "IcuUtilities.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
 #include "JniException.h"
-#include "ScopedLocalRef.h"
-#include "ScopedPrimitiveArray.h"
-#include "ScopedStringChars.h"
-#include "ScopedUtfChars.h"
-#include "toStringArray.h"
 #include "unicode/ucnv.h"
 #include "unicode/ucnv_cb.h"
 #include "unicode/uniset.h"
@@ -157,6 +157,19 @@
   return env->NewStringUTF(&result[0]);
 }
 
+// Returns a canonical ICU converter name which may have a version number appended to it, based on
+// the normal canonical name. This is used to determine the actual native converter to use (the
+// normal unversioned name is used to determine the aliases and the Java name).
+static char const * getVersionedIcuCanonicalName(char const * icuCanonicalName) {
+  if (strcmp(icuCanonicalName, "UTF-16") == 0) {
+    // The ICU UTF-16 converter encodes strings as platform-endian bytes with a BOM. The
+    // UTF-16,version=2 one encodes as big-endian with a BOM, as what the Charset javadoc requires.
+    return "UTF-16,version=2";
+  } else {
+    return icuCanonicalName;
+  }
+}
+
 static jlong NativeConverter_openConverter(JNIEnv* env, jclass, jstring converterName) {
     ScopedUtfChars converterNameChars(env, converterName);
     if (converterNameChars.c_str() == NULL) {
@@ -224,11 +237,11 @@
     jint* sourceOffset = &myData[0];
     jint* targetOffset = &myData[1];
     const jchar* mySource = uSource.get() + *sourceOffset;
-    const UChar* mySourceLimit= uSource.get() + sourceEnd;
+    const UChar* mySourceLimit= reinterpret_cast<const UChar*>(uSource.get()) + sourceEnd;
     char* cTarget = reinterpret_cast<char*>(uTarget.get() + *targetOffset);
     const char* cTargetLimit = reinterpret_cast<const char*>(uTarget.get() + targetEnd);
     UErrorCode errorCode = U_ZERO_ERROR;
-    ucnv_fromUnicode(cnv , &cTarget, cTargetLimit, &mySource, mySourceLimit, NULL, (UBool) flush, &errorCode);
+    ucnv_fromUnicode(cnv, &cTarget, cTargetLimit, reinterpret_cast<const UChar**>(&mySource), mySourceLimit, NULL, (UBool) flush, &errorCode);
     *sourceOffset = (mySource - uSource.get()) - *sourceOffset;
     *targetOffset = (reinterpret_cast<jbyte*>(cTarget) - uTarget.get());
 
@@ -281,12 +294,12 @@
     jint* targetOffset = &myData[1];
     const char* mySource = reinterpret_cast<const char*>(uSource.get() + *sourceOffset);
     const char* mySourceLimit = reinterpret_cast<const char*>(uSource.get() + sourceEnd);
-    UChar* cTarget = uTarget.get() + *targetOffset;
-    const UChar* cTargetLimit = uTarget.get() + targetEnd;
+    UChar* cTarget = reinterpret_cast<UChar*>(uTarget.get()) + *targetOffset;
+    const UChar* cTargetLimit = reinterpret_cast<UChar*>(uTarget.get()) + targetEnd;
     UErrorCode errorCode = U_ZERO_ERROR;
     ucnv_toUnicode(cnv, &cTarget, cTargetLimit, &mySource, mySourceLimit, NULL, flush, &errorCode);
     *sourceOffset = mySource - reinterpret_cast<const char*>(uSource.get()) - *sourceOffset;
-    *targetOffset = cTarget - uTarget.get() - *targetOffset;
+    *targetOffset = cTarget - reinterpret_cast<UChar*>(uTarget.get()) - *targetOffset;
 
     // If there was an error, count the problematic bytes.
     if (errorCode == U_ILLEGAL_CHAR_FOUND || errorCode == U_INVALID_CHAR_FOUND ||
@@ -510,7 +523,7 @@
         maybeThrowIcuException(env, "replacement", U_ILLEGAL_ARGUMENT_ERROR);
         return;
     }
-    u_strncpy(callbackContext->replacementChars, replacement.get(), replacement.size());
+    u_strncpy(callbackContext->replacementChars, reinterpret_cast<const UChar*>(replacement.get()), replacement.size());
     callbackContext->replacementCharCount = replacement.size();
 
     UErrorCode errorCode = U_ZERO_ERROR;
@@ -618,13 +631,14 @@
         return NULL;
     }
 
-    jstring icuCanonicalNameStr = env->NewStringUTF(icuCanonicalName);
+    char const * versionedIcuCanonicalName = getVersionedIcuCanonicalName(icuCanonicalName);
+    jstring versionedIcuCanonicalNameStr = env->NewStringUTF(versionedIcuCanonicalName);
     if (env->ExceptionCheck()) {
         return NULL;
     }
 
     return env->NewObject(JniConstants::charsetICUClass, charsetConstructor,
-            javaCanonicalName, icuCanonicalNameStr, javaAliases);
+            javaCanonicalName, versionedIcuCanonicalNameStr, javaAliases);
 }
 
 static void FreeNativeConverter(void *converter) {
diff --git a/luni/src/main/native/libcore_icu_TimeZoneNames.cpp b/luni/src/main/native/libcore_icu_TimeZoneNames.cpp
index c4f25e0..29c07e2 100644
--- a/luni/src/main/native/libcore_icu_TimeZoneNames.cpp
+++ b/luni/src/main/native/libcore_icu_TimeZoneNames.cpp
@@ -18,14 +18,15 @@
 
 #include <memory>
 
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedUtfChars.h>
+
 #include "IcuUtilities.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
 #include "JniException.h"
 #include "ScopedIcuLocale.h"
 #include "ScopedJavaUnicodeString.h"
-#include "ScopedLocalRef.h"
-#include "ScopedUtfChars.h"
 #include "unicode/calendar.h"
 #include "unicode/timezone.h"
 #include "unicode/tznames.h"
@@ -49,7 +50,7 @@
   // Don't use "GMT" string, for backwards compatibility.
   static const icu::UnicodeString kGmt("GMT", 3, US_INV);
   if (!s.isBogus() && !s.startsWith(kGmt)) {
-    ScopedLocalRef<jstring> javaString(env, env->NewString(s.getBuffer(), s.length()));
+    ScopedLocalRef<jstring> javaString(env, jniCreateString(env, s.getBuffer(), s.length()));
     if (javaString.get() == NULL) {
       return false;
     }
@@ -134,7 +135,7 @@
   icu::UnicodeString s;
   const UDate now(icu::Calendar::getNow());
   names->getDisplayName(tz.unicodeString(), UTZNM_EXEMPLAR_LOCATION, now, s);
-  return env->NewString(s.getBuffer(), s.length());
+  return jniCreateString(env, s.getBuffer(), s.length());
 }
 
 static JNINativeMethod gMethods[] = {
diff --git a/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp b/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
index a27e7b8..bf2d3a8 100644
--- a/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
+++ b/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
@@ -16,9 +16,10 @@
 
 #define LOG_TAG "AsynchronousCloseMonitor"
 
-#include "AsynchronousCloseMonitor.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
+#include <nativehelper/AsynchronousCloseMonitor.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+
 #include "jni.h"
 
 static void AsynchronousCloseMonitor_signalBlockedThreads(JNIEnv* env, jclass, jobject javaFd) {
diff --git a/luni/src/main/native/libcore_io_Linux.cpp b/luni/src/main/native/libcore_io_Linux.cpp
index 1e2f3a5..989024f 100644
--- a/luni/src/main/native/libcore_io_Linux.cpp
+++ b/luni/src/main/native/libcore_io_Linux.cpp
@@ -51,19 +51,19 @@
 #include <android-base/file.h>
 #include <android-base/strings.h>
 #include <log/log.h>
+#include <nativehelper/AsynchronousCloseMonitor.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedBytes.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedPrimitiveArray.h>
+#include <nativehelper/ScopedUtfChars.h>
+#include <nativehelper/toStringArray.h>
 
-#include "AsynchronousCloseMonitor.h"
 #include "ExecStrings.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
 #include "JniException.h"
 #include "NetworkUtilities.h"
 #include "Portability.h"
-#include "ScopedBytes.h"
-#include "ScopedLocalRef.h"
-#include "ScopedPrimitiveArray.h"
-#include "ScopedUtfChars.h"
-#include "toStringArray.h"
 
 #ifndef __unused
 #define __unused __attribute__((__unused__))
@@ -423,16 +423,23 @@
             pw_name, static_cast<jint>(pw.pw_uid), static_cast<jint>(pw.pw_gid), pw_dir, pw_shell);
 }
 
+static jobject makeStructTimespec(JNIEnv* env, const struct timespec& ts) {
+    static jmethodID ctor = env->GetMethodID(JniConstants::structTimespecClass, "<init>",
+            "(JJ)V");
+    return env->NewObject(JniConstants::structTimespecClass, ctor,
+            static_cast<jlong>(ts.tv_sec), static_cast<jlong>(ts.tv_nsec));
+}
+
 static jobject makeStructStat(JNIEnv* env, const struct stat64& sb) {
     static jmethodID ctor = env->GetMethodID(JniConstants::structStatClass, "<init>",
-            "(JJIJIIJJJJJJJ)V");
+            "(JJIJIIJJLandroid/system/StructTimespec;Landroid/system/StructTimespec;Landroid/system/StructTimespec;JJ)V");
     return env->NewObject(JniConstants::structStatClass, ctor,
             static_cast<jlong>(sb.st_dev), static_cast<jlong>(sb.st_ino),
             static_cast<jint>(sb.st_mode), static_cast<jlong>(sb.st_nlink),
             static_cast<jint>(sb.st_uid), static_cast<jint>(sb.st_gid),
             static_cast<jlong>(sb.st_rdev), static_cast<jlong>(sb.st_size),
-            static_cast<jlong>(sb.st_atime), static_cast<jlong>(sb.st_mtime),
-            static_cast<jlong>(sb.st_ctime), static_cast<jlong>(sb.st_blksize),
+            makeStructTimespec(env, sb.st_atim), makeStructTimespec(env, sb.st_mtim),
+            makeStructTimespec(env, sb.st_ctim), static_cast<jlong>(sb.st_blksize),
             static_cast<jlong>(sb.st_blocks));
 }
 
diff --git a/luni/src/main/native/libcore_io_Memory.cpp b/luni/src/main/native/libcore_io_Memory.cpp
index 1acb8f4..5f50751 100644
--- a/luni/src/main/native/libcore_io_Memory.cpp
+++ b/luni/src/main/native/libcore_io_Memory.cpp
@@ -16,18 +16,19 @@
 
 #define LOG_TAG "Memory"
 
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "nativehelper/jni_macros.h"
-#include "Portability.h"
-#include "ScopedBytes.h"
-#include "ScopedPrimitiveArray.h"
-
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
 
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedBytes.h>
+#include <nativehelper/ScopedPrimitiveArray.h>
+
+#include "nativehelper/jni_macros.h"
+#include "Portability.h"
+
 // Use packed structures for access to unaligned data on targets with alignment restrictions.
 // The compiler will generate appropriate code to access these structures without
 // generating alignment exceptions.
diff --git a/luni/src/main/native/libcore_util_NativeAllocationRegistry.cpp b/luni/src/main/native/libcore_util_NativeAllocationRegistry.cpp
index 5c0f8df..59bed74 100644
--- a/luni/src/main/native/libcore_util_NativeAllocationRegistry.cpp
+++ b/luni/src/main/native/libcore_util_NativeAllocationRegistry.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "JniConstants.h"
+#include <nativehelper/JniConstants.h>
 
 typedef void (*FreeFunction)(void*);
 
diff --git a/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
index aaf3ca1..22496bf 100644
--- a/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
+++ b/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
@@ -23,15 +23,15 @@
 
 #include <android/log.h>
 #include <android-base/stringprintf.h>
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedLocalRef.h>
+#include <nativehelper/ScopedPrimitiveArray.h>
+#include <nativehelper/ScopedStringChars.h>
+#include <nativehelper/ScopedUtfChars.h>
 
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "JniException.h"
-#include "ScopedLocalRef.h"
-#include "ScopedPrimitiveArray.h"
-#include "ScopedStringChars.h"
-#include "ScopedUtfChars.h"
 #include "jni.h"
+#include "JniException.h"
 #include "unicode/unistr.h"
 
 
diff --git a/luni/src/main/native/sun_misc_Unsafe.cpp b/luni/src/main/native/sun_misc_Unsafe.cpp
index d0a23be..67925b0 100644
--- a/luni/src/main/native/sun_misc_Unsafe.cpp
+++ b/luni/src/main/native/sun_misc_Unsafe.cpp
@@ -16,8 +16,8 @@
 
 #define LOG_TAG "Unsafe"
 
-#include "JNIHelp.h"
-#include "JniConstants.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
 
 static jobject Unsafe_allocateInstance(JNIEnv* env, jclass, jclass c) {
   return env->AllocObject(c);
diff --git a/luni/src/main/native/valueOf.cpp b/luni/src/main/native/valueOf.cpp
index be99cff..fdd2502 100644
--- a/luni/src/main/native/valueOf.cpp
+++ b/luni/src/main/native/valueOf.cpp
@@ -17,8 +17,8 @@
 #define LOG_TAG "valueOf"
 
 #include "valueOf.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
 
 template <typename T>
 static jobject valueOf(JNIEnv* env, jclass c, const char* signature, const T& value) {
diff --git a/luni/src/main/native/valueOf.h b/luni/src/main/native/valueOf.h
index 592977d..5c93b7c 100644
--- a/luni/src/main/native/valueOf.h
+++ b/luni/src/main/native/valueOf.h
@@ -17,7 +17,7 @@
 #ifndef VALUE_OF_H_included
 #define VALUE_OF_H_included
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 jobject booleanValueOf(JNIEnv* env, jboolean b);
 jobject doubleValueOf(JNIEnv* env, jdouble d);
diff --git a/luni/src/test/java/libcore/android/system/StructTimespecTest.java b/luni/src/test/java/libcore/android/system/StructTimespecTest.java
new file mode 100644
index 0000000..1cc4ade
--- /dev/null
+++ b/luni/src/test/java/libcore/android/system/StructTimespecTest.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.android.system;
+
+import android.system.StructTimespec;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test for {@link StructTimespec}
+ */
+public class StructTimespecTest extends TestCase {
+    public void testConstructor() {
+        StructTimespec val = new StructTimespec(Long.MIN_VALUE, 0);
+        assertEquals(Long.MIN_VALUE, val.tv_sec);
+        assertEquals(0, val.tv_nsec);
+
+        val = new StructTimespec(-23, 23);
+        assertEquals(-23, val.tv_sec);
+        assertEquals(23, val.tv_nsec);
+
+        val = new StructTimespec(0, 42);
+        assertEquals(0, val.tv_sec);
+        assertEquals(42, val.tv_nsec);
+
+        val = new StructTimespec(23, 91);
+        assertEquals(23, val.tv_sec);
+        assertEquals(91, val.tv_nsec);
+
+        val = new StructTimespec(Long.MAX_VALUE, 999_999_999);
+        assertEquals(Long.MAX_VALUE, val.tv_sec);
+        assertEquals(999_999_999, val.tv_nsec);
+    }
+
+    public void testConstructorInvalidNsec() {
+        try {
+            new StructTimespec(0, 1_000_000_000);
+            fail();
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            new StructTimespec(0, -1);
+            fail();
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    public void testCompare() {
+        StructTimespec[] specs = new StructTimespec[]{new StructTimespec(Long.MIN_VALUE, 0),
+                new StructTimespec(-24, 91),
+                new StructTimespec(-23, 23),
+                new StructTimespec(0, 41),
+                new StructTimespec(0, 42),
+                new StructTimespec(22, 91),
+                new StructTimespec(23, 23),
+                new StructTimespec(24, 91),
+                new StructTimespec(Long.MAX_VALUE, 999_999_999)};
+
+        for (int a = 0; a < specs.length; a++) {
+            for (int b = 0; b < specs.length; b++) {
+                if (a < b) {
+                    assertTrue(a + "<" + b, specs[a].compareTo(specs[b]) < 0);
+                } else if (a == b) {
+                    assertTrue(a + "==" + b, specs[a].compareTo(specs[b]) == 0);
+                } else {
+                    assertTrue(a + ">" + b,  specs[a].compareTo(specs[b]) > 0);
+                }
+            }
+        }
+    }
+
+    public void testEquals() {
+        StructTimespec allZero1 = new StructTimespec(0, 0);
+        StructTimespec allZero2 = new StructTimespec(0, 0);
+
+        StructTimespec val1 = new StructTimespec(23, 42);
+        StructTimespec val2 = new StructTimespec(23, 42);
+
+        StructTimespec secZero1 = new StructTimespec(0, 42);
+        StructTimespec secZero2 = new StructTimespec(0, 42);
+
+        StructTimespec nsecZero1 = new StructTimespec(23, 0);
+        StructTimespec nsecZero2 = new StructTimespec(23, 0);
+
+        assertTrue(allZero1.equals(allZero2));
+        assertTrue(val1.equals(val2));
+        assertTrue(secZero1.equals(secZero2));
+        assertTrue(nsecZero1.equals(nsecZero2));
+
+        // Compare equals in both directions
+        assertFalse(allZero1.equals(val1));
+        assertFalse(allZero1.equals(secZero1));
+        assertFalse(allZero1.equals(nsecZero1));
+
+        assertFalse(val1.equals(secZero1));
+        assertFalse(val1.equals(nsecZero1));
+        assertFalse(val1.equals(allZero1));
+
+        assertFalse(secZero1.equals(nsecZero1));
+        assertFalse(secZero1.equals(allZero1));
+        assertFalse(secZero1.equals(val1));
+
+        assertFalse(nsecZero1.equals(allZero1));
+        assertFalse(nsecZero1.equals(val1));
+        assertFalse(nsecZero1.equals(secZero1));
+    }
+
+    public void testHashcode() {
+        StructTimespec allZero1 = new StructTimespec(0, 0);
+        StructTimespec allZero2 = new StructTimespec(0, 0);
+
+        StructTimespec val1 = new StructTimespec(23, 42);
+        StructTimespec val2 = new StructTimespec(23, 42);
+
+        StructTimespec secZero1 = new StructTimespec(0, 42);
+        StructTimespec secZero2 = new StructTimespec(0, 42);
+
+        StructTimespec nsecZero1 = new StructTimespec(23, 0);
+        StructTimespec nsecZero2 = new StructTimespec(23, 0);
+
+        // Equal objects should have same hash code
+        assertEquals(allZero1.hashCode(), allZero2.hashCode());
+        assertEquals(val1.hashCode(), val2.hashCode());
+        assertEquals(secZero1.hashCode(), secZero2.hashCode());
+        assertEquals(nsecZero1.hashCode(), nsecZero2.hashCode());
+    }
+}
diff --git a/luni/src/test/java/libcore/io/OsTest.java b/luni/src/test/java/libcore/io/OsTest.java
index 07ce7d2..0f47d87 100644
--- a/luni/src/test/java/libcore/io/OsTest.java
+++ b/luni/src/test/java/libcore/io/OsTest.java
@@ -20,6 +20,7 @@
 import android.system.NetlinkSocketAddress;
 import android.system.OsConstants;
 import android.system.PacketSocketAddress;
+import android.system.StructStat;
 import android.system.StructTimeval;
 import android.system.StructUcred;
 import android.system.UnixSocketAddress;
@@ -783,4 +784,23 @@
       assertEquals(srcSock.getLocalPort(), address.getPort());
     }
   }
+
+  public void test_fstat_times() throws Exception {
+    File file = File.createTempFile("OsTest", "fstattest");
+    FileOutputStream fos = new FileOutputStream(file);
+    StructStat structStat1 = Libcore.os.fstat(fos.getFD());
+    assertEquals(structStat1.st_mtim.tv_sec, structStat1.st_mtime);
+    assertEquals(structStat1.st_ctim.tv_sec, structStat1.st_ctime);
+    assertEquals(structStat1.st_atim.tv_sec, structStat1.st_atime);
+    Thread.sleep(100);
+    fos.write(new byte[]{1,2,3});
+    fos.flush();
+    StructStat structStat2 = Libcore.os.fstat(fos.getFD());
+    fos.close();
+
+    assertEquals(-1, structStat1.st_mtim.compareTo(structStat2.st_mtim));
+    assertEquals(-1, structStat1.st_ctim.compareTo(structStat2.st_ctim));
+    assertEquals(0, structStat1.st_atim.compareTo(structStat2.st_atim));
+  }
+
 }
diff --git a/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java b/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
index 102c263..a80d741 100644
--- a/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
+++ b/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
@@ -11,6 +11,7 @@
 import java.util.Locale;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -114,7 +115,7 @@
             // Let server and client keep connecting for some time, then close the socket.
             for (int i = 0; i < maxSleepsPerIteration; i++) {
               Thread.sleep(sleepMsec);
-              if (serverRunnable.numSuccessfulConnections > 0) {
+              if (serverRunnable.numSuccessfulConnections.get() > 0) {
                 break;
               }
             }
@@ -139,7 +140,7 @@
             // reducing the iteration time or number of iterations.
             assertTrue(String.format(Locale.US, "%s: No connections in %d msec.",
                     iterationName, maxSleepsPerIteration * sleepMsec),
-                    serverRunnable.numSuccessfulConnections > 0);
+                    serverRunnable.numSuccessfulConnections.get() > 0);
 
             assertTrue(serverRunnable.isShutdown());
             // Sanity check to ensure the threads don't live into the next iteration. This should
@@ -194,7 +195,7 @@
      */
     static class ServerRunnable implements Runnable {
         private final ServerSocket serverSocket;
-        volatile int numSuccessfulConnections;
+        final AtomicInteger numSuccessfulConnections = new AtomicInteger();
         private final CountDownLatch startLatch = new CountDownLatch(1);
         private final CountDownLatch shutdownLatch = new CountDownLatch(1);
 
@@ -205,14 +206,12 @@
         @Override
         public void run() {
             startLatch.countDown();
-            int numSuccessfulConnections = 0;
             while (true) {
                 try {
                     Socket socket = serverSocket.accept();
-                    numSuccessfulConnections++;
+                    numSuccessfulConnections.incrementAndGet();
                     socket.close();
                 } catch (SocketException e) {
-                    this.numSuccessfulConnections = numSuccessfulConnections;
                     shutdownLatch.countDown();
                     return;
                 } catch (IOException e) {
diff --git a/luni/src/test/java/libcore/java/nio/channels/DatagramChannelMulticastTest.java b/luni/src/test/java/libcore/java/nio/channels/DatagramChannelMulticastTest.java
index 7d81af6..8976447 100644
--- a/luni/src/test/java/libcore/java/nio/channels/DatagramChannelMulticastTest.java
+++ b/luni/src/test/java/libcore/java/nio/channels/DatagramChannelMulticastTest.java
@@ -441,6 +441,7 @@
 
         DatagramChannel dc = createReceiverChannel();
         dc.setOption(StandardSocketOptions.IP_MULTICAST_LOOP, true /* enable loop */);
+        dc.setOption(StandardSocketOptions.IP_MULTICAST_IF, networkInterface);
         configureChannelForReceiving(dc);
         dc.join(group, networkInterface);
 
diff --git a/luni/src/test/java/libcore/java/nio/charset/OldCharset_MultiByte_UTF_16.java b/luni/src/test/java/libcore/java/nio/charset/OldCharset_MultiByte_UTF_16.java
index 29c42a3..8b047c8 100644
--- a/luni/src/test/java/libcore/java/nio/charset/OldCharset_MultiByte_UTF_16.java
+++ b/luni/src/test/java/libcore/java/nio/charset/OldCharset_MultiByte_UTF_16.java
@@ -15,10 +15,6 @@
  */
 package libcore.java.nio.charset;
 
-/** @hide
- * SEE correspondig_Android test class:
- */
-
 public class OldCharset_MultiByte_UTF_16 extends OldCharset_AbstractTest {
 
     @Override
diff --git a/luni/src/test/java/libcore/java/nio/charset/OldCharset_MultiByte_UTF_16_Android.java b/luni/src/test/java/libcore/java/nio/charset/OldCharset_MultiByte_UTF_16_Android.java
deleted file mode 100644
index b9c7c03..0000000
--- a/luni/src/test/java/libcore/java/nio/charset/OldCharset_MultiByte_UTF_16_Android.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package libcore.java.nio.charset;
-
-/** Note: ICU behaves differently from the RI */
-
-public class OldCharset_MultiByte_UTF_16_Android extends OldCharset_AbstractTest {
-
-    @Override
-    protected void setUp() throws Exception {
-        charsetName = "UTF-16";
-
-        testChars = theseChars(new int[]{
-32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
-48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
-64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
-80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
-96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
-112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
-128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
-144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
-160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
-176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
-192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
-208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
-224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
-240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
-256, 296, 336, 376, 416, 456, 496, 536, 576, 616, 656, 696, 736, 776, 816, 856,
-896, 936, 976, 1016, 1056, 1096, 1136, 1176, 1216, 1256, 1296, 1336, 1376, 1416, 1456, 1496,
-1536, 1576, 1616, 1656, 1696, 1736, 1776, 1816, 1856, 1896, 1936, 1976, 2016, 2056, 2096, 2136,
-2176, 2216, 2256, 2296, 2336, 2376, 2416, 2456, 2496, 2536, 2576, 2616, 2656, 2696, 2736, 2776,
-2816, 2856, 2896, 2936, 2976, 3016, 3056, 3096, 3136, 3176, 3216, 3256, 3296, 3336, 3376, 3416,
-3456, 3496, 3536, 3576, 3616, 3656, 3696, 3736, 3776, 3816, 3856, 3896, 3936, 3976, 4016, 4056,
-4096, 4136, 4176, 4216, 4256, 4296, 4336, 4376, 4416, 4456, 4496, 4536, 4576, 4616, 4656, 4696,
-4736, 4776, 4816, 4856, 4896, 4936, 4976, 5016, 5056, 5096, 5136, 5176, 5216, 5256, 5296, 5336,
-5376, 5416, 5456, 5496, 5536, 5576, 5616, 5656, 5696, 5736, 5776, 5816, 5856, 5896, 5936, 5976,
-6016, 6056, 6096, 6136, 6176, 6216, 6256, 6296, 6336, 6376, 6416, 6456, 6496, 6536, 6576, 6616,
-6656, 6696, 6736, 6776, 6816, 6856, 6896, 6936, 6976, 7016, 7056, 7096, 7136, 7176, 7216, 7256,
-7296, 7336, 7376, 7416, 7456, 7496, 7536, 7576, 7616, 7656, 7696, 7736, 7776, 7816, 7856, 7896,
-7936, 7976, 8016, 8056, 8096, 8136, 8176, 8216, 8256, 8296, 8336, 8376, 8416, 8456, 8496, 8536,
-8576, 8616, 8656, 8696, 8736, 8776, 8816, 8856, 8896, 8936, 8976, 9016, 9056, 9096, 9136, 9176,
-9216, 9256, 9296, 9336, 9376, 9416, 9456, 9496, 9536, 9576, 9616, 9656, 9696, 9736, 9776, 9816,
-9856, 9896, 9936, 9976, 10016, 10056, 10096, 10136, 10176, 10216, 10256, 10296, 10336, 10376, 10416, 10456,
-10496, 10536, 10576, 10616, 10656, 10696, 10736, 10776, 10816, 10856, 10896, 10936, 10976, 11016, 11056, 11096,
-11136, 11176, 11216, 11256, 11296, 11336, 11376, 11416, 11456, 11496, 11536, 11576, 11616, 11656, 11696, 11736,
-11776, 11816, 11856, 11896, 11936, 11976, 12016, 12056, 12096, 12136, 12176, 12216, 12256, 12296, 12336, 12376,
-12416, 12456, 12496, 12536, 12576, 12616, 12656, 12696, 12736, 12776, 12816, 12856, 12896, 12936, 12976, 13016,
-13056, 13096, 13136, 13176, 13216, 13256, 13296, 13336, 13376, 13416, 13456, 13496, 13536, 13576, 13616, 13656,
-13696, 13736, 13776, 13816, 13856, 13896, 13936, 13976, 14016, 14056, 14096, 14136, 14176, 14216, 14256, 14296,
-14336, 14376, 14416, 14456, 14496, 14536, 14576, 14616, 14656, 14696, 14736, 14776, 14816, 14856, 14896, 14936,
-14976, 15016, 15056, 15096, 15136, 15176, 15216, 15256, 15296, 15336, 15376, 15416, 15456, 15496, 15536, 15576,
-15616, 15656, 15696, 15736, 15776, 15816, 15856, 15896, 15936, 15976, 16016, 16056, 16096, 16136, 16176, 16216,
-16256, 16296, 16336, 16376, 16416, 16456, 16496, 16536, 16576, 16616, 16656, 16696, 16736, 16776, 16816, 16856,
-16896, 16936, 16976, 17016, 17056, 17096, 17136, 17176, 17216, 17256, 17296, 17336, 17376, 17416, 17456, 17496,
-17536, 17576, 17616, 17656, 17696, 17736, 17776, 17816, 17856, 17896, 17936, 17976, 18016, 18056, 18096, 18136,
-18176, 18216, 18256, 18296, 18336, 18376, 18416, 18456, 18496, 18536, 18576, 18616, 18656, 18696, 18736, 18776,
-18816, 18856, 18896, 18936, 18976, 19016, 19056, 19096, 19136, 19176, 19216, 19256, 19296, 19336, 19376, 19416,
-19456, 19496, 19536, 19576, 19616, 19656, 19696, 19736, 19776, 19816, 19856, 19896, 19936, 19976, 20016, 20056,
-20096, 20136, 20176, 20216, 20256, 20296, 20336, 20376, 20416, 20456, 20496, 20536, 20576, 20616, 20656, 20696,
-20736, 20776, 20816, 20856, 20896, 20936, 20976, 21016, 21056, 21096, 21136, 21176, 21216, 21256, 21296, 21336,
-21376, 21416, 21456, 21496, 21536, 21576, 21616, 21656, 21696, 21736, 21776, 21816, 21856, 21896, 21936, 21976,
-22016, 22056, 22096, 22136, 22176, 22216, 22256, 22296, 22336, 22376, 22416, 22456, 22496, 22536, 22576, 22616,
-22656, 22696, 22736, 22776, 22816, 22856, 22896, 22936, 22976, 23016, 23056, 23096, 23136, 23176, 23216, 23256,
-23296, 23336, 23376, 23416, 23456, 23496, 23536, 23576, 23616, 23656, 23696, 23736, 23776, 23816, 23856, 23896,
-23936, 23976, 24016, 24056, 24096, 24136, 24176, 24216, 24256, 24296, 24336, 24376, 24416, 24456, 24496, 24536,
-24576, 24616, 24656, 24696, 24736, 24776, 24816, 24856, 24896, 24936, 24976, 25016, 25056, 25096, 25136, 25176,
-25216, 25256, 25296, 25336, 25376, 25416, 25456, 25496, 25536, 25576, 25616, 25656, 25696, 25736, 25776, 25816,
-25856, 25896, 25936, 25976, 26016, 26056, 26096, 26136, 26176, 26216, 26256, 26296, 26336, 26376, 26416, 26456,
-26496, 26536, 26576, 26616, 26656, 26696, 26736, 26776, 26816, 26856, 26896, 26936, 26976, 27016, 27056, 27096,
-27136, 27176, 27216, 27256, 27296, 27336, 27376, 27416, 27456, 27496, 27536, 27576, 27616, 27656, 27696, 27736,
-27776, 27816, 27856, 27896, 27936, 27976, 28016, 28056, 28096, 28136, 28176, 28216, 28256, 28296, 28336, 28376,
-28416, 28456, 28496, 28536, 28576, 28616, 28656, 28696, 28736, 28776, 28816, 28856, 28896, 28936, 28976, 29016,
-29056, 29096, 29136, 29176, 29216, 29256, 29296, 29336, 29376, 29416, 29456, 29496, 29536, 29576, 29616, 29656,
-29696, 29736, 29776, 29816, 29856, 29896, 29936, 29976, 30016, 30056, 30096, 30136, 30176, 30216, 30256, 30296,
-30336, 30376, 30416, 30456, 30496, 30536, 30576, 30616, 30656, 30696, 30736, 30776, 30816, 30856, 30896, 30936,
-30976, 31016, 31056, 31096, 31136, 31176, 31216, 31256, 31296, 31336, 31376, 31416, 31456, 31496, 31536, 31576,
-31616, 31656, 31696, 31736, 31776, 31816, 31856, 31896, 31936, 31976, 32016, 32056, 32096, 32136, 32176, 32216,
-32256, 32296, 32336, 32376, 32416, 32456, 32496, 32536, 32576, 32616, 32656, 32696, 32736, 32776, 32816, 32856,
-32896, 32936, 32976, 33016, 33056, 33096, 33136, 33176, 33216, 33256, 33296, 33336, 33376, 33416, 33456, 33496,
-33536, 33576, 33616, 33656, 33696, 33736, 33776, 33816, 33856, 33896, 33936, 33976, 34016, 34056, 34096, 34136,
-34176, 34216, 34256, 34296, 34336, 34376, 34416, 34456, 34496, 34536, 34576, 34616, 34656, 34696, 34736, 34776,
-34816, 34856, 34896, 34936, 34976, 35016, 35056, 35096, 35136, 35176, 35216, 35256, 35296, 35336, 35376, 35416,
-35456, 35496, 35536, 35576, 35616, 35656, 35696, 35736, 35776, 35816, 35856, 35896, 35936, 35976, 36016, 36056,
-36096, 36136, 36176, 36216, 36256, 36296, 36336, 36376, 36416, 36456, 36496, 36536, 36576, 36616, 36656, 36696,
-36736, 36776, 36816, 36856, 36896, 36936, 36976, 37016, 37056, 37096, 37136, 37176, 37216, 37256, 37296, 37336,
-37376, 37416, 37456, 37496, 37536, 37576, 37616, 37656, 37696, 37736, 37776, 37816, 37856, 37896, 37936, 37976,
-38016, 38056, 38096, 38136, 38176, 38216, 38256, 38296, 38336, 38376, 38416, 38456, 38496, 38536, 38576, 38616,
-38656, 38696, 38736, 38776, 38816, 38856, 38896, 38936, 38976, 39016, 39056, 39096, 39136, 39176, 39216, 39256,
-39296, 39336, 39376, 39416, 39456, 39496, 39536, 39576, 39616, 39656, 39696, 39736, 39776, 39816, 39856, 39896,
-39936, 39976, 40016, 40056, 40096, 40136, 40176, 40216, 40256, 40296, 40336, 40376, 40416, 40456, 40496, 40536,
-40576, 40616, 40656, 40696, 40736, 40776, 40816, 40856, 40896, 40936, 40976, 41016, 41056, 41096, 41136, 41176,
-41216, 41256, 41296, 41336, 41376, 41416, 41456, 41496, 41536, 41576, 41616, 41656, 41696, 41736, 41776, 41816,
-41856, 41896, 41936, 41976, 42016, 42056, 42096, 42136, 42176, 42216, 42256, 42296, 42336, 42376, 42416, 42456,
-42496, 42536, 42576, 42616, 42656, 42696, 42736, 42776, 42816, 42856, 42896, 42936, 42976, 43016, 43056, 43096,
-43136, 43176, 43216, 43256, 43296, 43336, 43376, 43416, 43456, 43496, 43536, 43576, 43616, 43656, 43696, 43736,
-43776, 43816, 43856, 43896, 43936, 43976, 44016, 44056, 44096, 44136, 44176, 44216, 44256, 44296, 44336, 44376,
-44416, 44456, 44496, 44536, 44576, 44616, 44656, 44696, 44736, 44776, 44816, 44856, 44896, 44936, 44976, 45016,
-45056, 45096, 45136, 45176, 45216, 45256, 45296, 45336, 45376, 45416, 45456, 45496, 45536, 45576, 45616, 45656,
-45696, 45736, 45776, 45816, 45856, 45896, 45936, 45976, 46016, 46056, 46096, 46136, 46176, 46216, 46256, 46296,
-46336, 46376, 46416, 46456, 46496, 46536, 46576, 46616, 46656, 46696, 46736, 46776, 46816, 46856, 46896, 46936,
-46976, 47016, 47056, 47096, 47136, 47176, 47216, 47256, 47296, 47336, 47376, 47416, 47456, 47496, 47536, 47576,
-47616, 47656, 47696, 47736, 47776, 47816, 47856, 47896, 47936, 47976, 48016, 48056, 48096, 48136, 48176, 48216,
-48256, 48296, 48336, 48376, 48416, 48456, 48496, 48536, 48576, 48616, 48656, 48696, 48736, 48776, 48816, 48856,
-48896, 48936, 48976, 49016, 49056, 49096, 49136, 49176, 49216, 49256, 49296, 49336, 49376, 49416, 49456, 49496,
-49536, 49576, 49616, 49656, 49696, 49736, 49776, 49816, 49856, 49896, 49936, 49976, 50016, 50056, 50096, 50136,
-50176, 50216, 50256, 50296, 50336, 50376, 50416, 50456, 50496, 50536, 50576, 50616, 50656, 50696, 50736, 50776,
-50816, 50856, 50896, 50936, 50976, 51016, 51056, 51096, 51136, 51176, 51216, 51256, 51296, 51336, 51376, 51416,
-51456, 51496, 51536, 51576, 51616, 51656, 51696, 51736, 51776, 51816, 51856, 51896, 51936, 51976, 52016, 52056,
-52096, 52136, 52176, 52216, 52256, 52296, 52336, 52376, 52416, 52456, 52496, 52536, 52576, 52616, 52656, 52696,
-52736, 52776, 52816, 52856, 52896, 52936, 52976, 53016, 53056, 53096, 53136, 53176, 53216, 53256, 53296, 53336,
-53376, 53416, 53456, 53496, 53536, 53576, 53616, 53656, 53696, 53736, 53776, 53816, 53856, 53896, 53936, 53976,
-54016, 54056, 54096, 54136, 54176, 54216, 54256, 54296, 54336, 54376, 54416, 54456, 54496, 54536, 54576, 54616,
-54656, 54696, 54736, 54776, 54816, 54856, 54896, 54936, 54976, 55016, 55056, 55096, 55136, 55176, 55216, 55256,
-57344, 57384, 57424, 57464, 57504, 57544, 57584, 57624, 57664, 57704, 57744, 57784, 57824, 57864, 57904, 57944,
-57984, 58024, 58064, 58104, 58144, 58184, 58224, 58264, 58304, 58344, 58384, 58424, 58464, 58504, 58544, 58584,
-58624, 58664, 58704, 58744, 58784, 58824, 58864, 58904, 58944, 58984, 59024, 59064, 59104, 59144, 59184, 59224,
-59264, 59304, 59344, 59384, 59424, 59464, 59504, 59544, 59584, 59624, 59664, 59704, 59744, 59784, 59824, 59864,
-59904, 59944, 59984, 60024, 60064, 60104, 60144, 60184, 60224, 60264, 60304, 60344, 60384, 60424, 60464, 60504,
-60544, 60584, 60624, 60664, 60704, 60744, 60784, 60824, 60864, 60904, 60944, 60984, 61024, 61064, 61104, 61144,
-61184, 61224, 61264, 61304, 61344, 61384, 61424, 61464, 61504, 61544, 61584, 61624, 61664, 61704, 61744, 61784,
-61824, 61864, 61904, 61944, 61984, 62024, 62064, 62104, 62144, 62184, 62224, 62264, 62304, 62344, 62384, 62424,
-62464, 62504, 62544, 62584, 62624, 62664, 62704, 62744, 62784, 62824, 62864, 62904, 62944, 62984, 63024, 63064,
-63104, 63144, 63184, 63224, 63264, 63304, 63344, 63384, 63424, 63464, 63504, 63544, 63584, 63624, 63664, 63704,
-63744, 63784, 63824, 63864, 63904, 63944, 63984, 64024, 64064, 64104, 64144, 64184, 64224, 64264, 64304, 64344,
-64384, 64424, 64464, 64504, 64544, 64584, 64624, 64664, 64704, 64744, 64784, 64824, 64864, 64904, 64944, 64984,
-65024, 65064, 65104, 65144, 65184, 65224, 65264, 65304, 65344, 65384, 65424, 65464, 65504
-            });
-
-        testBytes = theseBytes(new int[]{
-255, 254, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0,
-39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0,
-47, 0, 48, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0,
-55, 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0,
-63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0,
-71, 0, 72, 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 0,
-79, 0, 80, 0, 81, 0, 82, 0, 83, 0, 84, 0, 85, 0, 86, 0,
-87, 0, 88, 0, 89, 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, 0,
-95, 0, 96, 0, 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0,
-103, 0, 104, 0, 105, 0, 106, 0, 107, 0, 108, 0, 109, 0, 110, 0,
-111, 0, 112, 0, 113, 0, 114, 0, 115, 0, 116, 0, 117, 0, 118, 0,
-119, 0, 120, 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, 0, 126, 0,
-127, 0, 128, 0, 129, 0, 130, 0, 131, 0, 132, 0, 133, 0, 134, 0,
-135, 0, 136, 0, 137, 0, 138, 0, 139, 0, 140, 0, 141, 0, 142, 0,
-143, 0, 144, 0, 145, 0, 146, 0, 147, 0, 148, 0, 149, 0, 150, 0,
-151, 0, 152, 0, 153, 0, 154, 0, 155, 0, 156, 0, 157, 0, 158, 0,
-159, 0, 160, 0, 161, 0, 162, 0, 163, 0, 164, 0, 165, 0, 166, 0,
-167, 0, 168, 0, 169, 0, 170, 0, 171, 0, 172, 0, 173, 0, 174, 0,
-175, 0, 176, 0, 177, 0, 178, 0, 179, 0, 180, 0, 181, 0, 182, 0,
-183, 0, 184, 0, 185, 0, 186, 0, 187, 0, 188, 0, 189, 0, 190, 0,
-191, 0, 192, 0, 193, 0, 194, 0, 195, 0, 196, 0, 197, 0, 198, 0,
-199, 0, 200, 0, 201, 0, 202, 0, 203, 0, 204, 0, 205, 0, 206, 0,
-207, 0, 208, 0, 209, 0, 210, 0, 211, 0, 212, 0, 213, 0, 214, 0,
-215, 0, 216, 0, 217, 0, 218, 0, 219, 0, 220, 0, 221, 0, 222, 0,
-223, 0, 224, 0, 225, 0, 226, 0, 227, 0, 228, 0, 229, 0, 230, 0,
-231, 0, 232, 0, 233, 0, 234, 0, 235, 0, 236, 0, 237, 0, 238, 0,
-239, 0, 240, 0, 241, 0, 242, 0, 243, 0, 244, 0, 245, 0, 246, 0,
-247, 0, 248, 0, 249, 0, 250, 0, 251, 0, 252, 0, 253, 0, 254, 0,
-255, 0, 0, 1, 40, 1, 80, 1, 120, 1, 160, 1, 200, 1, 240, 1,
-24, 2, 64, 2, 104, 2, 144, 2, 184, 2, 224, 2, 8, 3, 48, 3,
-88, 3, 128, 3, 168, 3, 208, 3, 248, 3, 32, 4, 72, 4, 112, 4,
-152, 4, 192, 4, 232, 4, 16, 5, 56, 5, 96, 5, 136, 5, 176, 5,
-216, 5, 0, 6, 40, 6, 80, 6, 120, 6, 160, 6, 200, 6, 240, 6,
-24, 7, 64, 7, 104, 7, 144, 7, 184, 7, 224, 7, 8, 8, 48, 8,
-88, 8, 128, 8, 168, 8, 208, 8, 248, 8, 32, 9, 72, 9, 112, 9,
-152, 9, 192, 9, 232, 9, 16, 10, 56, 10, 96, 10, 136, 10, 176, 10,
-216, 10, 0, 11, 40, 11, 80, 11, 120, 11, 160, 11, 200, 11, 240, 11,
-24, 12, 64, 12, 104, 12, 144, 12, 184, 12, 224, 12, 8, 13, 48, 13,
-88, 13, 128, 13, 168, 13, 208, 13, 248, 13, 32, 14, 72, 14, 112, 14,
-152, 14, 192, 14, 232, 14, 16, 15, 56, 15, 96, 15, 136, 15, 176, 15,
-216, 15, 0, 16, 40, 16, 80, 16, 120, 16, 160, 16, 200, 16, 240, 16,
-24, 17, 64, 17, 104, 17, 144, 17, 184, 17, 224, 17, 8, 18, 48, 18,
-88, 18, 128, 18, 168, 18, 208, 18, 248, 18, 32, 19, 72, 19, 112, 19,
-152, 19, 192, 19, 232, 19, 16, 20, 56, 20, 96, 20, 136, 20, 176, 20,
-216, 20, 0, 21, 40, 21, 80, 21, 120, 21, 160, 21, 200, 21, 240, 21,
-24, 22, 64, 22, 104, 22, 144, 22, 184, 22, 224, 22, 8, 23, 48, 23,
-88, 23, 128, 23, 168, 23, 208, 23, 248, 23, 32, 24, 72, 24, 112, 24,
-152, 24, 192, 24, 232, 24, 16, 25, 56, 25, 96, 25, 136, 25, 176, 25,
-216, 25, 0, 26, 40, 26, 80, 26, 120, 26, 160, 26, 200, 26, 240, 26,
-24, 27, 64, 27, 104, 27, 144, 27, 184, 27, 224, 27, 8, 28, 48, 28,
-88, 28, 128, 28, 168, 28, 208, 28, 248, 28, 32, 29, 72, 29, 112, 29,
-152, 29, 192, 29, 232, 29, 16, 30, 56, 30, 96, 30, 136, 30, 176, 30,
-216, 30, 0, 31, 40, 31, 80, 31, 120, 31, 160, 31, 200, 31, 240, 31,
-24, 32, 64, 32, 104, 32, 144, 32, 184, 32, 224, 32, 8, 33, 48, 33,
-88, 33, 128, 33, 168, 33, 208, 33, 248, 33, 32, 34, 72, 34, 112, 34,
-152, 34, 192, 34, 232, 34, 16, 35, 56, 35, 96, 35, 136, 35, 176, 35,
-216, 35, 0, 36, 40, 36, 80, 36, 120, 36, 160, 36, 200, 36, 240, 36,
-24, 37, 64, 37, 104, 37, 144, 37, 184, 37, 224, 37, 8, 38, 48, 38,
-88, 38, 128, 38, 168, 38, 208, 38, 248, 38, 32, 39, 72, 39, 112, 39,
-152, 39, 192, 39, 232, 39, 16, 40, 56, 40, 96, 40, 136, 40, 176, 40,
-216, 40, 0, 41, 40, 41, 80, 41, 120, 41, 160, 41, 200, 41, 240, 41,
-24, 42, 64, 42, 104, 42, 144, 42, 184, 42, 224, 42, 8, 43, 48, 43,
-88, 43, 128, 43, 168, 43, 208, 43, 248, 43, 32, 44, 72, 44, 112, 44,
-152, 44, 192, 44, 232, 44, 16, 45, 56, 45, 96, 45, 136, 45, 176, 45,
-216, 45, 0, 46, 40, 46, 80, 46, 120, 46, 160, 46, 200, 46, 240, 46,
-24, 47, 64, 47, 104, 47, 144, 47, 184, 47, 224, 47, 8, 48, 48, 48,
-88, 48, 128, 48, 168, 48, 208, 48, 248, 48, 32, 49, 72, 49, 112, 49,
-152, 49, 192, 49, 232, 49, 16, 50, 56, 50, 96, 50, 136, 50, 176, 50,
-216, 50, 0, 51, 40, 51, 80, 51, 120, 51, 160, 51, 200, 51, 240, 51,
-24, 52, 64, 52, 104, 52, 144, 52, 184, 52, 224, 52, 8, 53, 48, 53,
-88, 53, 128, 53, 168, 53, 208, 53, 248, 53, 32, 54, 72, 54, 112, 54,
-152, 54, 192, 54, 232, 54, 16, 55, 56, 55, 96, 55, 136, 55, 176, 55,
-216, 55, 0, 56, 40, 56, 80, 56, 120, 56, 160, 56, 200, 56, 240, 56,
-24, 57, 64, 57, 104, 57, 144, 57, 184, 57, 224, 57, 8, 58, 48, 58,
-88, 58, 128, 58, 168, 58, 208, 58, 248, 58, 32, 59, 72, 59, 112, 59,
-152, 59, 192, 59, 232, 59, 16, 60, 56, 60, 96, 60, 136, 60, 176, 60,
-216, 60, 0, 61, 40, 61, 80, 61, 120, 61, 160, 61, 200, 61, 240, 61,
-24, 62, 64, 62, 104, 62, 144, 62, 184, 62, 224, 62, 8, 63, 48, 63,
-88, 63, 128, 63, 168, 63, 208, 63, 248, 63, 32, 64, 72, 64, 112, 64,
-152, 64, 192, 64, 232, 64, 16, 65, 56, 65, 96, 65, 136, 65, 176, 65,
-216, 65, 0, 66, 40, 66, 80, 66, 120, 66, 160, 66, 200, 66, 240, 66,
-24, 67, 64, 67, 104, 67, 144, 67, 184, 67, 224, 67, 8, 68, 48, 68,
-88, 68, 128, 68, 168, 68, 208, 68, 248, 68, 32, 69, 72, 69, 112, 69,
-152, 69, 192, 69, 232, 69, 16, 70, 56, 70, 96, 70, 136, 70, 176, 70,
-216, 70, 0, 71, 40, 71, 80, 71, 120, 71, 160, 71, 200, 71, 240, 71,
-24, 72, 64, 72, 104, 72, 144, 72, 184, 72, 224, 72, 8, 73, 48, 73,
-88, 73, 128, 73, 168, 73, 208, 73, 248, 73, 32, 74, 72, 74, 112, 74,
-152, 74, 192, 74, 232, 74, 16, 75, 56, 75, 96, 75, 136, 75, 176, 75,
-216, 75, 0, 76, 40, 76, 80, 76, 120, 76, 160, 76, 200, 76, 240, 76,
-24, 77, 64, 77, 104, 77, 144, 77, 184, 77, 224, 77, 8, 78, 48, 78,
-88, 78, 128, 78, 168, 78, 208, 78, 248, 78, 32, 79, 72, 79, 112, 79,
-152, 79, 192, 79, 232, 79, 16, 80, 56, 80, 96, 80, 136, 80, 176, 80,
-216, 80, 0, 81, 40, 81, 80, 81, 120, 81, 160, 81, 200, 81, 240, 81,
-24, 82, 64, 82, 104, 82, 144, 82, 184, 82, 224, 82, 8, 83, 48, 83,
-88, 83, 128, 83, 168, 83, 208, 83, 248, 83, 32, 84, 72, 84, 112, 84,
-152, 84, 192, 84, 232, 84, 16, 85, 56, 85, 96, 85, 136, 85, 176, 85,
-216, 85, 0, 86, 40, 86, 80, 86, 120, 86, 160, 86, 200, 86, 240, 86,
-24, 87, 64, 87, 104, 87, 144, 87, 184, 87, 224, 87, 8, 88, 48, 88,
-88, 88, 128, 88, 168, 88, 208, 88, 248, 88, 32, 89, 72, 89, 112, 89,
-152, 89, 192, 89, 232, 89, 16, 90, 56, 90, 96, 90, 136, 90, 176, 90,
-216, 90, 0, 91, 40, 91, 80, 91, 120, 91, 160, 91, 200, 91, 240, 91,
-24, 92, 64, 92, 104, 92, 144, 92, 184, 92, 224, 92, 8, 93, 48, 93,
-88, 93, 128, 93, 168, 93, 208, 93, 248, 93, 32, 94, 72, 94, 112, 94,
-152, 94, 192, 94, 232, 94, 16, 95, 56, 95, 96, 95, 136, 95, 176, 95,
-216, 95, 0, 96, 40, 96, 80, 96, 120, 96, 160, 96, 200, 96, 240, 96,
-24, 97, 64, 97, 104, 97, 144, 97, 184, 97, 224, 97, 8, 98, 48, 98,
-88, 98, 128, 98, 168, 98, 208, 98, 248, 98, 32, 99, 72, 99, 112, 99,
-152, 99, 192, 99, 232, 99, 16, 100, 56, 100, 96, 100, 136, 100, 176, 100,
-216, 100, 0, 101, 40, 101, 80, 101, 120, 101, 160, 101, 200, 101, 240, 101,
-24, 102, 64, 102, 104, 102, 144, 102, 184, 102, 224, 102, 8, 103, 48, 103,
-88, 103, 128, 103, 168, 103, 208, 103, 248, 103, 32, 104, 72, 104, 112, 104,
-152, 104, 192, 104, 232, 104, 16, 105, 56, 105, 96, 105, 136, 105, 176, 105,
-216, 105, 0, 106, 40, 106, 80, 106, 120, 106, 160, 106, 200, 106, 240, 106,
-24, 107, 64, 107, 104, 107, 144, 107, 184, 107, 224, 107, 8, 108, 48, 108,
-88, 108, 128, 108, 168, 108, 208, 108, 248, 108, 32, 109, 72, 109, 112, 109,
-152, 109, 192, 109, 232, 109, 16, 110, 56, 110, 96, 110, 136, 110, 176, 110,
-216, 110, 0, 111, 40, 111, 80, 111, 120, 111, 160, 111, 200, 111, 240, 111,
-24, 112, 64, 112, 104, 112, 144, 112, 184, 112, 224, 112, 8, 113, 48, 113,
-88, 113, 128, 113, 168, 113, 208, 113, 248, 113, 32, 114, 72, 114, 112, 114,
-152, 114, 192, 114, 232, 114, 16, 115, 56, 115, 96, 115, 136, 115, 176, 115,
-216, 115, 0, 116, 40, 116, 80, 116, 120, 116, 160, 116, 200, 116, 240, 116,
-24, 117, 64, 117, 104, 117, 144, 117, 184, 117, 224, 117, 8, 118, 48, 118,
-88, 118, 128, 118, 168, 118, 208, 118, 248, 118, 32, 119, 72, 119, 112, 119,
-152, 119, 192, 119, 232, 119, 16, 120, 56, 120, 96, 120, 136, 120, 176, 120,
-216, 120, 0, 121, 40, 121, 80, 121, 120, 121, 160, 121, 200, 121, 240, 121,
-24, 122, 64, 122, 104, 122, 144, 122, 184, 122, 224, 122, 8, 123, 48, 123,
-88, 123, 128, 123, 168, 123, 208, 123, 248, 123, 32, 124, 72, 124, 112, 124,
-152, 124, 192, 124, 232, 124, 16, 125, 56, 125, 96, 125, 136, 125, 176, 125,
-216, 125, 0, 126, 40, 126, 80, 126, 120, 126, 160, 126, 200, 126, 240, 126,
-24, 127, 64, 127, 104, 127, 144, 127, 184, 127, 224, 127, 8, 128, 48, 128,
-88, 128, 128, 128, 168, 128, 208, 128, 248, 128, 32, 129, 72, 129, 112, 129,
-152, 129, 192, 129, 232, 129, 16, 130, 56, 130, 96, 130, 136, 130, 176, 130,
-216, 130, 0, 131, 40, 131, 80, 131, 120, 131, 160, 131, 200, 131, 240, 131,
-24, 132, 64, 132, 104, 132, 144, 132, 184, 132, 224, 132, 8, 133, 48, 133,
-88, 133, 128, 133, 168, 133, 208, 133, 248, 133, 32, 134, 72, 134, 112, 134,
-152, 134, 192, 134, 232, 134, 16, 135, 56, 135, 96, 135, 136, 135, 176, 135,
-216, 135, 0, 136, 40, 136, 80, 136, 120, 136, 160, 136, 200, 136, 240, 136,
-24, 137, 64, 137, 104, 137, 144, 137, 184, 137, 224, 137, 8, 138, 48, 138,
-88, 138, 128, 138, 168, 138, 208, 138, 248, 138, 32, 139, 72, 139, 112, 139,
-152, 139, 192, 139, 232, 139, 16, 140, 56, 140, 96, 140, 136, 140, 176, 140,
-216, 140, 0, 141, 40, 141, 80, 141, 120, 141, 160, 141, 200, 141, 240, 141,
-24, 142, 64, 142, 104, 142, 144, 142, 184, 142, 224, 142, 8, 143, 48, 143,
-88, 143, 128, 143, 168, 143, 208, 143, 248, 143, 32, 144, 72, 144, 112, 144,
-152, 144, 192, 144, 232, 144, 16, 145, 56, 145, 96, 145, 136, 145, 176, 145,
-216, 145, 0, 146, 40, 146, 80, 146, 120, 146, 160, 146, 200, 146, 240, 146,
-24, 147, 64, 147, 104, 147, 144, 147, 184, 147, 224, 147, 8, 148, 48, 148,
-88, 148, 128, 148, 168, 148, 208, 148, 248, 148, 32, 149, 72, 149, 112, 149,
-152, 149, 192, 149, 232, 149, 16, 150, 56, 150, 96, 150, 136, 150, 176, 150,
-216, 150, 0, 151, 40, 151, 80, 151, 120, 151, 160, 151, 200, 151, 240, 151,
-24, 152, 64, 152, 104, 152, 144, 152, 184, 152, 224, 152, 8, 153, 48, 153,
-88, 153, 128, 153, 168, 153, 208, 153, 248, 153, 32, 154, 72, 154, 112, 154,
-152, 154, 192, 154, 232, 154, 16, 155, 56, 155, 96, 155, 136, 155, 176, 155,
-216, 155, 0, 156, 40, 156, 80, 156, 120, 156, 160, 156, 200, 156, 240, 156,
-24, 157, 64, 157, 104, 157, 144, 157, 184, 157, 224, 157, 8, 158, 48, 158,
-88, 158, 128, 158, 168, 158, 208, 158, 248, 158, 32, 159, 72, 159, 112, 159,
-152, 159, 192, 159, 232, 159, 16, 160, 56, 160, 96, 160, 136, 160, 176, 160,
-216, 160, 0, 161, 40, 161, 80, 161, 120, 161, 160, 161, 200, 161, 240, 161,
-24, 162, 64, 162, 104, 162, 144, 162, 184, 162, 224, 162, 8, 163, 48, 163,
-88, 163, 128, 163, 168, 163, 208, 163, 248, 163, 32, 164, 72, 164, 112, 164,
-152, 164, 192, 164, 232, 164, 16, 165, 56, 165, 96, 165, 136, 165, 176, 165,
-216, 165, 0, 166, 40, 166, 80, 166, 120, 166, 160, 166, 200, 166, 240, 166,
-24, 167, 64, 167, 104, 167, 144, 167, 184, 167, 224, 167, 8, 168, 48, 168,
-88, 168, 128, 168, 168, 168, 208, 168, 248, 168, 32, 169, 72, 169, 112, 169,
-152, 169, 192, 169, 232, 169, 16, 170, 56, 170, 96, 170, 136, 170, 176, 170,
-216, 170, 0, 171, 40, 171, 80, 171, 120, 171, 160, 171, 200, 171, 240, 171,
-24, 172, 64, 172, 104, 172, 144, 172, 184, 172, 224, 172, 8, 173, 48, 173,
-88, 173, 128, 173, 168, 173, 208, 173, 248, 173, 32, 174, 72, 174, 112, 174,
-152, 174, 192, 174, 232, 174, 16, 175, 56, 175, 96, 175, 136, 175, 176, 175,
-216, 175, 0, 176, 40, 176, 80, 176, 120, 176, 160, 176, 200, 176, 240, 176,
-24, 177, 64, 177, 104, 177, 144, 177, 184, 177, 224, 177, 8, 178, 48, 178,
-88, 178, 128, 178, 168, 178, 208, 178, 248, 178, 32, 179, 72, 179, 112, 179,
-152, 179, 192, 179, 232, 179, 16, 180, 56, 180, 96, 180, 136, 180, 176, 180,
-216, 180, 0, 181, 40, 181, 80, 181, 120, 181, 160, 181, 200, 181, 240, 181,
-24, 182, 64, 182, 104, 182, 144, 182, 184, 182, 224, 182, 8, 183, 48, 183,
-88, 183, 128, 183, 168, 183, 208, 183, 248, 183, 32, 184, 72, 184, 112, 184,
-152, 184, 192, 184, 232, 184, 16, 185, 56, 185, 96, 185, 136, 185, 176, 185,
-216, 185, 0, 186, 40, 186, 80, 186, 120, 186, 160, 186, 200, 186, 240, 186,
-24, 187, 64, 187, 104, 187, 144, 187, 184, 187, 224, 187, 8, 188, 48, 188,
-88, 188, 128, 188, 168, 188, 208, 188, 248, 188, 32, 189, 72, 189, 112, 189,
-152, 189, 192, 189, 232, 189, 16, 190, 56, 190, 96, 190, 136, 190, 176, 190,
-216, 190, 0, 191, 40, 191, 80, 191, 120, 191, 160, 191, 200, 191, 240, 191,
-24, 192, 64, 192, 104, 192, 144, 192, 184, 192, 224, 192, 8, 193, 48, 193,
-88, 193, 128, 193, 168, 193, 208, 193, 248, 193, 32, 194, 72, 194, 112, 194,
-152, 194, 192, 194, 232, 194, 16, 195, 56, 195, 96, 195, 136, 195, 176, 195,
-216, 195, 0, 196, 40, 196, 80, 196, 120, 196, 160, 196, 200, 196, 240, 196,
-24, 197, 64, 197, 104, 197, 144, 197, 184, 197, 224, 197, 8, 198, 48, 198,
-88, 198, 128, 198, 168, 198, 208, 198, 248, 198, 32, 199, 72, 199, 112, 199,
-152, 199, 192, 199, 232, 199, 16, 200, 56, 200, 96, 200, 136, 200, 176, 200,
-216, 200, 0, 201, 40, 201, 80, 201, 120, 201, 160, 201, 200, 201, 240, 201,
-24, 202, 64, 202, 104, 202, 144, 202, 184, 202, 224, 202, 8, 203, 48, 203,
-88, 203, 128, 203, 168, 203, 208, 203, 248, 203, 32, 204, 72, 204, 112, 204,
-152, 204, 192, 204, 232, 204, 16, 205, 56, 205, 96, 205, 136, 205, 176, 205,
-216, 205, 0, 206, 40, 206, 80, 206, 120, 206, 160, 206, 200, 206, 240, 206,
-24, 207, 64, 207, 104, 207, 144, 207, 184, 207, 224, 207, 8, 208, 48, 208,
-88, 208, 128, 208, 168, 208, 208, 208, 248, 208, 32, 209, 72, 209, 112, 209,
-152, 209, 192, 209, 232, 209, 16, 210, 56, 210, 96, 210, 136, 210, 176, 210,
-216, 210, 0, 211, 40, 211, 80, 211, 120, 211, 160, 211, 200, 211, 240, 211,
-24, 212, 64, 212, 104, 212, 144, 212, 184, 212, 224, 212, 8, 213, 48, 213,
-88, 213, 128, 213, 168, 213, 208, 213, 248, 213, 32, 214, 72, 214, 112, 214,
-152, 214, 192, 214, 232, 214, 16, 215, 56, 215, 96, 215, 136, 215, 176, 215,
-216, 215, 0, 224, 40, 224, 80, 224, 120, 224, 160, 224, 200, 224, 240, 224,
-24, 225, 64, 225, 104, 225, 144, 225, 184, 225, 224, 225, 8, 226, 48, 226,
-88, 226, 128, 226, 168, 226, 208, 226, 248, 226, 32, 227, 72, 227, 112, 227,
-152, 227, 192, 227, 232, 227, 16, 228, 56, 228, 96, 228, 136, 228, 176, 228,
-216, 228, 0, 229, 40, 229, 80, 229, 120, 229, 160, 229, 200, 229, 240, 229,
-24, 230, 64, 230, 104, 230, 144, 230, 184, 230, 224, 230, 8, 231, 48, 231,
-88, 231, 128, 231, 168, 231, 208, 231, 248, 231, 32, 232, 72, 232, 112, 232,
-152, 232, 192, 232, 232, 232, 16, 233, 56, 233, 96, 233, 136, 233, 176, 233,
-216, 233, 0, 234, 40, 234, 80, 234, 120, 234, 160, 234, 200, 234, 240, 234,
-24, 235, 64, 235, 104, 235, 144, 235, 184, 235, 224, 235, 8, 236, 48, 236,
-88, 236, 128, 236, 168, 236, 208, 236, 248, 236, 32, 237, 72, 237, 112, 237,
-152, 237, 192, 237, 232, 237, 16, 238, 56, 238, 96, 238, 136, 238, 176, 238,
-216, 238, 0, 239, 40, 239, 80, 239, 120, 239, 160, 239, 200, 239, 240, 239,
-24, 240, 64, 240, 104, 240, 144, 240, 184, 240, 224, 240, 8, 241, 48, 241,
-88, 241, 128, 241, 168, 241, 208, 241, 248, 241, 32, 242, 72, 242, 112, 242,
-152, 242, 192, 242, 232, 242, 16, 243, 56, 243, 96, 243, 136, 243, 176, 243,
-216, 243, 0, 244, 40, 244, 80, 244, 120, 244, 160, 244, 200, 244, 240, 244,
-24, 245, 64, 245, 104, 245, 144, 245, 184, 245, 224, 245, 8, 246, 48, 246,
-88, 246, 128, 246, 168, 246, 208, 246, 248, 246, 32, 247, 72, 247, 112, 247,
-152, 247, 192, 247, 232, 247, 16, 248, 56, 248, 96, 248, 136, 248, 176, 248,
-216, 248, 0, 249, 40, 249, 80, 249, 120, 249, 160, 249, 200, 249, 240, 249,
-24, 250, 64, 250, 104, 250, 144, 250, 184, 250, 224, 250, 8, 251, 48, 251,
-88, 251, 128, 251, 168, 251, 208, 251, 248, 251, 32, 252, 72, 252, 112, 252,
-152, 252, 192, 252, 232, 252, 16, 253, 56, 253, 96, 253, 136, 253, 176, 253,
-216, 253, 0, 254, 40, 254, 80, 254, 120, 254, 160, 254, 200, 254, 240, 254,
-24, 255, 64, 255, 104, 255, 144, 255, 184, 255, 224, 255
-            });
-
-        super.setUp();
-    }
-
-}
diff --git a/luni/src/test/java/libcore/java/text/DecimalFormatTest.java b/luni/src/test/java/libcore/java/text/DecimalFormatTest.java
index ba8cbeb..4add5b0 100644
--- a/luni/src/test/java/libcore/java/text/DecimalFormatTest.java
+++ b/luni/src/test/java/libcore/java/text/DecimalFormatTest.java
@@ -335,4 +335,42 @@
         localeCurrencyFormat.setCurrency(currency);
         return localeCurrencyFormat.format(1000);
     }
+
+    /**
+     * DecimalFormat doesn't support different group separator for currency and non-currency
+     * number formats. Ensure normal group separator is used, and ignore monetary group separator
+     * when formatting currency. http://b/37135768
+     */
+    public void testLocaleGroupingSeparator() {
+        // CLDR uses '.' for currency and '\u00a0' for non-currency number formats in de_AT
+        // Assert ICU is using these characters
+        Locale locale = new Locale("de", "AT");
+        android.icu.text.DecimalFormatSymbols icuDfs =
+                new android.icu.text.DecimalFormatSymbols(locale);
+        assertEquals(icuDfs.getGroupingSeparator(), '\u00a0');
+        assertEquals(icuDfs.getMonetaryGroupingSeparator(), '.');
+
+        // In this class, only '\u00a0' should be used for both cases.
+        DecimalFormatSymbols dfs = new DecimalFormatSymbols(locale);
+        // Assert CLDR uses '\u00a0' as grouping separator
+        assertEquals(dfs.getGroupingSeparator(), '\u00a0');
+
+        // Test non-currency number formats
+        assertEquals("1\u00a0234,00", new DecimalFormat("#,##0.00", dfs).format(1234));
+        // Test currency format
+        assertEquals("\u20ac1\u00a0234,00", new DecimalFormat("¤#,##0.00", dfs).format(1234));
+    }
+
+    /**
+     * Test {@link DecimalFormatSymbols#setGroupingSeparator(char)} for currency and non-currency
+     * number formats. http://b/37135768
+     */
+    public void testSetGroupingSeparator() {
+        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
+        dfs.setGroupingSeparator(' ');
+        // Test non-currency number formats
+        assertEquals("1 234.00", new DecimalFormat("#,##0.00", dfs).format(1234));
+        // Test currency format
+        assertEquals("$1 234.00", new DecimalFormat("¤#,##0.00", dfs).format(1234));
+    }
 }
diff --git a/luni/src/test/java/libcore/java/text/OldNumberFormatTest.java b/luni/src/test/java/libcore/java/text/OldNumberFormatTest.java
index ad7ef0b..e77eb89 100644
--- a/luni/src/test/java/libcore/java/text/OldNumberFormatTest.java
+++ b/luni/src/test/java/libcore/java/text/OldNumberFormatTest.java
@@ -317,7 +317,7 @@
         format = NumberFormat.getCurrencyInstance(atLocale);
         // BEGIN Android-changed: ICU uses non-breaking space after the euro sign; the RI uses ' '.
         assertEquals("\u20ac\u00a035,76", format.format(35.76));
-        assertEquals("\u20ac\u00a0123.456,79", format.format(123456.789));
+        assertEquals("\u20ac\u00a0123\u00a0456,79", format.format(123456.789));
         assertEquals("\u20ac\u00a00,10", format.format(0.1));
         assertEquals("\u20ac\u00a01,00", format.format(0.999));
         try {
diff --git a/luni/src/test/java/libcore/java/util/zip/ZipEntryTest.java b/luni/src/test/java/libcore/java/util/zip/ZipEntryTest.java
index bf10c3e..4e2df69 100644
--- a/luni/src/test/java/libcore/java/util/zip/ZipEntryTest.java
+++ b/luni/src/test/java/libcore/java/util/zip/ZipEntryTest.java
@@ -21,21 +21,24 @@
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
 import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
 
 public class ZipEntryTest extends junit.framework.TestCase {
-  private static File createTemporaryZipFile() throws IOException {
-    File result = File.createTempFile("ZipFileTest", "zip");
-    result.deleteOnExit();
-    return result;
-  }
+  // The zip format differentiates between times before and after 1/1/1980. A timestamp before 1980
+  // will produce a different zip binary. ZipOutputStream.putNextEntry defaults the entry times to
+  // the current system clock value. This time can be used explicitly to ensure the behavior of most
+  // tests is independent of the system clock.
+  private static final long ENTRY_TIME = 1262304000000L; //  January 1, 2010 12:00:00 AM GMT
 
   private static ZipOutputStream createZipOutputStream(File f) throws IOException {
     return new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(f)));
@@ -49,6 +52,23 @@
     return sb.toString();
   }
 
+  private List<File> temporaryFiles = new ArrayList<>();
+
+  private File createTemporaryZipFile() throws IOException {
+    File result = File.createTempFile("ZipFileTest", "zip");
+    temporaryFiles.add(result);
+    return result;
+  }
+
+  @Override
+  public void tearDown() throws Exception {
+    for (File file : temporaryFiles) {
+      file.delete();
+    }
+    temporaryFiles.clear();
+    super.tearDown();
+  }
+
   // http://code.google.com/p/android/issues/detail?id=4690
   public void test_utf8FileNames() throws Exception {
     // Create a zip file containing non-ASCII filenames.
@@ -134,6 +154,7 @@
     ZipOutputStream out = createZipOutputStream(f);
     ZipEntry ze = new ZipEntry("x");
     ze.setSize(0);
+    ze.setTime(ENTRY_TIME);
     ze.setExtra(maxLengthExtra);
     out.putNextEntry(ze);
     out.closeEntry();
@@ -145,6 +166,41 @@
     zipFile.close();
   }
 
+  public void testSetTime() throws Exception {
+    // Set a time before the lower bound of dos time, year 1980
+    checkSetTime(0L); // January 1, 1970 12:00:00 AM GMT
+    checkSetTime(31536000000L); // January 1, 1971 12:00:00 AM GMT
+    checkSetTime(315187200000L); // December 28, 1979 12:00:00 AM GMT
+    // December 31, 1979 11:59:59 AM Local time
+    checkSetTime(LocalDate.of(1980, 1, 1).atStartOfDay().minus(1, ChronoUnit.SECONDS)
+                    .atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
+
+    // January 1, 1980 12:00:00 AM Local time
+    checkSetTime(LocalDate.of(1980, 1, 1).atStartOfDay().atZone(ZoneId.systemDefault())
+            .toInstant().toEpochMilli());
+    // Set a time after the lower bound of dos time, year 1980
+    checkSetTime(315705600000L); // January 3, 1980 12:00:00 AM GMT
+    checkSetTime(ENTRY_TIME); // January 1, 2010 12:00:00 AM
+
+    // Set a time after upper bound of dos time.
+    checkSetTime(4134153600000L); // January 3, 2101 12:00:00 AM GMT
+  }
+
+  private void checkSetTime(long time) throws IOException {
+    File f = createTemporaryZipFile();
+    ZipOutputStream out = createZipOutputStream(f);
+    ZipEntry ze = new ZipEntry("x");
+    ze.setSize(0);
+    ze.setTime(time);
+    out.putNextEntry(ze);
+    out.closeEntry();
+    out.close();
+
+    // Read it back, and check that we see the entry.
+    ZipFile zipFile = new ZipFile(f);
+    assertEquals(time, zipFile.getEntry("x").getTime());
+    zipFile.close();
+  }
 
   // TODO: This test does not compile because we need to add a ZipOutputStream constructor
   // that forces zip64. This also needs followup changes in ZipInputStream et al. to assume zip64
@@ -206,6 +262,7 @@
     // Regular (non zip64) format.
     ZipEntry ze = new ZipEntry("x");
     ze.setSize(0);
+    ze.setTime(ENTRY_TIME);
     ze.setExtra(extra);
     ze.setComment(comment);
     out.putNextEntry(ze);
@@ -213,6 +270,7 @@
 
     // An entry without a length is assumed to be zip64.
     ze = new ZipEntry("y");
+    ze.setTime(ENTRY_TIME);
     ze.setExtra(extra);
     ze.setComment(comment);
     out.putNextEntry(ze);
diff --git a/luni/src/test/java/libcore/java/util/zip/ZipOutputStreamTest.java b/luni/src/test/java/libcore/java/util/zip/ZipOutputStreamTest.java
index 4e72874..fa85f9a 100644
--- a/luni/src/test/java/libcore/java/util/zip/ZipOutputStreamTest.java
+++ b/luni/src/test/java/libcore/java/util/zip/ZipOutputStreamTest.java
@@ -17,6 +17,7 @@
 package libcore.java.util.zip;
 
 import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -25,6 +26,8 @@
 import java.util.Random;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
 import libcore.junit.junit3.TestCaseWithRules;
 import libcore.junit.util.ResourceLeakageDetector;
@@ -98,4 +101,34 @@
             out.finish();
         }
     }
+
+    /**
+     * Test {@link ZipOutputStream#putNextEntry(ZipEntry)} that the current time will be used
+     * if the entry has no set modification time.
+     */
+    public void testPutNextEntryUsingCurrentTime() throws IOException {
+        // Zip file truncates time into 1s (before 1980) or 2s precision.
+        long timeBeforeZip = System.currentTimeMillis() / 2000 * 2000;
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try (ZipOutputStream out = new ZipOutputStream(bos)) {
+            ZipEntry entryWithoutExplicitTime = new ZipEntry("name");
+            // We do not set a time on the entry. We expect ZipOutputStream to use the current
+            // system clock value.
+            out.putNextEntry(entryWithoutExplicitTime);
+            out.closeEntry();
+            out.finish();
+        }
+        // timeAfterZip will normally be rounded down to  1 / 2 seconds boundary as well, but this
+        // test accepts either exact or rounded-down values because the rounding behavior is outside
+        // of this test's purpose
+        long timeAfterZip = System.currentTimeMillis();
+
+        // Read it back, and check the modification time is almost the system clock value
+        try (ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray()))) {
+            ZipEntry entry = zis.getNextEntry();
+            assertEquals("name", entry.getName());
+            assertTrue(timeBeforeZip <= entry.getTime());
+            assertTrue(timeAfterZip >= entry.getTime());
+        }
+    }
 }
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
index 7b74c83..44cda4b 100644
--- a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
+++ b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
@@ -64,6 +64,7 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -1816,9 +1817,17 @@
         client.startHandshake();
 
         // Reflection is used so this can compile on the RI
-        String expectedClassName = "com.android.org.conscrypt.OpenSSLSocketImpl";
+        String expectedClassName = "com.android.org.conscrypt.ConscryptFileDescriptorSocket";
         Class<?> actualClass = client.getClass();
         assertEquals(expectedClassName, actualClass.getName());
+        // The concrete class that Conscrypt returns has methods on it that have no
+        // equivalent on the public API (like setSoWriteTimeout), so users have
+        // previously used reflection to access those otherwise-inaccessible methods
+        // on that class.  The concrete class used to be named OpenSSLSocketImpl, so
+        // check that OpenSSLSocketImpl is still in the class hierarchy so applications
+        // that rely on getting that class back still work.
+        Class<?> superClass = actualClass.getSuperclass();
+        assertEquals("com.android.org.conscrypt.OpenSSLSocketImpl", superClass.getName());
         Method setSoWriteTimeout = actualClass.getMethod("setSoWriteTimeout",
                                                          new Class<?>[] { Integer.TYPE });
         setSoWriteTimeout.invoke(client, 1);
@@ -1853,7 +1862,7 @@
         SSLSocket client = (SSLSocket) c.clientContext.getSocketFactory().createSocket();
 
         // Reflection is used so this can compile on the RI
-        String expectedClassName = "com.android.org.conscrypt.OpenSSLSocketImpl";
+        String expectedClassName = "com.android.org.conscrypt.ConscryptFileDescriptorSocket";
         Class<?> actualClass = client.getClass();
         assertEquals(expectedClassName, actualClass.getName());
         Method setNpnProtocols = actualClass.getMethod("setNpnProtocols", byte[].class);
@@ -1950,7 +1959,7 @@
             fail();
         } catch (SocketTimeoutException e) {
             throw e;
-        } catch (SocketException expected) {
+        } catch (IOException expected) {
         }
         future.get();
 
@@ -1989,7 +1998,12 @@
                     wrapping.startHandshake();
                     assertFalse(StandardNames.IS_RI);
                     wrapping.setSoTimeout(readingTimeoutMillis);
-                    assertEquals(-1, wrapping.getInputStream().read());
+                    wrapping.getInputStream().read();
+                    fail();
+                } catch (SocketException e) {
+                    // Conscrypt throws an exception complaining that the socket is closed
+                    // if it's interrupted by a close() in the middle of a read()
+                    assertTrue(e.getMessage().contains("closed"));
                 } catch (Exception e) {
                     if (!StandardNames.IS_RI) {
                         throw e;
diff --git a/luni/src/test/native/libcore_java_io_FileTest.cpp b/luni/src/test/native/libcore_java_io_FileTest.cpp
index 4dcf487..7cc6568 100644
--- a/luni/src/test/native/libcore_java_io_FileTest.cpp
+++ b/luni/src/test/native/libcore_java_io_FileTest.cpp
@@ -22,8 +22,8 @@
 #include <errno.h>
 
 #include <jni.h>
-#include "JNIHelp.h"
-#include "ScopedUtfChars.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedUtfChars.h>
 
 extern "C" void Java_libcore_java_io_FileTest_nativeTestFilesWithSurrogatePairs(
     JNIEnv* env, jobject /* clazz */, jstring baseDir) {
diff --git a/luni/src/test/native/libcore_java_lang_ThreadTest.cpp b/luni/src/test/native/libcore_java_lang_ThreadTest.cpp
index 68e858a..f942607 100644
--- a/luni/src/test/native/libcore_java_lang_ThreadTest.cpp
+++ b/luni/src/test/native/libcore_java_lang_ThreadTest.cpp
@@ -21,7 +21,7 @@
 #include <sys/prctl.h>
 
 #include <jni.h>
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 static JavaVM* javaVm = nullptr;
 
diff --git a/luni/src/test/native/libcore_java_nio_BufferTest.cpp b/luni/src/test/native/libcore_java_nio_BufferTest.cpp
index 2b71b3e..ab7c20e 100644
--- a/luni/src/test/native/libcore_java_nio_BufferTest.cpp
+++ b/luni/src/test/native/libcore_java_nio_BufferTest.cpp
@@ -15,7 +15,7 @@
  */
 
 #include <jni.h>
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 extern "C" jlong Java_libcore_java_nio_BufferTest_jniGetDirectBufferAddress(
     JNIEnv* env, jobject /* clazz */, jobject buffer) {
diff --git a/luni/src/test/native/libcore_util_NativeAllocationRegistryTest.cpp b/luni/src/test/native/libcore_util_NativeAllocationRegistryTest.cpp
index 3b458e2..2260d37 100644
--- a/luni/src/test/native/libcore_util_NativeAllocationRegistryTest.cpp
+++ b/luni/src/test/native/libcore_util_NativeAllocationRegistryTest.cpp
@@ -18,8 +18,8 @@
 #include <string>
 
 #include <jni.h>
-#include "JNIHelp.h"
-#include "ScopedUtfChars.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedUtfChars.h>
 
 uint64_t gNumNativeBytesAllocated = 0;
 
diff --git a/non_openjdk_java_files.mk b/non_openjdk_java_files.mk
index ecd0ffa..29f8d0c 100644
--- a/non_openjdk_java_files.mk
+++ b/non_openjdk_java_files.mk
@@ -19,6 +19,7 @@
   luni/src/main/java/android/system/StructStat.java \
   luni/src/main/java/android/system/StructStatVfs.java \
   luni/src/main/java/android/system/StructTimeval.java \
+  luni/src/main/java/android/system/StructTimespec.java \
   luni/src/main/java/android/system/StructUcred.java \
   luni/src/main/java/android/system/StructUtsname.java \
   luni/src/main/java/android/util/MutableBoolean.java \
diff --git a/ojluni/src/main/java/java/lang/String.java b/ojluni/src/main/java/java/lang/String.java
index 2b588a5..eb24712 100644
--- a/ojluni/src/main/java/java/lang/String.java
+++ b/ojluni/src/main/java/java/lang/String.java
@@ -117,7 +117,7 @@
 public final class String
     implements java.io.Serializable, Comparable<String>, CharSequence {
 
-    // dThe associated character storage is managed by the runtime. We only
+    // The associated character storage is managed by the runtime. We only
     // keep track of the length here.
     //
     // private final char value[];
diff --git a/ojluni/src/main/java/java/text/DecimalFormat.java b/ojluni/src/main/java/java/text/DecimalFormat.java
index 3ceb9cd..17d5d41 100644
--- a/ojluni/src/main/java/java/text/DecimalFormat.java
+++ b/ojluni/src/main/java/java/text/DecimalFormat.java
@@ -48,6 +48,7 @@
 import java.math.RoundingMode;
 import java.util.Currency;
 import java.util.Locale;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -1593,36 +1594,87 @@
         ObjectInputStream.GetField fields = stream.readFields();
         this.symbols = (DecimalFormatSymbols) fields.get("symbols", null);
 
-        init("");
+        init("#");
 
-        icuDecimalFormat.setPositivePrefix((String) fields.get("positivePrefix", ""));
-        icuDecimalFormat.setPositiveSuffix((String) fields.get("positiveSuffix", ""));
-        icuDecimalFormat.setNegativePrefix((String) fields.get("negativePrefix", "-"));
-        icuDecimalFormat.setNegativeSuffix((String) fields.get("negativeSuffix", ""));
-        icuDecimalFormat.setMultiplier(fields.get("multiplier", 1));
-        icuDecimalFormat.setGroupingSize(fields.get("groupingSize", (byte) 3));
-        icuDecimalFormat.setGroupingUsed(fields.get("groupingUsed", true));
-        icuDecimalFormat.setDecimalSeparatorAlwaysShown(fields.get("decimalSeparatorAlwaysShown",
-                false));
+        // Calling a setter method on an ICU DecimalFormat object will change the object's internal
+        // state, even if the value set is the same as the default value (ICU Ticket #13266).
+        //
+        // In an attempt to create objects that are equals() to the ones that were serialized, it's
+        // therefore assumed here that any values that are the same as the default values were the
+        // default values (ie. no setter was called to explicitly set that value).
 
-        setRoundingMode((RoundingMode) fields.get("roundingMode", RoundingMode.HALF_EVEN));
+        String positivePrefix = (String) fields.get("positivePrefix", "");
+        if (!Objects.equals(positivePrefix, icuDecimalFormat.getPositivePrefix())) {
+            icuDecimalFormat.setPositivePrefix(positivePrefix);
+        }
 
-        final int maximumIntegerDigits = fields.get("maximumIntegerDigits", 309);
-        final int minimumIntegerDigits = fields.get("minimumIntegerDigits", 309);
-        final int maximumFractionDigits = fields.get("maximumFractionDigits", 340);
-        final int minimumFractionDigits = fields.get("minimumFractionDigits", 340);
-        // Tell ICU what we want, then ask it what we can have, and then
-        // set that in our Java object. This isn't RI-compatible, but then very little of our
-        // behavior in this area is, and it's not obvious how we can second-guess ICU (or tell
-        // it to just do exactly what we ask). We only need to do this with maximumIntegerDigits
-        // because ICU doesn't seem to have its own ideas about the other options.
-        icuDecimalFormat.setMaximumIntegerDigits(maximumIntegerDigits);
-        super.setMaximumIntegerDigits(icuDecimalFormat.getMaximumIntegerDigits());
+        String positiveSuffix = (String) fields.get("positiveSuffix", "");
+        if (!Objects.equals(positiveSuffix, icuDecimalFormat.getPositiveSuffix())) {
+            icuDecimalFormat.setPositiveSuffix(positiveSuffix);
+        }
 
-        setMinimumIntegerDigits(minimumIntegerDigits);
-        setMinimumFractionDigits(minimumFractionDigits);
-        setMaximumFractionDigits(maximumFractionDigits);
-        setParseBigDecimal(fields.get("parseBigDecimal", false));
+        String negativePrefix = (String) fields.get("negativePrefix", "-");
+        if (!Objects.equals(negativePrefix, icuDecimalFormat.getNegativePrefix())) {
+            icuDecimalFormat.setNegativePrefix(negativePrefix);
+        }
+
+        String negativeSuffix = (String) fields.get("negativeSuffix", "");
+        if (!Objects.equals(negativeSuffix, icuDecimalFormat.getNegativeSuffix())) {
+            icuDecimalFormat.setNegativeSuffix(negativeSuffix);
+        }
+
+        int multiplier = fields.get("multiplier", 1);
+        if (multiplier != icuDecimalFormat.getMultiplier()) {
+            icuDecimalFormat.setMultiplier(multiplier);
+        }
+
+        boolean groupingUsed = fields.get("groupingUsed", true);
+        if (groupingUsed != icuDecimalFormat.isGroupingUsed()) {
+            icuDecimalFormat.setGroupingUsed(groupingUsed);
+        }
+
+        int groupingSize = fields.get("groupingSize", (byte) 3);
+        if (groupingSize != icuDecimalFormat.getGroupingSize()) {
+            icuDecimalFormat.setGroupingSize(groupingSize);
+        }
+
+        boolean decimalSeparatorAlwaysShown = fields.get("decimalSeparatorAlwaysShown", false);
+        if (decimalSeparatorAlwaysShown != icuDecimalFormat.isDecimalSeparatorAlwaysShown()) {
+            icuDecimalFormat.setDecimalSeparatorAlwaysShown(decimalSeparatorAlwaysShown);
+        }
+
+        RoundingMode roundingMode =
+                (RoundingMode) fields.get("roundingMode", RoundingMode.HALF_EVEN);
+        if (convertRoundingMode(roundingMode) != icuDecimalFormat.getRoundingMode()) {
+            setRoundingMode(roundingMode);
+        }
+
+        int maximumIntegerDigits = fields.get("maximumIntegerDigits", 309);
+        if (maximumIntegerDigits != icuDecimalFormat.getMaximumIntegerDigits()) {
+            icuDecimalFormat.setMaximumIntegerDigits(maximumIntegerDigits);
+        }
+
+        int minimumIntegerDigits = fields.get("minimumIntegerDigits", 309);
+        if (minimumIntegerDigits != icuDecimalFormat.getMinimumIntegerDigits()) {
+            icuDecimalFormat.setMinimumIntegerDigits(minimumIntegerDigits);
+        }
+
+        int maximumFractionDigits = fields.get("maximumFractionDigits", 340);
+        if (maximumFractionDigits != icuDecimalFormat.getMaximumFractionDigits()) {
+            icuDecimalFormat.setMaximumFractionDigits(maximumFractionDigits);
+        }
+
+        int minimumFractionDigits = fields.get("minimumFractionDigits", 340);
+        if (minimumFractionDigits != icuDecimalFormat.getMinimumFractionDigits()) {
+            icuDecimalFormat.setMinimumFractionDigits(minimumFractionDigits);
+        }
+
+        boolean parseBigDecimal = fields.get("parseBigDecimal", true);
+        if (parseBigDecimal != icuDecimalFormat.isParseBigDecimal()) {
+            icuDecimalFormat.setParseBigDecimal(parseBigDecimal);
+        }
+
+        updateFieldsFromIcu();
 
         if (fields.get("serialVersionOnStream", 0) < 3) {
             setMaximumIntegerDigits(super.getMaximumIntegerDigits());
diff --git a/ojluni/src/main/java/java/text/DecimalFormatSymbols.java b/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
index 9e82738..2acb128 100644
--- a/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
@@ -757,6 +757,10 @@
         cachedIcuDFS.setDigit(digit);
         cachedIcuDFS.setDecimalSeparator(decimalSeparator);
         cachedIcuDFS.setGroupingSeparator(groupingSeparator);
+        // {@link #setGroupingSeparator(char)} should set grouping separator for currency, but
+        // ICU has a separate API setMonetaryGroupingSeparator. Need to call it explicitly here.
+        // http://b/38021063
+        cachedIcuDFS.setMonetaryGroupingSeparator(groupingSeparator);
         cachedIcuDFS.setPatternSeparator(patternSeparator);
         cachedIcuDFS.setPercent(percent);
         cachedIcuDFS.setMonetaryDecimalSeparator(monetarySeparator);
diff --git a/ojluni/src/main/java/java/util/regex/Matcher.java b/ojluni/src/main/java/java/util/regex/Matcher.java
index 9af28aa..156b8bd 100644
--- a/ojluni/src/main/java/java/util/regex/Matcher.java
+++ b/ojluni/src/main/java/java/util/regex/Matcher.java
@@ -124,6 +124,13 @@
             Matcher.class.getClassLoader(), getNativeFinalizer(), nativeSize());
 
     /**
+     * Holds the original CharSequence for use in {@link #reset}. {@link #input} is used during
+     * matching. Note that CharSequence is mutable while String is not, so reset can cause the input
+     * to match to change.
+     */
+    private CharSequence originalInput;
+
+    /**
      * Holds the input text.
      */
     private String input;
@@ -490,6 +497,7 @@
      *          pattern
      */
     public boolean find(int start) {
+        reset();
         if (start < 0 || start > input.length()) {
             throw new IndexOutOfBoundsException("start=" + start + "; length=" + input.length());
         }
@@ -820,7 +828,7 @@
      * @since 1.5
      */
     public Matcher region(int start, int end) {
-        return reset(input, start, end);
+        return reset(originalInput, start, end);
     }
 
     /**
@@ -1024,7 +1032,7 @@
      * @return  This matcher
      */
     public Matcher reset() {
-        return reset(input, 0, input.length());
+        return reset(originalInput, 0, originalInput.length());
     }
 
     /**
@@ -1070,6 +1078,7 @@
             throw new IndexOutOfBoundsException();
         }
 
+        this.originalInput = input;
         this.input = input.toString();
         this.regionStart = start;
         this.regionEnd = end;
diff --git a/ojluni/src/main/native/Adler32.c b/ojluni/src/main/native/Adler32.c
index b62b111..11ef08d 100644
--- a/ojluni/src/main/native/Adler32.c
+++ b/ojluni/src/main/native/Adler32.c
@@ -27,7 +27,7 @@
  * Native method support for java.util.zip.Adler32
  */
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #include "jni.h"
 #include "jni_util.h"
 #include "jlong.h"
diff --git a/ojluni/src/main/native/Bits.c b/ojluni/src/main/native/Bits.c
index 18e5e59..50caf36 100644
--- a/ojluni/src/main/native/Bits.c
+++ b/ojluni/src/main/native/Bits.c
@@ -31,7 +31,7 @@
 #include "jlong.h"
 #include <string.h>
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 /*
  * WARNING:
diff --git a/ojluni/src/main/native/Character.cpp b/ojluni/src/main/native/Character.cpp
index 6a82fde..666184f 100644
--- a/ojluni/src/main/native/Character.cpp
+++ b/ojluni/src/main/native/Character.cpp
@@ -20,7 +20,7 @@
 
 #include "jni.h"
 #include "jvm.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #include "nativehelper/jni_macros.h"
 #include "unicode/uchar.h"
 #include "unicode/uscript.h"
diff --git a/ojluni/src/main/native/Console_md.c b/ojluni/src/main/native/Console_md.c
index 73b4a97..13437be 100644
--- a/ojluni/src/main/native/Console_md.c
+++ b/ojluni/src/main/native/Console_md.c
@@ -31,7 +31,7 @@
 #include <unistd.h>
 #include <termios.h>
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_java_io_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/DatagramChannelImpl.c b/ojluni/src/main/native/DatagramChannelImpl.c
index 10d7170..925064f 100644
--- a/ojluni/src/main/native/DatagramChannelImpl.c
+++ b/ojluni/src/main/native/DatagramChannelImpl.c
@@ -45,7 +45,7 @@
 #include "nio_util.h"
 
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_sun_nio_ch_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/DatagramDispatcher.c b/ojluni/src/main/native/DatagramDispatcher.c
index 3143baf..36cc6cf 100644
--- a/ojluni/src/main/native/DatagramDispatcher.c
+++ b/ojluni/src/main/native/DatagramDispatcher.c
@@ -42,7 +42,7 @@
 #include <limits.h>
 
 #include "nio.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_sun_nio_ch_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/Double.c b/ojluni/src/main/native/Double.c
index 942f8c8..8382b88 100644
--- a/ojluni/src/main/native/Double.c
+++ b/ojluni/src/main/native/Double.c
@@ -28,7 +28,7 @@
 #include "jlong.h"
 #include "jvm.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/FileChannelImpl.c b/ojluni/src/main/native/FileChannelImpl.c
index 692a64c..5b428e9 100644
--- a/ojluni/src/main/native/FileChannelImpl.c
+++ b/ojluni/src/main/native/FileChannelImpl.c
@@ -35,7 +35,7 @@
 #include "nio.h"
 #include "nio_util.h"
 #include <dlfcn.h>
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/FileDescriptor_md.c b/ojluni/src/main/native/FileDescriptor_md.c
index 17e63aa..0404263 100644
--- a/ojluni/src/main/native/FileDescriptor_md.c
+++ b/ojluni/src/main/native/FileDescriptor_md.c
@@ -29,7 +29,7 @@
 #include "jni_util.h"
 #include "jvm.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/FileDispatcherImpl.c b/ojluni/src/main/native/FileDispatcherImpl.c
index a723bfb..5a49a60 100644
--- a/ojluni/src/main/native/FileDispatcherImpl.c
+++ b/ojluni/src/main/native/FileDispatcherImpl.c
@@ -40,7 +40,7 @@
 #endif
 #include "nio.h"
 #include "nio_util.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/FileInputStream.c b/ojluni/src/main/native/FileInputStream.c
index a5a54f5..2418c5d 100644
--- a/ojluni/src/main/native/FileInputStream.c
+++ b/ojluni/src/main/native/FileInputStream.c
@@ -41,7 +41,7 @@
 #include <limits.h>
 
 #include "io_util_md.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/FileKey.c b/ojluni/src/main/native/FileKey.c
index 99df82c..b28fb56 100644
--- a/ojluni/src/main/native/FileKey.c
+++ b/ojluni/src/main/native/FileKey.c
@@ -28,7 +28,7 @@
 #include "jvm.h"
 #include "nio.h"
 #include "nio_util.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/FileOutputStream_md.c b/ojluni/src/main/native/FileOutputStream_md.c
index 615627a..73218d4 100644
--- a/ojluni/src/main/native/FileOutputStream_md.c
+++ b/ojluni/src/main/native/FileOutputStream_md.c
@@ -31,7 +31,7 @@
 #include "io_util_md.h"
 
 #include <fcntl.h>
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/FileSystemPreferences.c b/ojluni/src/main/native/FileSystemPreferences.c
index 9f35dd5..8ab516a 100644
--- a/ojluni/src/main/native/FileSystemPreferences.c
+++ b/ojluni/src/main/native/FileSystemPreferences.c
@@ -35,7 +35,7 @@
 #include <utime.h>
 #include "jni_util.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_java_util_prefs_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/Float.c b/ojluni/src/main/native/Float.c
index 398914a..956048d 100644
--- a/ojluni/src/main/native/Float.c
+++ b/ojluni/src/main/native/Float.c
@@ -26,7 +26,7 @@
 #include "jni.h"
 #include "jvm.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/IOUtil.c b/ojluni/src/main/native/IOUtil.c
index 390c0e6..05949da 100644
--- a/ojluni/src/main/native/IOUtil.c
+++ b/ojluni/src/main/native/IOUtil.c
@@ -34,7 +34,7 @@
 #include "java_lang_Integer.h"
 #include "nio.h"
 #include "nio_util.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 
 #define NATIVE_METHOD(className, functionName, signature) \
diff --git a/ojluni/src/main/native/Inet4Address.c b/ojluni/src/main/native/Inet4Address.c
index 5c7df40..bccbe18 100644
--- a/ojluni/src/main/native/Inet4Address.c
+++ b/ojluni/src/main/native/Inet4Address.c
@@ -26,7 +26,7 @@
 #include <string.h>
 
 #include "net_util.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/Inet6Address.c b/ojluni/src/main/native/Inet6Address.c
index 6f0ac57..13c38ce 100644
--- a/ojluni/src/main/native/Inet6Address.c
+++ b/ojluni/src/main/native/Inet6Address.c
@@ -26,7 +26,7 @@
 #include <string.h>
 
 #include "net_util.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/InetAddress.c b/ojluni/src/main/native/InetAddress.c
index 0f0fefe..6260836 100644
--- a/ojluni/src/main/native/InetAddress.c
+++ b/ojluni/src/main/native/InetAddress.c
@@ -26,7 +26,7 @@
 #include <string.h>
 
 #include "net_util.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/MappedByteBuffer.c b/ojluni/src/main/native/MappedByteBuffer.c
index 3dbb96e..a5b0b04 100644
--- a/ojluni/src/main/native/MappedByteBuffer.c
+++ b/ojluni/src/main/native/MappedByteBuffer.c
@@ -31,7 +31,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_java_nio_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/Math.c b/ojluni/src/main/native/Math.c
index c5482ba..3191ade 100644
--- a/ojluni/src/main/native/Math.c
+++ b/ojluni/src/main/native/Math.c
@@ -19,7 +19,7 @@
  */
 
 #include "jni.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #include "nativehelper/jni_macros.h"
 
 #include <stdlib.h>
diff --git a/ojluni/src/main/native/NativeThread.c b/ojluni/src/main/native/NativeThread.c
index 9147bc3..3a1c5c1 100644
--- a/ojluni/src/main/native/NativeThread.c
+++ b/ojluni/src/main/native/NativeThread.c
@@ -30,7 +30,7 @@
 #include "jvm.h"
 #include "jlong.h"
 #include "nio_util.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #ifdef __linux__
   #include <pthread.h>
diff --git a/ojluni/src/main/native/Net.c b/ojluni/src/main/native/Net.c
index e2962e6..01ea3f2 100644
--- a/ojluni/src/main/native/Net.c
+++ b/ojluni/src/main/native/Net.c
@@ -55,7 +55,7 @@
   #endif
 #endif
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_sun_nio_ch_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/ObjectInputStream.c b/ojluni/src/main/native/ObjectInputStream.c
index 95eeec4..6f65dca 100644
--- a/ojluni/src/main/native/ObjectInputStream.c
+++ b/ojluni/src/main/native/ObjectInputStream.c
@@ -28,7 +28,7 @@
 #include "jni_util.h"
 #include "jlong.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_java_io_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/ObjectOutputStream.c b/ojluni/src/main/native/ObjectOutputStream.c
index 25ee3bf..169a83f 100644
--- a/ojluni/src/main/native/ObjectOutputStream.c
+++ b/ojluni/src/main/native/ObjectOutputStream.c
@@ -28,7 +28,7 @@
 #include "jni_util.h"
 #include "jlong.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_java_io_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/ObjectStreamClass.c b/ojluni/src/main/native/ObjectStreamClass.c
index fc33fb7..95cd4f0 100644
--- a/ojluni/src/main/native/ObjectStreamClass.c
+++ b/ojluni/src/main/native/ObjectStreamClass.c
@@ -26,7 +26,7 @@
 #include "jni.h"
 #include "jvm.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/ProcessEnvironment_md.c b/ojluni/src/main/native/ProcessEnvironment_md.c
index 65003db..a59410b 100644
--- a/ojluni/src/main/native/ProcessEnvironment_md.c
+++ b/ojluni/src/main/native/ProcessEnvironment_md.c
@@ -32,7 +32,7 @@
 #include <crt_externs.h>
 #define environ (*_NSGetEnviron())
 #endif
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/Register.cpp b/ojluni/src/main/native/Register.cpp
index 588eedb..15ac1e4 100644
--- a/ojluni/src/main/native/Register.cpp
+++ b/ojluni/src/main/native/Register.cpp
@@ -29,8 +29,8 @@
 
 #include <log/log.h>
 
-#include "JniConstants.h"
-#include "ScopedLocalFrame.h"
+#include <nativehelper/JniConstants.h>
+#include <nativehelper/ScopedLocalFrame.h>
 
 extern "C" {
 
diff --git a/ojluni/src/main/native/Runtime.c b/ojluni/src/main/native/Runtime.c
index 61de356..f070249 100644
--- a/ojluni/src/main/native/Runtime.c
+++ b/ojluni/src/main/native/Runtime.c
@@ -39,7 +39,7 @@
 #include "jni_util.h"
 #include "jvm.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #include "nativehelper/jni_macros.h"
 
diff --git a/ojluni/src/main/native/ServerSocketChannelImpl.c b/ojluni/src/main/native/ServerSocketChannelImpl.c
index 63dd4ea..679811f 100644
--- a/ojluni/src/main/native/ServerSocketChannelImpl.c
+++ b/ojluni/src/main/native/ServerSocketChannelImpl.c
@@ -45,7 +45,7 @@
 #include "nio.h"
 #include "nio_util.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 
 #define NATIVE_METHOD(className, functionName, signature) \
diff --git a/ojluni/src/main/native/SocketChannelImpl.c b/ojluni/src/main/native/SocketChannelImpl.c
index 8cd3b85..9429165 100644
--- a/ojluni/src/main/native/SocketChannelImpl.c
+++ b/ojluni/src/main/native/SocketChannelImpl.c
@@ -43,7 +43,7 @@
 #include "nio_util.h"
 #include "nio.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(Java_sun_nio_ch_ ## className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/SocketInputStream.c b/ojluni/src/main/native/SocketInputStream.c
index 7be77a7..dcea334 100644
--- a/ojluni/src/main/native/SocketInputStream.c
+++ b/ojluni/src/main/native/SocketInputStream.c
@@ -33,7 +33,7 @@
 #include "jni_util.h"
 #include "net_util.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/SocketOutputStream.c b/ojluni/src/main/native/SocketOutputStream.c
index 5fcc7c3..bc3522b 100644
--- a/ojluni/src/main/native/SocketOutputStream.c
+++ b/ojluni/src/main/native/SocketOutputStream.c
@@ -33,7 +33,7 @@
 #include "jvm.h"
 #include "net_util.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/StrictMath.c b/ojluni/src/main/native/StrictMath.c
index c1efc50..7f9bbeb 100644
--- a/ojluni/src/main/native/StrictMath.c
+++ b/ojluni/src/main/native/StrictMath.c
@@ -26,7 +26,7 @@
 #include "jni.h"
 #include "../../external/fdlibm/fdlibm.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/String.c b/ojluni/src/main/native/String.c
index 80dc90b..011089d 100644
--- a/ojluni/src/main/native/String.c
+++ b/ojluni/src/main/native/String.c
@@ -24,7 +24,7 @@
  */
 
 #include "jvm.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/System.c b/ojluni/src/main/native/System.c
index 22c4d52..6cfee92 100644
--- a/ojluni/src/main/native/System.c
+++ b/ojluni/src/main/native/System.c
@@ -37,7 +37,7 @@
 
 #include "openssl/opensslv.h"
 #include "zlib.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #if defined(__ANDROID__)
 void android_get_LD_LIBRARY_PATH(char*, size_t);
 #endif
diff --git a/ojluni/src/main/native/Thread.c b/ojluni/src/main/native/Thread.c
index c099288..83b448f 100644
--- a/ojluni/src/main/native/Thread.c
+++ b/ojluni/src/main/native/Thread.c
@@ -36,7 +36,7 @@
 #define OBJ "Ljava/lang/Object;"
 #define STE "Ljava/lang/StackTraceElement;"
 #define STR "Ljava/lang/String;"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define ARRAY_LENGTH(a) (sizeof(a)/sizeof(a[0]))
 
diff --git a/ojluni/src/main/native/Throwable.c b/ojluni/src/main/native/Throwable.c
index b7868e8..805c80a 100644
--- a/ojluni/src/main/native/Throwable.c
+++ b/ojluni/src/main/native/Throwable.c
@@ -35,7 +35,7 @@
 #include "jni.h"
 #include "jvm.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/UNIXProcess_md.c b/ojluni/src/main/native/UNIXProcess_md.c
index 3c03221..f944c31 100644
--- a/ojluni/src/main/native/UNIXProcess_md.c
+++ b/ojluni/src/main/native/UNIXProcess_md.c
@@ -31,7 +31,7 @@
 #include "jvm_md.h"
 #include "jni_util.h"
 #include "io_util.h"
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #define NATIVE_METHOD(className, functionName, signature) \
 { #functionName, signature, (void*)(className ## _ ## functionName) }
diff --git a/ojluni/src/main/native/UnixFileSystem_md.c b/ojluni/src/main/native/UnixFileSystem_md.c
index 61f907c..0c53f09 100644
--- a/ojluni/src/main/native/UnixFileSystem_md.c
+++ b/ojluni/src/main/native/UnixFileSystem_md.c
@@ -42,7 +42,7 @@
 #include "java_io_FileSystem.h"
 #include "java_io_UnixFileSystem.h"
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 
 #if defined(_ALLBSD_SOURCE)
 #define dirent64 dirent
diff --git a/ojluni/src/main/native/java_util_zip_CRC32.c b/ojluni/src/main/native/java_util_zip_CRC32.c
index 4c2beae..cec99de 100644
--- a/ojluni/src/main/native/java_util_zip_CRC32.c
+++ b/ojluni/src/main/native/java_util_zip_CRC32.c
@@ -27,7 +27,7 @@
  * Native method support for java.util.zip.CRC32
  */
 
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #include "jni.h"
 #include "jni_util.h"
 #include <zlib.h>
diff --git a/ojluni/src/main/native/java_util_zip_Deflater.c b/ojluni/src/main/native/java_util_zip_Deflater.c
index 8834171..9ee0326 100644
--- a/ojluni/src/main/native/java_util_zip_Deflater.c
+++ b/ojluni/src/main/native/java_util_zip_Deflater.c
@@ -29,7 +29,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #include "jlong.h"
 #include "jni.h"
 #include "jni_util.h"
diff --git a/ojluni/src/main/native/java_util_zip_Inflater.c b/ojluni/src/main/native/java_util_zip_Inflater.c
index 16241f5..c4c24f0 100644
--- a/ojluni/src/main/native/java_util_zip_Inflater.c
+++ b/ojluni/src/main/native/java_util_zip_Inflater.c
@@ -31,7 +31,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #include "jlong.h"
 #include "jni.h"
 #include "jvm.h"
diff --git a/ojluni/src/main/native/java_util_zip_ZipFile.c b/ojluni/src/main/native/java_util_zip_ZipFile.c
index d9d7a51..8444c42 100644
--- a/ojluni/src/main/native/java_util_zip_ZipFile.c
+++ b/ojluni/src/main/native/java_util_zip_ZipFile.c
@@ -33,7 +33,7 @@
 #include <errno.h>
 #include <ctype.h>
 #include <assert.h>
-#include "JNIHelp.h"
+#include <nativehelper/JNIHelp.h>
 #include "jlong.h"
 #include "jvm.h"
 #include "jni.h"
diff --git a/ojluni/src/main/native/linux_close.cpp b/ojluni/src/main/native/linux_close.cpp
index 6f88c93..e100035 100644
--- a/ojluni/src/main/native/linux_close.cpp
+++ b/ojluni/src/main/native/linux_close.cpp
@@ -38,7 +38,7 @@
 #include <sys/poll.h>
 
 
-#include "AsynchronousCloseMonitor.h"
+#include <nativehelper/AsynchronousCloseMonitor.h>
 
 extern "C" {
 
diff --git a/ojluni/src/main/native/socket_tagger_util.cpp b/ojluni/src/main/native/socket_tagger_util.cpp
index b03d0aa..611b92e 100644
--- a/ojluni/src/main/native/socket_tagger_util.cpp
+++ b/ojluni/src/main/native/socket_tagger_util.cpp
@@ -18,8 +18,8 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "JNIHelp.h"
-#include "JniConstants.h"
+#include <nativehelper/JNIHelp.h>
+#include <nativehelper/JniConstants.h>
 
 extern "C" {
 
diff --git a/ojluni/src/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java b/ojluni/src/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java
index 27c0575..36c3e51 100644
--- a/ojluni/src/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java
+++ b/ojluni/src/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java
@@ -72,6 +72,7 @@
 import java.util.Date;
 import java.util.Locale;
 
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
@@ -82,6 +83,21 @@
 @Test
 public class TCKLocalizedPrinterParser {
 
+    // BEGIN Android-added: Clear DateFormat.is24Hour during test run (http://b/62651881).
+    private Boolean originalIs24Hour;
+
+    @BeforeMethod
+    public void clearIs24Hour() {
+        originalIs24Hour = DateFormat.is24Hour;
+        DateFormat.set24HourTimePref(null);
+    }
+
+    @AfterMethod
+    public void resetIs24Hour() {
+        DateFormat.set24HourTimePref(originalIs24Hour);
+    }
+    // END Android-added: Clear DateFormat.is24Hour during test run (http://b/62651881).
+
     private DateTimeFormatterBuilder builder;
     private ParsePosition pos;
 
diff --git a/tzdata/prototype_updater/Android.mk b/tzdata/prototype_updater/Android.mk
deleted file mode 100644
index 0ddaa45..0000000
--- a/tzdata/prototype_updater/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := optional
-LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_PACKAGE_NAME := PrototypeTimeZoneUpdaterApp
-LOCAL_CERTIFICATE := platform
-LOCAL_PRIVILEGED_MODULE := true
-include $(BUILD_PACKAGE)
diff --git a/tzdata/prototype_updater/AndroidManifest.xml b/tzdata/prototype_updater/AndroidManifest.xml
deleted file mode 100644
index 9b73b0b..0000000
--- a/tzdata/prototype_updater/AndroidManifest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="libcore.tzdata.prototype_updater"
-    android:versionCode="1">
-
-    <uses-permission android:name="android.permission.UPDATE_TIME_ZONE_RULES" />
-
-    <application
-        android:allowBackup="false"
-        android:label="@string/app_name">
-
-        <receiver android:name=".RulesCheckReceiver"
-                android:permission="android.permission.TRIGGER_TIME_ZONE_RULES_CHECK"
-                android:exported="true">
-            <intent-filter>
-                <action android:name="android.intent.action.timezone.TRIGGER_RULES_UPDATE_CHECK" />
-            </intent-filter>
-        </receiver>
-
-    </application>
-
-</manifest>
diff --git a/tzdata/prototype_updater/res/values/strings.xml b/tzdata/prototype_updater/res/values/strings.xml
deleted file mode 100644
index 204ae27..0000000
--- a/tzdata/prototype_updater/res/values/strings.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- -->
-
-<resources>
-    <string name="app_name">PrototypeUpdaterApp</string>
-</resources>
diff --git a/tzdata/prototype_updater/src/libcore/tzdata/prototype_updater/RulesCheckReceiver.java b/tzdata/prototype_updater/src/libcore/tzdata/prototype_updater/RulesCheckReceiver.java
deleted file mode 100644
index 51f454e..0000000
--- a/tzdata/prototype_updater/src/libcore/tzdata/prototype_updater/RulesCheckReceiver.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package libcore.tzdata.prototype_updater;
-
-import android.app.timezone.Callback;
-import android.app.timezone.DistroFormatVersion;
-import android.app.timezone.DistroRulesVersion;
-import android.app.timezone.RulesManager;
-import android.app.timezone.RulesState;
-import android.app.timezone.RulesUpdaterContract;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.os.ParcelFileDescriptor;
-import android.provider.TimeZoneRulesDataContract;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import libcore.io.Streams;
-
-// TODO(nfuller): Prevent multiple broadcasts being handled at once?
-// TODO(nfuller): Improve logging
-// TODO(nfuller): Make the rules check async?
-// TODO(nfuller): Need async generally for SystemService calls from BroadcastReceiver?
-public class RulesCheckReceiver extends BroadcastReceiver {
-    final static String TAG = "RulesCheckReceiver";
-
-    private RulesManager mRulesManager;
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        if (!RulesUpdaterContract.ACTION_TRIGGER_RULES_UPDATE_CHECK.equals(intent.getAction())) {
-            // Unknown. Do nothing.
-            Log.w(TAG, "Unrecognized intent action received: " + intent
-                    + ", action=" + intent.getAction());
-            return;
-        }
-
-        mRulesManager = (RulesManager) context.getSystemService("timezone");
-
-        byte[] token = intent.getByteArrayExtra(RulesUpdaterContract.EXTRA_CHECK_TOKEN);
-
-        // Note: We rely on the system server to check that the configured data application is the
-        // one that exposes the content provider with the well-known authority, and is a privileged
-        // application as required. It is *not* checked here and it is assumed the updater can trust
-        // the data application.
-
-        // Obtain the information about what the data app is telling us to do.
-        DistroOperation operation = getOperation(context);
-        if (operation == null) {
-            Log.w(TAG, "Unable to read time zone operation. Halting check.");
-            boolean success = true; // No point in retrying.
-            handleCheckComplete(token, success);
-            return;
-        }
-
-        // Try to do what the data app asked.
-        Log.d(TAG, "Time zone operation: " + operation + " received.");
-        switch (operation.mOperationString) {
-            case TimeZoneRulesDataContract.OPERATION_NO_OP:
-                // No-op. Just acknowledge the check.
-                handleCheckComplete(token, true /* success */);
-                break;
-            case TimeZoneRulesDataContract.OPERATION_UNINSTALL:
-                handleUninstall(token);
-                break;
-            case TimeZoneRulesDataContract.OPERATION_INSTALL:
-                handleCopyAndInstall(context, token, operation.mDistroFormatVersion,
-                        operation.mDistroRulesVersion);
-                break;
-            default:
-                Log.w(TAG, "Unknown time zone operation: " + operation
-                        + " received. Halting check.");
-                final boolean success = true; // No point in retrying.
-                handleCheckComplete(token, success);
-        }
-    }
-
-    private DistroOperation getOperation(Context context) {
-        Cursor c = context.getContentResolver()
-                .query(TimeZoneRulesDataContract.OPERATION_URI,
-                        new String[] {
-                                TimeZoneRulesDataContract.COLUMN_OPERATION,
-                                TimeZoneRulesDataContract.COLUMN_DISTRO_MAJOR_VERSION,
-                                TimeZoneRulesDataContract.COLUMN_DISTRO_MINOR_VERSION,
-                                TimeZoneRulesDataContract.COLUMN_RULES_VERSION,
-                                TimeZoneRulesDataContract.COLUMN_REVISION
-                        },
-                        null /* selection */, null /* selectionArgs */, null /* sortOrder */);
-        try (Cursor cursor = c) {
-            if (cursor == null) {
-                Log.e(TAG, "Query returned null");
-                return null;
-            }
-            if (!cursor.moveToFirst()) {
-                Log.e(TAG, "Query returned empty results");
-                return null;
-            }
-
-            try {
-                String operation = cursor.getString(0);
-                DistroFormatVersion distroFormatVersion = null;
-                DistroRulesVersion distroRulesVersion = null;
-                if (TimeZoneRulesDataContract.OPERATION_INSTALL.equals(operation)) {
-                    distroFormatVersion = new DistroFormatVersion(cursor.getInt(1),
-                            cursor.getInt(2));
-                    distroRulesVersion = new DistroRulesVersion(cursor.getString(3),
-                            cursor.getInt(4));
-                }
-                return new DistroOperation(operation, distroFormatVersion, distroRulesVersion);
-            } catch (Exception e) {
-                Log.e(TAG, "Error looking up distro operation / version", e);
-                return null;
-            }
-        }
-    }
-
-    private void handleCopyAndInstall(Context context, byte[] checkToken,
-            DistroFormatVersion distroFormatVersion, DistroRulesVersion distroRulesVersion) {
-        // Decide whether to proceed with the install.
-        RulesState rulesState = mRulesManager.getRulesState();
-        if (!rulesState.isDistroFormatVersionSupported(distroFormatVersion)
-            || rulesState.isSystemVersionNewerThan(distroRulesVersion)) {
-            // Nothing to do.
-            handleCheckComplete(checkToken, true /* success */);
-            return;
-        }
-
-        ParcelFileDescriptor inputFileDescriptor = getDistroParcelFileDescriptor(context);
-        if (inputFileDescriptor == null) {
-            Log.e(TAG, "No local file created for distro. Halting.");
-            return;
-        }
-
-        // Copying the ParcelFileDescriptor to a local file proves we can read it before passing it
-        // on to the next stage. It also ensures that we have a hermetic copy of the data we know
-        // the originating content provider cannot modify unexpectedly. If the next stage wants to
-        // "seek" the ParcelFileDescriptor it can do so with fewer processes affected.
-        File file = copyDataToLocalFile(context, inputFileDescriptor);
-        if (file == null) {
-            // It's possible this may get better if the problem is related to storage space so we
-            // signal success := false so it may be retried.
-            boolean success = false;
-            handleCheckComplete(checkToken, success);
-            return;
-        }
-        handleInstall(checkToken, file);
-    }
-
-    private static ParcelFileDescriptor getDistroParcelFileDescriptor(Context context) {
-        ParcelFileDescriptor inputFileDescriptor;
-        try {
-            inputFileDescriptor = context.getContentResolver().openFileDescriptor(
-                    TimeZoneRulesDataContract.DATA_URI, "r");
-            if (inputFileDescriptor == null) {
-                throw new FileNotFoundException("ContentProvider returned null");
-            }
-        } catch (FileNotFoundException e) {
-            Log.e(TAG, "Unable to open file descriptor" + TimeZoneRulesDataContract.DATA_URI, e);
-            return null;
-        }
-        return inputFileDescriptor;
-    }
-
-    private static File copyDataToLocalFile(
-            Context context, ParcelFileDescriptor inputFileDescriptor) {
-
-        // Adopt the ParcelFileDescriptor into a try-with-resources so we will close it when we're
-        // done regardless of the outcome.
-        try (ParcelFileDescriptor pfd = inputFileDescriptor) {
-            File localFile;
-            try {
-                localFile = File.createTempFile("temp", ".zip", context.getFilesDir());
-            } catch (IOException e) {
-                Log.e(TAG, "Unable to create local storage file", e);
-                return null;
-            }
-
-            InputStream fis = new FileInputStream(pfd.getFileDescriptor(), false /* isFdOwner */);
-            try (FileOutputStream fos = new FileOutputStream(localFile, false /* append */)) {
-                Streams.copy(fis, fos);
-            } catch (IOException e) {
-                Log.e(TAG, "Unable to create asset storage file: " + localFile, e);
-                return null;
-            }
-            return localFile;
-        } catch (IOException e) {
-            Log.e(TAG, "Unable to close ParcelFileDescriptor", e);
-            return null;
-        }
-    }
-
-    private void handleInstall(final byte[] checkToken, final File localFile) {
-        // Create a ParcelFileDescriptor pointing to localFile.
-        final ParcelFileDescriptor distroFileDescriptor;
-        try {
-            distroFileDescriptor =
-                    ParcelFileDescriptor.open(localFile, ParcelFileDescriptor.MODE_READ_ONLY);
-        } catch (FileNotFoundException e) {
-            Log.e(TAG, "Unable to create ParcelFileDescriptor from " + localFile);
-            handleCheckComplete(checkToken, false /* success */);
-            return;
-        } finally {
-            // It is safe to delete the File at this point. The ParcelFileDescriptor has an open
-            // file descriptor to it if we are successful, or it is not going to be used if we are
-            // returning early.
-            localFile.delete();
-        }
-
-        Callback callback = new Callback() {
-            @Override
-            public void onFinished(int status) {
-                Log.i(TAG, "Finished install: " + status);
-            }
-        };
-
-        // Adopt the distroFileDescriptor here so the local file descriptor is closed, whatever the
-        // outcome.
-        try (ParcelFileDescriptor pfd = distroFileDescriptor) {
-            int requestStatus = mRulesManager.requestInstall(pfd, checkToken, callback);
-            Log.i(TAG, "requestInstall() called, token=" + Arrays.toString(checkToken)
-                    + ", returned " + requestStatus);
-        } catch (Exception e) {
-            Log.e(TAG, "Error calling requestInstall()", e);
-        }
-    }
-
-    private void handleUninstall(byte[] checkToken) {
-        Callback callback = new Callback() {
-            @Override
-            public void onFinished(int status) {
-                Log.i(TAG, "Finished uninstall: " + status);
-            }
-        };
-
-        try {
-            int requestStatus = mRulesManager.requestUninstall(checkToken, callback);
-            Log.i(TAG, "requestUninstall() called, token=" + Arrays.toString(checkToken)
-                    + ", returned " + requestStatus);
-        } catch (Exception e) {
-            Log.e(TAG, "Error calling requestUninstall()", e);
-        }
-    }
-
-    private void handleCheckComplete(final byte[] token, final boolean success) {
-        try {
-            mRulesManager.requestNothing(token, success);
-            Log.i(TAG, "requestNothing() called, token=" + Arrays.toString(token)
-                    + ", success=" + success);
-        } catch (Exception e) {
-            Log.e(TAG, "Error calling requestNothing()", e);
-        }
-    }
-
-    private static class DistroOperation {
-        final String mOperationString;
-        final DistroFormatVersion mDistroFormatVersion;
-        final DistroRulesVersion mDistroRulesVersion;
-
-        DistroOperation(String operationString, DistroFormatVersion distroFormatVersion,
-                DistroRulesVersion distroRulesVersion) {
-            mOperationString = operationString;
-            mDistroFormatVersion = distroFormatVersion;
-            mDistroRulesVersion = distroRulesVersion;
-        }
-
-        @Override
-        public String toString() {
-            return "DistroOperation{" +
-                    "mOperationString='" + mOperationString + '\'' +
-                    ", mDistroFormatVersion=" + mDistroFormatVersion +
-                    ", mDistroRulesVersion=" + mDistroRulesVersion +
-                    '}';
-        }
-    }
-}
diff --git a/tzdata/update_test_app2/Android.mk b/tzdata/update_test_app2/Android.mk
deleted file mode 100644
index c1ae636..0000000
--- a/tzdata/update_test_app2/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_PACKAGE_NAME := UpdateTestApp2
-LOCAL_CERTIFICATE := platform
-include $(BUILD_PACKAGE)
diff --git a/tzdata/update_test_app2/AndroidManifest.xml b/tzdata/update_test_app2/AndroidManifest.xml
deleted file mode 100644
index fd42bb5..0000000
--- a/tzdata/update_test_app2/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="libcore.tzdata.update_test_app2.installupdatetestapp" >
-
-    <uses-permission android:name="android.permission.UPDATE_TIME_ZONE_RULES" />
-
-    <application
-        android:allowBackup="false"
-        android:icon="@drawable/ic_launcher"
-        android:label="@string/app_name"
-        android:theme="@android:style/Theme.Holo.Light">
-        <activity
-            android:name=".MainActivity"
-            android:label="@string/app_name" >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-    </application>
-
-</manifest>
diff --git a/tzdata/update_test_app2/res/drawable/ic_launcher.png b/tzdata/update_test_app2/res/drawable/ic_launcher.png
deleted file mode 100644
index 96a442e..0000000
--- a/tzdata/update_test_app2/res/drawable/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/tzdata/update_test_app2/res/layout/activity_main.xml b/tzdata/update_test_app2/res/layout/activity_main.xml
deleted file mode 100644
index 16e4b11..0000000
--- a/tzdata/update_test_app2/res/layout/activity_main.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical"
-    tools:context=".MainActivity">
-
-    <LinearLayout
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/content_path"
-            android:id="@+id/content_path_label" />
-
-        <EditText
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/default_content_path"
-            android:id="@+id/content_path" />
-
-    </LinearLayout>
-
-    <Button
-        android:id="@+id/trigger_install_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_centerHorizontal="true"
-        android:layout_centerVertical="true"
-        android:text="@string/trigger_install" />
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="2dip"
-            android:background="#FF00FF00" />
-
-    <Button
-        android:id="@+id/trigger_uninstall_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_centerHorizontal="true"
-        android:layout_centerVertical="true"
-        android:text="@string/trigger_uninstall" />
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="2dip"
-            android:background="#FF00FF00" />
-
-    <CheckBox android:id="@+id/success_checkbox"
-              android:layout_width="wrap_content"
-              android:layout_height="wrap_content"
-              android:text="@string/success" />
-
-    <Button
-        android:id="@+id/trigger_nothing"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_centerHorizontal="true"
-        android:layout_centerVertical="true"
-        android:text="@string/trigger_nothing" />
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="2dip"
-            android:background="#FF00FF00" />
-
-    <Button
-        android:id="@+id/get_rules_state_button"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_centerHorizontal="true"
-        android:layout_centerVertical="true"
-        android:text="@string/get_rules_state" />
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="2dip"
-            android:background="#FF00FF00" />
-
-    <ScrollView
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:scrollbars="vertical"
-            android:fillViewport="true">
-
-        <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="fill_parent"
-                android:id="@+id/log"
-                android:singleLine="false" />
-
-    </ScrollView>
-
-</LinearLayout>
diff --git a/tzdata/update_test_app2/res/values/strings.xml b/tzdata/update_test_app2/res/values/strings.xml
deleted file mode 100644
index 9bb5f57..0000000
--- a/tzdata/update_test_app2/res/values/strings.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-    <string name="app_name">InstallUpdateTestApp2</string>
-    <string name="content_path">Content Path</string>
-    <string name="default_content_path">/data/local/tmp/out.zip</string>
-    <string name="trigger_install">Request Install</string>
-    <string name="trigger_uninstall">Request Uninstall</string>
-    <string name="trigger_nothing">Request Nothing</string>
-    <string name="success">Success</string>
-    <string name="get_rules_state">Get rules state</string>
-</resources>
diff --git a/tzdata/update_test_app2/src/libcore/tzdata/update_test_app2/installupdatetestapp/MainActivity.java b/tzdata/update_test_app2/src/libcore/tzdata/update_test_app2/installupdatetestapp/MainActivity.java
deleted file mode 100644
index caa52c4..0000000
--- a/tzdata/update_test_app2/src/libcore/tzdata/update_test_app2/installupdatetestapp/MainActivity.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package libcore.tzdata.update_test_app2.installupdatetestapp;
-
-import android.app.Activity;
-import android.app.timezone.Callback;
-import android.app.timezone.RulesManager;
-import android.app.timezone.RulesState;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.os.ParcelFileDescriptor;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Date;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class MainActivity extends Activity implements View.OnClickListener {
-
-    private EditText contentPathEditText;
-    private TextView logView;
-
-    private RulesManager rulesManager;
-    private Callback callback;
-    private ExecutorService executor;
-    private CheckBox successCheckbox;
-
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_main);
-        Button triggerInstallButton = (Button) findViewById(R.id.trigger_install_button);
-        triggerInstallButton.setOnClickListener(this);
-        Button triggerUninstallButton = (Button) findViewById(R.id.trigger_uninstall_button);
-        triggerUninstallButton.setOnClickListener(this);
-        Button triggerCheckCompleteButton = (Button) findViewById(R.id.trigger_nothing);
-        triggerCheckCompleteButton.setOnClickListener(this);
-        successCheckbox = (CheckBox) findViewById(R.id.success_checkbox);
-
-        Button getRulesStateButton = (Button) findViewById(R.id.get_rules_state_button);
-        getRulesStateButton.setOnClickListener(this);
-
-        contentPathEditText = (EditText) findViewById(R.id.content_path);
-        logView = (TextView) findViewById(R.id.log);
-        executor = Executors.newFixedThreadPool(1);
-        rulesManager = (RulesManager) getSystemService("timezone");
-        callback = new Callback() {
-            @Override
-            public void onFinished(int status) {
-                logString("Operation finished. Status=" + status);
-            }
-        };
-    }
-
-    private abstract class MyAsyncTask extends AsyncTask<Void, String, Void> {
-        @Override
-        protected void onProgressUpdate(String... values) {
-            for (String message : values) {
-                addToLog(message, null);
-            }
-        }
-    }
-
-    @Override
-    public void onClick(View v) {
-        MyAsyncTask task;
-        if (v.getId() == R.id.trigger_install_button) {
-            final String contentPath = contentPathEditText.getText().toString();
-            final File contentFile = new File(contentPath);
-
-            // Convert the contentFile to a ParcelFileDescriptor.
-            final ParcelFileDescriptor distroFileDescriptor =
-                    createParcelFileDescriptor(contentFile);
-            if (distroFileDescriptor == null) {
-                return;
-            }
-
-            Callback callback = new Callback() {
-                @Override
-                public void onFinished(int status) {
-                    logString("onFinished: Finished install: " + status);
-
-                    // TODO(nfuller): Can this be closed sooner?
-                    try {
-                        distroFileDescriptor.close();
-                    } catch (IOException e) {
-                        logString("Unable to close ParcelFileDescriptor for " + contentFile + ": "
-                                + exceptionToString(e));
-                    }
-                }
-            };
-
-            task = new MyAsyncTask() {
-                @Override
-                protected Void doInBackground(Void... params) {
-                    if (!contentFile.exists()) {
-                        publishProgress("Error: " +  contentFile + " does not exist.");
-                        return null;
-                    }
-                    try {
-                        int requestStatus = rulesManager.requestInstall(
-                                distroFileDescriptor, null /* checkToken */, callback);
-                        publishProgress("Request sent:" + requestStatus);
-                    } catch (Exception e) {
-                        publishProgress("Error", exceptionToString(e));
-                    }
-                    return null;
-               }
-            };
-        } else if (v.getId() == R.id.trigger_uninstall_button) {
-            task = new MyAsyncTask() {
-                @Override
-                protected Void doInBackground(Void... params) {
-                    try {
-                        int requestStatus = rulesManager.requestUninstall(
-                                null /* checkToken */, callback);
-                        publishProgress("Request sent:" + requestStatus);
-                    } catch (Exception e) {
-                        publishProgress("Error", exceptionToString(e));
-                    }
-                    return null;
-                }
-            };
-        } else if (v.getId() == R.id.trigger_nothing) {
-            final boolean success = successCheckbox.isChecked();
-            task = new MyAsyncTask() {
-                @Override
-                protected Void doInBackground(Void... params) {
-                    try {
-                        rulesManager.requestNothing(null /* checkToken */, success);
-                        publishProgress("Request sent");
-                    } catch (Exception e) {
-                        publishProgress("Error", exceptionToString(e));
-                    }
-                    return null;
-                }
-            };
-        } else if (v.getId() == R.id.get_rules_state_button) {
-            task = new MyAsyncTask() {
-                @Override
-                protected Void doInBackground(Void... params) {
-                    try {
-                        RulesState rulesState = rulesManager.getRulesState();
-                        publishProgress("Rules state: " + rulesState);
-                    } catch (Exception e) {
-                        publishProgress("Error", exceptionToString(e));
-                    }
-                    return null;
-                }
-            };
-        } else {
-            addToLog("Unknown button", null);
-            return;
-        }
-        task.executeOnExecutor(executor);
-    }
-
-    private ParcelFileDescriptor createParcelFileDescriptor(File contentFile) {
-        try {
-            return ParcelFileDescriptor.open(contentFile, ParcelFileDescriptor.MODE_READ_ONLY);
-        } catch (FileNotFoundException e) {
-            logString("Unable to create ParcelFileDescriptor from " + contentFile + ": "
-                    + exceptionToString(e));
-            return null;
-        }
-    }
-
-    private void addToLog(String message, Exception e) {
-        logString(message);
-        if (e != null) {
-            String text = exceptionToString(e);
-            logString(text);
-        }
-    }
-
-    private void logString(String value) {
-        logView.append(new Date() + " " + value + "\n");
-        int scrollAmount =
-                logView.getLayout().getLineTop(logView.getLineCount()) - logView.getHeight();
-        logView.scrollTo(0, scrollAmount);
-    }
-
-    private static String exceptionToString(Exception e) {
-        StringWriter writer = new StringWriter();
-        e.printStackTrace(new PrintWriter(writer));
-        return writer.getBuffer().toString();
-    }
-}