Merge "Mark VMRuntime is64bit as stable"
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 0da4c80..2d275e2 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -425,12 +425,13 @@
     name: "core-test-rules",
     visibility: [
         "//art/build/sdk",
+        "//cts/tests/tests/util",
         "//external/conscrypt",
         "//external/conscrypt/apex/tests",
         "//frameworks/base/location/tests/locationtests",
         "//frameworks/base/core/tests/coretests",
         "//frameworks/base/wifi/tests",
-        "//cts/tests/tests/util",
+        "//packages/modules/Wifi/framework/tests",
     ],
     hostdex: true,
     srcs: [
@@ -823,6 +824,7 @@
     visibility: [
         "//art/build/sdk",
         "//frameworks/base",
+        "//frameworks/base/api",
     ],
     srcs: [
         ":core_oj_api_files",
@@ -844,6 +846,7 @@
     api_only: true,
     droiddoc_options: [
         rewrite_openjdk_doc_args,
+        "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.* ",
     ],
 
     // Emit nullability annotations from the source to the stub files.
@@ -866,9 +869,12 @@
     patch_module: "java.base",
     sdk_version: "none",
     system_modules: "java-current-stubs-system-modules",
-
-    // Don't copy any output files to the dist.
-    no_dist: true,
+    // The base name for the artifacts that are automatically published to the
+    // dist and which end up in one of the sub-directories of prebuilts/sdk.
+    // As long as this matches the name of the artifacts in prebuilts/sdk then
+    // the API will be checked for compatibility against the latest released
+    // version of the API.
+    dist_stem: "art",
 }
 
 // Used when compiling higher-level code against art.module.public.api.stubs.
diff --git a/NativeCode.bp b/NativeCode.bp
index 1ac607a..c93e214 100644
--- a/NativeCode.bp
+++ b/NativeCode.bp
@@ -60,7 +60,6 @@
     ],
     srcs: [
         ":luni_native_srcs",
-        "dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp",
     ],
     shared_libs: [
         "libandroidio",
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 8c0baae..f399594 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,5 +1,5 @@
 {
-  "presubmit": [
+  "presubmit-large": [
     {
       "name": "CtsLibcoreTestCases",
       "options": [
diff --git a/api/current.txt b/api/current.txt
index 41dcf35..523b048 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -2266,10 +2266,11 @@
   }
 
   public final class Byte extends java.lang.Number implements java.lang.Comparable<java.lang.Byte> {
-    ctor public Byte(byte);
-    ctor public Byte(@NonNull String) throws java.lang.NumberFormatException;
+    ctor @Deprecated public Byte(byte);
+    ctor @Deprecated public Byte(@NonNull String) throws java.lang.NumberFormatException;
     method public static int compare(byte, byte);
     method public int compareTo(@NonNull Byte);
+    method public static int compareUnsigned(byte, byte);
     method @NonNull public static Byte decode(@NonNull String) throws java.lang.NumberFormatException;
     method public double doubleValue();
     method public float floatValue();
@@ -2834,6 +2835,7 @@
     method public int getModifiers();
     method @NonNull public String getName();
     method @Nullable public Package getPackage();
+    method @NonNull public String getPackageName();
     method @Nullable public java.security.ProtectionDomain getProtectionDomain();
     method @Nullable public java.net.URL getResource(@NonNull String);
     method @Nullable public java.io.InputStream getResourceAsStream(@NonNull String);
@@ -2933,7 +2935,9 @@
     method public static void enable();
   }
 
-  @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target({java.lang.annotation.ElementType.CONSTRUCTOR, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.LOCAL_VARIABLE, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PACKAGE, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE}) public @interface Deprecated {
+  @Deprecated @java.lang.annotation.Documented @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target({java.lang.annotation.ElementType.CONSTRUCTOR, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.LOCAL_VARIABLE, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PACKAGE, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE}) public @interface Deprecated {
+    method @Deprecated public abstract boolean forRemoval() default false;
+    method @Deprecated public abstract String since() default "";
   }
 
   public final class Double extends java.lang.Number implements java.lang.Comparable<java.lang.Double> {
@@ -3585,10 +3589,11 @@
   }
 
   public final class Short extends java.lang.Number implements java.lang.Comparable<java.lang.Short> {
-    ctor public Short(short);
-    ctor public Short(String) throws java.lang.NumberFormatException;
+    ctor @Deprecated public Short(short);
+    ctor @Deprecated public Short(String) throws java.lang.NumberFormatException;
     method public static int compare(short, short);
     method public int compareTo(Short);
+    method public static int compareUnsigned(short, short);
     method public static Short decode(String) throws java.lang.NumberFormatException;
     method public double doubleValue();
     method public float floatValue();
diff --git a/benchmarks/src/benchmarks/regression/NativeMethodBenchmark.java b/benchmarks/src/benchmarks/regression/NativeMethodBenchmark.java
deleted file mode 100644
index dbb6308..0000000
--- a/benchmarks/src/benchmarks/regression/NativeMethodBenchmark.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc.
- *
- * 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 benchmarks.regression;
-
-import org.apache.harmony.dalvik.NativeTestTarget;
-
-public class NativeMethodBenchmark {
-    public void time_emptyJniStaticSynchronizedMethod0(int reps) throws Exception {
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticSynchronizedMethod0();
-        }
-    }
-
-    public void time_emptyJniSynchronizedMethod0(int reps) throws Exception {
-        NativeTestTarget n = new NativeTestTarget();
-        for (int i = 0; i < reps; ++i) {
-            n.emptyJniSynchronizedMethod0();
-        }
-    }
-
-
-    public void time_emptyJniMethod0(int reps) throws Exception {
-        NativeTestTarget n = new NativeTestTarget();
-        for (int i = 0; i < reps; ++i) {
-            n.emptyJniMethod0();
-        }
-    }
-
-    public void time_emptyJniMethod6(int reps) throws Exception {
-        int a = -1;
-        int b = 0;
-        NativeTestTarget n = new NativeTestTarget();
-        for (int i = 0; i < reps; ++i) {
-            n.emptyJniMethod6(a, b, 1, 2, 3, i);
-        }
-    }
-
-    public void time_emptyJniMethod6L(int reps) throws Exception {
-        NativeTestTarget n = new NativeTestTarget();
-        for (int i = 0; i < reps; ++i) {
-            n.emptyJniMethod6L(null, null, null, null, null, null);
-        }
-    }
-
-    public void time_emptyJniStaticMethod6L(int reps) throws Exception {
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod6L(null, null, null, null, null, null);
-        }
-    }
-    public void time_emptyJniStaticMethod0(int reps) throws Exception {
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod0();
-        }
-    }
-
-    public void time_emptyJniStaticMethod6(int reps) throws Exception {
-        int a = -1;
-        int b = 0;
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod6(a, b, 1, 2, 3, i);
-        }
-    }
-
-    public void time_emptyJniMethod0_Fast(int reps) throws Exception {
-        NativeTestTarget n = new NativeTestTarget();
-        for (int i = 0; i < reps; ++i) {
-            n.emptyJniMethod0_Fast();
-        }
-    }
-
-    public void time_emptyJniMethod6_Fast(int reps) throws Exception {
-        int a = -1;
-        int b = 0;
-        NativeTestTarget n = new NativeTestTarget();
-        for (int i = 0; i < reps; ++i) {
-            n.emptyJniMethod6_Fast(a, b, 1, 2, 3, i);
-        }
-    }
-
-    public void time_emptyJniMethod6L_Fast(int reps) throws Exception {
-        NativeTestTarget n = new NativeTestTarget();
-        for (int i = 0; i < reps; ++i) {
-            n.emptyJniMethod6L_Fast(null, null, null, null, null, null);
-        }
-    }
-
-    public void time_emptyJniStaticMethod6L_Fast(int reps) throws Exception {
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod6L_Fast(null, null, null, null, null, null);
-        }
-    }
-    public void time_emptyJniStaticMethod0_Fast(int reps) throws Exception {
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod0_Fast();
-        }
-    }
-
-    public void time_emptyJniStaticMethod6_Fast(int reps) throws Exception {
-        int a = -1;
-        int b = 0;
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod6_Fast(a, b, 1, 2, 3, i);
-        }
-    }
-
-    public void time_emptyJniStaticMethod0_Critical(int reps) throws Exception {
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod0_Critical();
-        }
-    }
-
-    public void time_emptyJniStaticMethod6_Critical(int reps) throws Exception {
-        int a = -1;
-        int b = 0;
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod6_Critical(a, b, 1, 2, 3, i);
-        }
-    }
-}
diff --git a/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java b/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java
deleted file mode 100644
index 271a985..0000000
--- a/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2007 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 org.apache.harmony.dalvik;
-
-import dalvik.annotation.optimization.CriticalNative;
-import dalvik.annotation.optimization.FastNative;
-
-/**
- * Methods used to test calling into native code. The methods in this
- * class are all effectively no-ops and may be used to test the mechanisms
- * and performance of calling native methods.
- * @hide
- */
-@libcore.api.CorePlatformApi
-public final class NativeTestTarget {
-    @libcore.api.CorePlatformApi
-    public NativeTestTarget() {
-    }
-
-    /**
-     * This is used to benchmark dalvik's inline natives.
-     */
-    @libcore.api.CorePlatformApi
-    public static void emptyInlineMethod() {
-    }
-
-    /**
-     * This is used to benchmark dalvik's inline natives.
-     */
-    @libcore.api.CorePlatformApi
-    public static native void emptyInternalStaticMethod();
-
-    // Synchronized methods. Test normal JNI only.
-    @libcore.api.CorePlatformApi
-    public static native synchronized void emptyJniStaticSynchronizedMethod0();
-    @libcore.api.CorePlatformApi
-    public native synchronized void emptyJniSynchronizedMethod0();
-
-    // Static methods without object parameters. Test all optimization combinations.
-
-    // Normal native.
-    @libcore.api.CorePlatformApi
-    public static native void emptyJniStaticMethod0();
-    // Normal native.
-    @libcore.api.CorePlatformApi
-    public static native void emptyJniStaticMethod6(int a, int b, int c, int d, int e, int f);
-
-    @libcore.api.CorePlatformApi
-    @FastNative
-    public static native void emptyJniStaticMethod0_Fast();
-    @libcore.api.CorePlatformApi
-    @FastNative
-    public static native void emptyJniStaticMethod6_Fast(int a, int b, int c, int d, int e, int f);
-
-    @libcore.api.CorePlatformApi
-    @CriticalNative
-    public static native void emptyJniStaticMethod0_Critical();
-    @libcore.api.CorePlatformApi
-    @CriticalNative
-    public static native void emptyJniStaticMethod6_Critical(int a, int b, int c, int d, int e, int f);
-    // Instance methods or methods with object parameters. Test {Normal, @FastNative} combinations.
-
-    // Normal native.
-    @libcore.api.CorePlatformApi
-    public native void emptyJniMethod0();
-    // Normal native.
-    @libcore.api.CorePlatformApi
-    public native void emptyJniMethod6(int a, int b, int c, int d, int e, int f);
-
-    /**
-     * This is an empty native static method with six args, hooked up
-     * using JNI. These have more complex args to show the cost of
-     * parsing the signature. All six values should be null
-     * references.
-     */
-    // Normal native.
-    @libcore.api.CorePlatformApi
-    public static native void emptyJniStaticMethod6L(String a, String[] b,
-        int[][] c, Object d, Object[] e, Object[][][][] f);
-
-    // Normal native.
-    @libcore.api.CorePlatformApi
-    public native void emptyJniMethod6L(String a, String[] b,
-        int[][] c, Object d, Object[] e, Object[][][][] f);
-
-    @libcore.api.CorePlatformApi
-    @FastNative
-    public native void emptyJniMethod0_Fast();
-    @libcore.api.CorePlatformApi
-    @FastNative
-    public native void emptyJniMethod6_Fast(int a, int b, int c, int d, int e, int f);
-
-    /**
-     * This is an empty native static method with six args, hooked up
-     * using JNI. These have more complex args to show the cost of
-     * parsing the signature. All six values should be null
-     * references.
-     */
-    @libcore.api.CorePlatformApi
-    @FastNative
-    public static native void emptyJniStaticMethod6L_Fast(String a, String[] b,
-        int[][] c, Object d, Object[] e, Object[][][][] f);
-
-    @libcore.api.CorePlatformApi
-    @FastNative
-    public native void emptyJniMethod6L_Fast(String a, String[] b,
-        int[][] c, Object d, Object[] e, Object[][][][] f);
-}
diff --git a/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp b/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
deleted file mode 100644
index 9f2b429..0000000
--- a/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-#define LOG_TAG "NativeTestTarget"
-
-#include <nativehelper/JNIHelp.h>
-
-#define NATIVE_METHOD(className, functionName, signature)               \
-    { #functionName, signature, reinterpret_cast<void*>(className ## _ ## functionName) }
-
-static void NativeTestTarget_emptyJniStaticSynchronizedMethod0(JNIEnv*, jclass) { }
-static void NativeTestTarget_emptyJniSynchronizedMethod0(JNIEnv*, jclass) { }
-
-static JNINativeMethod gMethods_NormalOnly[] = {
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticSynchronizedMethod0, "()V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniSynchronizedMethod0, "()V"),
-};
-
-
-static void NativeTestTarget_emptyJniMethod0(JNIEnv*, jobject) { }
-static void NativeTestTarget_emptyJniMethod6(JNIEnv*, jobject, int, int, int, int, int, int) { }
-static void NativeTestTarget_emptyJniMethod6L(JNIEnv*, jobject, jobject, jarray, jarray, jobject, jarray, jarray) { }
-static void NativeTestTarget_emptyJniStaticMethod6L(JNIEnv*, jclass, jobject, jarray, jarray, jobject, jarray, jarray) { }
-
-static void NativeTestTarget_emptyJniStaticMethod0(JNIEnv*, jclass) { }
-static void NativeTestTarget_emptyJniStaticMethod6(JNIEnv*, jclass, int, int, int, int, int, int) { }
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(NativeTestTarget, emptyJniMethod0, "()V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniMethod6, "(IIIIII)V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniMethod6L, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6L, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod0, "()V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6, "(IIIIII)V"),
-};
-
-static void NativeTestTarget_emptyJniMethod0_Fast(JNIEnv*, jobject) { }
-static void NativeTestTarget_emptyJniMethod6_Fast(JNIEnv*, jobject, int, int, int, int, int, int) { }
-static void NativeTestTarget_emptyJniMethod6L_Fast(JNIEnv*, jobject, jobject, jarray, jarray, jobject, jarray, jarray) { }
-static void NativeTestTarget_emptyJniStaticMethod6L_Fast(JNIEnv*, jclass, jobject, jarray, jarray, jobject, jarray, jarray) { }
-
-static void NativeTestTarget_emptyJniStaticMethod0_Fast(JNIEnv*, jclass) { }
-static void NativeTestTarget_emptyJniStaticMethod6_Fast(JNIEnv*, jclass, int, int, int, int, int, int) { }
-
-static JNINativeMethod gMethods_Fast[] = {
-    NATIVE_METHOD(NativeTestTarget, emptyJniMethod0_Fast, "()V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniMethod6_Fast, "(IIIIII)V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniMethod6L_Fast, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6L_Fast, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod0_Fast, "()V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6_Fast, "(IIIIII)V"),
-};
-
-
-static void NativeTestTarget_emptyJniStaticMethod0_Critical() { }
-static void NativeTestTarget_emptyJniStaticMethod6_Critical( int, int, int, int, int, int) { }
-
-static JNINativeMethod gMethods_Critical[] = {
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod0_Critical, "()V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6_Critical, "(IIIIII)V"),
-};
-int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods_NormalOnly, NELEM(gMethods_NormalOnly));
-    jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods, NELEM(gMethods));
-    jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods_Fast, NELEM(gMethods_Fast));
-    jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods_Critical, NELEM(gMethods_Critical));
-
-    return 0;
-}
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/FileTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/FileTest.java
index 9f397f4..2bf5660 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/FileTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/io/FileTest.java
@@ -410,17 +410,22 @@
 
         // Test create an illegal file
         String sep = File.separator;
-        f1 = new File(sep + "..");
+        f1 = new File(sep + "a" + sep + ".." + sep + ".." + sep);
         try {
             f1.createNewFile();
             fail("should throw IOE");
         } catch (IOException e) {
             // expected;
         }
-        f1 = new File(sep + "a" + sep + ".." + sep + ".." + sep);
+
+        // Prior to kernel version 5.7, creating "/.." returns EISDIR, and in 5.7 or later,
+        // such syscall returns EEXIST. In the first case, IOException is thrown. In the second
+        // case, false is returned. The below test is modified to accept both of them.
+        // See http://b/176057454 for details.
+        f1 = new File(sep + "..");
         try {
-            f1.createNewFile();
-            fail("should throw IOE");
+            boolean result = f1.createNewFile();
+            assertFalse(result);
         } catch (IOException e) {
             // expected;
         }
diff --git a/libart/src/main/java/java/lang/StringFactory.java b/libart/src/main/java/java/lang/StringFactory.java
index 6ef664b..ea80b9f 100644
--- a/libart/src/main/java/java/lang/StringFactory.java
+++ b/libart/src/main/java/java/lang/StringFactory.java
@@ -65,14 +65,6 @@
         return newStringFromBytes(data, 0, data.length, Charset.forNameUEE(charsetName));
     }
 
-    private static final int[] TABLE_UTF8_NEEDED = new int[] {
-    //      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
-            0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 - 0xcf
-            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 - 0xdf
-            2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xe0 - 0xef
-            3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0 - 0xff
-    };
-
     // TODO: Implement this method natively.
     public static String newStringFromBytes(byte[] data, int offset, int byteCount, Charset charset) {
         if ((offset | byteCount) < 0 || byteCount > data.length - offset) {
@@ -85,147 +77,7 @@
         // We inline UTF-8, ISO-8859-1, and US-ASCII decoders for speed.
         String canonicalCharsetName = charset.name();
         if (canonicalCharsetName.equals("UTF-8")) {
-            /*
-            This code converts a UTF-8 byte sequence to a Java String (UTF-16).
-            It implements the W3C recommended UTF-8 decoder.
-            https://www.w3.org/TR/encoding/#utf-8-decoder
-
-            Unicode 3.2 Well-Formed UTF-8 Byte Sequences
-            Code Points        First  Second Third Fourth
-            U+0000..U+007F     00..7F
-            U+0080..U+07FF     C2..DF 80..BF
-            U+0800..U+0FFF     E0     A0..BF 80..BF
-            U+1000..U+CFFF     E1..EC 80..BF 80..BF
-            U+D000..U+D7FF     ED     80..9F 80..BF
-            U+E000..U+FFFF     EE..EF 80..BF 80..BF
-            U+10000..U+3FFFF   F0     90..BF 80..BF 80..BF
-            U+40000..U+FFFFF   F1..F3 80..BF 80..BF 80..BF
-            U+100000..U+10FFFF F4     80..8F 80..BF 80..BF
-
-            Please refer to Unicode as the authority.
-            p.126 Table 3-7 in http://www.unicode.org/versions/Unicode10.0.0/ch03.pdf
-
-            Handling Malformed Input
-            The maximal subpart should be replaced by a single U+FFFD. Maximal subpart is
-            the longest code unit subsequence starting at an unconvertible offset that is either
-            1) the initial subsequence of a well-formed code unit sequence, or
-            2) a subsequence of length one:
-            One U+FFFD should be emitted for every sequence of bytes that is an incomplete prefix
-            of a valid sequence, and with the conversion to restart after the incomplete sequence.
-
-            For example, in byte sequence "41 C0 AF 41 F4 80 80 41", the maximal subparts are
-            "C0", "AF", and "F4 80 80". "F4 80 80" can be the initial subsequence of "F4 80 80 80",
-            but "C0" can't be the initial subsequence of any well-formed code unit sequence.
-            Thus, the output should be "A\ufffd\ufffdA\ufffdA".
-
-            Please refer to section "Best Practices for Using U+FFFD." in
-            http://www.unicode.org/versions/Unicode10.0.0/ch03.pdf
-            */
-            byte[] d = data;
-            char[] v = new char[byteCount];
-
-            int idx = offset;
-            int last = offset + byteCount;
-            int s = 0;
-
-            int codePoint = 0;
-            int utf8BytesSeen = 0;
-            int utf8BytesNeeded = 0;
-            int lowerBound = 0x80;
-            int upperBound = 0xbf;
-
-            while (idx < last) {
-                int b = d[idx++] & 0xff;
-                if (utf8BytesNeeded == 0) {
-                    if ((b & 0x80) == 0) { // ASCII char. 0xxxxxxx
-                        v[s++] = (char) b;
-                        continue;
-                    }
-
-                    if ((b & 0x40) == 0) { // 10xxxxxx is illegal as first byte
-                        v[s++] = REPLACEMENT_CHAR;
-                        continue;
-                    }
-
-                    // 11xxxxxx
-                    int tableLookupIndex = b & 0x3f;
-                    utf8BytesNeeded = TABLE_UTF8_NEEDED[tableLookupIndex];
-                    if (utf8BytesNeeded == 0) {
-                        v[s++] = REPLACEMENT_CHAR;
-                        continue;
-                    }
-
-                    // utf8BytesNeeded
-                    // 1: b & 0x1f
-                    // 2: b & 0x0f
-                    // 3: b & 0x07
-                    codePoint = b & (0x3f >> utf8BytesNeeded);
-                    if (b == 0xe0) {
-                        lowerBound = 0xa0;
-                    } else if (b == 0xed) {
-                        upperBound = 0x9f;
-                    } else if (b == 0xf0) {
-                        lowerBound = 0x90;
-                    } else if (b == 0xf4) {
-                        upperBound = 0x8f;
-                    }
-                } else {
-                    if (b < lowerBound || b > upperBound) {
-                        // The bytes seen are ill-formed. Substitute them with U+FFFD
-                        v[s++] = REPLACEMENT_CHAR;
-                        codePoint = 0;
-                        utf8BytesNeeded = 0;
-                        utf8BytesSeen = 0;
-                        lowerBound = 0x80;
-                        upperBound = 0xbf;
-                        /*
-                         * According to the Unicode Standard,
-                         * "a UTF-8 conversion process is required to never consume well-formed
-                         * subsequences as part of its error handling for ill-formed subsequences"
-                         * The current byte could be part of well-formed subsequences. Reduce the
-                         * index by 1 to parse it in next loop.
-                         */
-                        idx--;
-                        continue;
-                    }
-
-                    lowerBound = 0x80;
-                    upperBound = 0xbf;
-                    codePoint = (codePoint << 6) | (b & 0x3f);
-                    utf8BytesSeen++;
-                    if (utf8BytesNeeded != utf8BytesSeen) {
-                        continue;
-                    }
-
-                    // Encode chars from U+10000 up as surrogate pairs
-                    if (codePoint < 0x10000) {
-                        v[s++] = (char) codePoint;
-                    } else {
-                        v[s++] = (char) ((codePoint >> 10) + 0xd7c0);
-                        v[s++] = (char) ((codePoint & 0x3ff) + 0xdc00);
-                    }
-
-                    utf8BytesSeen = 0;
-                    utf8BytesNeeded = 0;
-                    codePoint = 0;
-                }
-            }
-
-            // The bytes seen are ill-formed. Substitute them by U+FFFD
-            if (utf8BytesNeeded != 0) {
-                v[s++] = REPLACEMENT_CHAR;
-            }
-
-            if (s == byteCount) {
-                // We guessed right, so we can use our temporary array as-is.
-                value = v;
-                length = s;
-            } else {
-                // Our temporary array was too big, so reallocate and copy.
-                value = new char[s];
-                length = s;
-                System.arraycopy(v, 0, value, 0, s);
-            }
+            return newStringFromUtf8Bytes(data, offset, byteCount);
         } else if (canonicalCharsetName.equals("ISO-8859-1")) {
             value = new char[byteCount];
             length = byteCount;
@@ -267,6 +119,9 @@
     @FastNative
     public static native String newStringFromString(String toCopy);
 
+    @FastNative
+    public static native String newStringFromUtf8Bytes(byte[] data, int offset, int byteCount);
+
     public static String newStringFromStringBuffer(StringBuffer stringBuffer) {
         synchronized (stringBuffer) {
             return newStringFromChars(stringBuffer.getValue(), 0, stringBuffer.length());
diff --git a/luni/src/main/java/android/system/StructTimeval.java b/luni/src/main/java/android/system/StructTimeval.java
index 559056a..7b39462 100644
--- a/luni/src/main/java/android/system/StructTimeval.java
+++ b/luni/src/main/java/android/system/StructTimeval.java
@@ -43,11 +43,10 @@
         // represented by rounding down to the nearest whole second <= the one we need
         // (i.e. floor()) and adding the necessary micro seconds.
         long tv_sec = millis / 1000;
-        long tv_usec = (millis - (tv_sec * 1000)) * 1000;
-        if (millis < 0) {
-            tv_sec -= 1;
-            tv_usec += 1_000_000;
+        if (tv_sec * 1000 > millis) {
+            --tv_sec;
         }
+        long tv_usec = (millis - (tv_sec * 1000)) * 1000;
         return new StructTimeval(tv_sec, tv_usec);
     }
 
diff --git a/luni/src/main/java/libcore/icu/ICU.java b/luni/src/main/java/libcore/icu/ICU.java
index 4996431..f7f2042 100644
--- a/luni/src/main/java/libcore/icu/ICU.java
+++ b/luni/src/main/java/libcore/icu/ICU.java
@@ -22,6 +22,7 @@
 import android.icu.util.IllformedLocaleException;
 import android.icu.util.ULocale;
 
+import com.android.icu.util.ExtendedCalendar;
 import com.android.icu.util.LocaleNative;
 
 import java.util.Collections;
@@ -373,6 +374,96 @@
   }
 
   /**
+   * {@link java.time.format.DateTimeFormatter} does not handle some date symbols, e.g. 'B' / 'b',
+   * and thus we use a heuristic algorithm to remove the symbol. See http://b/174804526.
+   * See {@link #transformIcuDateTimePattern(String)} for documentation about the implementation.
+   */
+  public static String transformIcuDateTimePattern_forJavaTime(String pattern) {
+    return transformIcuDateTimePattern(pattern);
+  }
+
+  /**
+   * Rewrite the date/time pattern coming ICU to be consumed by libcore classes.
+   * It's an ideal place to rewrite the pattern entirely when multiple symbols not digested
+   * by libcore need to be removed/processed. Rewriting in single place could be more efficient
+   * in a small or constant number of scans instead of scanning for every symbol.
+   *
+   * {@link LocaleData#initLocaleData(Locale)} also rewrites time format, but only a subset of
+   * patterns. In the future, that should migrate to this function in order to handle the symbols
+   * in one place, but now separate because java.text and java.time handles different sets of
+   * symbols.
+   */
+  private static String transformIcuDateTimePattern(String pattern) {
+    if (pattern == null) {
+      return null;
+    }
+
+    // For details about the different symbols, see
+    // http://cldr.unicode.org/translation/date-time-1/date-time-patterns#TOC-Day-period-patterns
+    // The symbols B means "Day periods with locale-specific ranges".
+    // English example: 2:00 at night, 10:00 in the morning, 12:00 in the afternoon.
+    boolean contains_B = pattern.indexOf('B') != -1;
+    // AM, PM, noon and midnight. English example: 10:00 AM, 12:00 noon, 7:00 PM
+    boolean contains_b = pattern.indexOf('b') != -1;
+
+    // Simply remove the symbol 'B' and 'b' if 24-hour 'H' exists because the 24-hour format
+    // provides enough information and the day periods are optional. See http://b/174804526.
+    // Don't handle symbol 'B'/'b' with 12-hour 'h' because it's much more complicated because
+    // we likely need to replace 'B'/'b' with 'a' inserted into a new right position or use other
+    // ways.
+    boolean remove_B_and_b = (contains_B || contains_b) && (pattern.indexOf('H') != -1);
+
+    if (remove_B_and_b) {
+      pattern = rewriteIcuDateTimePattern(pattern);
+    }
+    return pattern;
+  }
+
+  /**
+   * Rewrite pattern with heuristics. It's known to
+   *   - Remove 'b' and 'B' from simple patterns, e.g. "B H:mm" and "dd-MM-yy B HH:mm:ss" only.
+   *   - (Append the new heuristics)
+   */
+  private static String rewriteIcuDateTimePattern(String pattern) {
+    // The below implementation can likely be replaced by a regular expression via
+    // String.replaceAll(). However, it's known that libcore's regex implementation is more
+    // memory-intensive, and the below implementation is likely cheaper, but it's not yet measured.
+    StringBuilder sb = new StringBuilder(pattern.length());
+    char prev = ' '; // the initial value is not used.
+    for (int i = 0; i < pattern.length(); i++) {
+      char curr = pattern.charAt(i);
+      switch(curr) {
+        case 'B':
+        case 'b':
+          // Ignore 'B' and 'b'
+          break;
+        case ' ': // Ascii whitespace
+          // caveat: Ideally it's a case for all Unicode whitespaces by UCharacter.isUWhiteSpace(c)
+          // but checking ascii whitespace only is enough for the CLDR data when this is written.
+          if (i != 0 && (prev == 'B' || prev == 'b')) {
+            // Ignore the whitespace behind the symbol 'B'/'b' because it's likely a whitespace to
+            // separate the day period with the next text.
+          } else {
+            sb.append(curr);
+          }
+          break;
+        default:
+          sb.append(curr);
+          break;
+      }
+      prev = curr;
+    }
+
+    // Remove the trailing whitespace which is likely following the symbol 'B'/'b' in the original
+    // pattern, e.g. "hh:mm B" (12:00 in the afternoon).
+    int lastIndex = sb.length() - 1;
+    if (lastIndex >= 0 && sb.charAt(lastIndex) == ' ') {
+      sb.deleteCharAt(lastIndex);
+    }
+    return sb.toString();
+  }
+
+  /**
    * Returns the version of the CLDR data in use, such as "22.1.1".
    *
    */
@@ -465,4 +556,14 @@
    * Returns a locale name, not a BCP-47 language tag. e.g. en_US not en-US.
    */
   public static native String getDefaultLocale();
+
+
+  /**
+   * @param calendarType LDML-defined legacy calendar type. See keyTypeData.txt in ICU.
+   */
+  public static ExtendedCalendar getExtendedCalendar(Locale locale, String calendarType) {
+      ULocale uLocale = ULocale.forLocale(locale)
+              .setKeywordValue("calendar", calendarType);
+      return ExtendedCalendar.getInstance(uLocale);
+  }
 }
diff --git a/luni/src/main/java/libcore/icu/LocaleData.java b/luni/src/main/java/libcore/icu/LocaleData.java
index 5000b17..c255720 100644
--- a/luni/src/main/java/libcore/icu/LocaleData.java
+++ b/luni/src/main/java/libcore/icu/LocaleData.java
@@ -29,7 +29,8 @@
 import android.icu.util.GregorianCalendar;
 import android.icu.util.ULocale;
 
-import com.android.icu.text.DecimalFormatSymbolsBridge;
+import com.android.icu.text.ExtendedDecimalFormatSymbols;
+import com.android.icu.util.ExtendedCalendar;
 
 import dalvik.system.VMRuntime;
 
@@ -334,8 +335,8 @@
         if (ns == null || ns.getRadix() != 10 || ns.isAlgorithmic()) {
             ns = NumberingSystem.LATIN;
         }
-        String patternSeparator =
-            DecimalFormatSymbolsBridge.getLocalizedPatternSeparator(uLocale, ns);
+        String patternSeparator = ExtendedDecimalFormatSymbols.getInstance(uLocale, ns)
+                .getLocalizedPatternSeparator();
 
         if (patternSeparator == null || patternSeparator.isEmpty()) {
             patternSeparator = ";";
@@ -409,24 +410,24 @@
     }
 
     private void initializeDateTimePatterns(Locale locale) {
-        ULocale uLocale = ULocale.forLocale(locale);
-        String calType = "gregorian";
+        // libcore's java.text supports Gregorian calendar only.
+        ExtendedCalendar extendedCalendar = ICU.getExtendedCalendar(locale, "gregorian");
 
-        fullTimeFormat = Calendar.getDateTimeFormatString(uLocale, calType,
+        fullTimeFormat = extendedCalendar.getDateTimePattern(
             android.icu.text.DateFormat.NONE, android.icu.text.DateFormat.FULL);
-        longTimeFormat = Calendar.getDateTimeFormatString(uLocale, calType,
+        longTimeFormat = extendedCalendar.getDateTimePattern(
             android.icu.text.DateFormat.NONE, android.icu.text.DateFormat.LONG);
-        mediumTimeFormat = Calendar.getDateTimeFormatString(uLocale, calType,
+        mediumTimeFormat = extendedCalendar.getDateTimePattern(
             android.icu.text.DateFormat.NONE, android.icu.text.DateFormat. MEDIUM);
-        shortTimeFormat = Calendar.getDateTimeFormatString(uLocale, calType,
+        shortTimeFormat = extendedCalendar.getDateTimePattern(
             android.icu.text.DateFormat.NONE, android.icu.text.DateFormat.SHORT);
-        fullDateFormat = Calendar.getDateTimeFormatString(uLocale, calType,
+        fullDateFormat = extendedCalendar.getDateTimePattern(
             android.icu.text.DateFormat.FULL, android.icu.text.DateFormat.NONE);
-        longDateFormat = Calendar.getDateTimeFormatString(uLocale, calType,
+        longDateFormat = extendedCalendar.getDateTimePattern(
             android.icu.text.DateFormat.LONG, android.icu.text.DateFormat.NONE);
-        mediumDateFormat = Calendar.getDateTimeFormatString(uLocale, calType,
+        mediumDateFormat = extendedCalendar.getDateTimePattern(
             android.icu.text.DateFormat.MEDIUM, android.icu.text.DateFormat.NONE);
-        shortDateFormat = Calendar.getDateTimeFormatString(uLocale, calType,
+        shortDateFormat = extendedCalendar.getDateTimePattern(
             android.icu.text.DateFormat.SHORT, android.icu.text.DateFormat.NONE);
     }
 }
diff --git a/luni/src/main/java/libcore/util/ArrayUtils.java b/luni/src/main/java/libcore/util/ArrayUtils.java
index 3a8d854..5330bc0 100644
--- a/luni/src/main/java/libcore/util/ArrayUtils.java
+++ b/luni/src/main/java/libcore/util/ArrayUtils.java
@@ -18,7 +18,6 @@
 /**
  * @hide
  */
-@libcore.api.CorePlatformApi
 public final class ArrayUtils {
     private ArrayUtils() {}
 
@@ -30,7 +29,6 @@
      * @throws ArrayIndexOutOfBoundsException if the range from {@code offset} with length
      * {@code count} is out of bounds of the array
      */
-    @libcore.api.CorePlatformApi
     public static void throwsIfOutOfBounds(int len, int offset, int count) {
         if (len < 0) {
             throw new ArrayIndexOutOfBoundsException("Negative length: " + len);
diff --git a/luni/src/main/java/libcore/util/HexEncoding.java b/luni/src/main/java/libcore/util/HexEncoding.java
index 6d00074..808409f 100644
--- a/luni/src/main/java/libcore/util/HexEncoding.java
+++ b/luni/src/main/java/libcore/util/HexEncoding.java
@@ -36,6 +36,11 @@
 
     /**
      * Encodes the provided byte as a two-digit hexadecimal String value.
+     *
+     * @param  b byte to encode
+     * @param  upperCase {@code true} to use uppercase letters, {@code false}
+     *         for lowercase
+     * @return the encoded string
      */
     @libcore.api.CorePlatformApi
     public static String encodeToString(byte b, boolean upperCase) {
@@ -48,6 +53,9 @@
 
     /**
      * Encodes the provided data as a sequence of hexadecimal characters.
+     *
+     * @param  data byte array to encode
+     * @return the encoded data, using uppercase letters
      */
     @libcore.api.CorePlatformApi
     public static char[] encode(byte[] data) {
@@ -56,6 +64,11 @@
 
     /**
      * Encodes the provided data as a sequence of hexadecimal characters.
+     *
+     * @param  data byte array to encode
+     * @param  upperCase {@code true} to use uppercase letters, {@code false}
+     *         for lowercase
+     * @return the encoded data
      */
     @libcore.api.CorePlatformApi
     public static char[] encode(byte[] data, boolean upperCase) {
@@ -64,6 +77,11 @@
 
     /**
      * Encodes the provided data as a sequence of hexadecimal characters.
+     *
+     * @param  data byte array containing the data to encode
+     * @param  offset offset of the data to encode in the {@code data} array
+     * @param  len length of the data to encode in the {@code data} array
+     * @return the encoded data, using uppercase letters
      */
     @libcore.api.CorePlatformApi
     public static char[] encode(byte[] data, int offset, int len) {
@@ -88,6 +106,9 @@
 
     /**
      * Encodes the provided data as a sequence of hexadecimal characters.
+     *
+     * @param  data byte array to encode
+     * @return the encoded data, using uppercase letters
      */
     @libcore.api.CorePlatformApi
     public static String encodeToString(byte[] data) {
@@ -96,6 +117,11 @@
 
     /**
      * Encodes the provided data as a sequence of hexadecimal characters.
+     *
+     * @param  data byte array to encode.
+     * @param  upperCase {@code true} to use uppercase letters, {@code false}
+     *         for lowercase
+     * @return the encoded data
      */
     @libcore.api.CorePlatformApi
     public static String encodeToString(byte[] data, boolean upperCase) {
@@ -103,10 +129,13 @@
     }
 
     /**
-     * Decodes the provided hexadecimal string into a byte array.  Odd-length inputs
-     * are not allowed.
+     * Decodes the provided hexadecimal sequence. Odd-length inputs are not
+     * allowed.
      *
-     * Throws an {@code IllegalArgumentException} if the input is malformed.
+     * @param  encoded string of hexadecimal characters to decode. Letters
+     *         can be either uppercase or lowercase.
+     * @return the decoded data
+     * @throws IllegalArgumentException if the input is malformed
      */
     @libcore.api.CorePlatformApi
     public static byte[] decode(String encoded) throws IllegalArgumentException {
@@ -114,11 +143,15 @@
     }
 
     /**
-     * Decodes the provided hexadecimal string into a byte array. If {@code allowSingleChar}
-     * is {@code true} odd-length inputs are allowed and the first character is interpreted
-     * as the lower bits of the first result byte.
+     * Decodes the provided hexadecimal sequence.
      *
-     * Throws an {@code IllegalArgumentException} if the input is malformed.
+     * @param  encoded string of hexadecimal characters to decode. Letters
+     *         can be either uppercase or lowercase.
+     * @param  allowSingleChar If {@code true} odd-length inputs are allowed and
+     *         the first character is interpreted as the lower bits of the first
+     *         result byte. If {@code false} odd-length inputs are not allowed.
+     * @return the decoded data
+     * @throws IllegalArgumentException if the input is malformed
      */
     @libcore.api.CorePlatformApi
     public static byte[] decode(String encoded, boolean allowSingleChar)
@@ -127,10 +160,13 @@
     }
 
     /**
-     * Decodes the provided hexadecimal string into a byte array.  Odd-length inputs
-     * are not allowed.
+     * Decodes the provided hexadecimal sequence. Odd-length inputs are not
+     * allowed.
      *
-     * Throws an {@code IllegalArgumentException} if the input is malformed.
+     * @param  encoded char array of hexadecimal characters to decode. Letters
+     *         can be either uppercase or lowercase.
+     * @return the decoded data
+     * @throws IllegalArgumentException if the input is malformed
      */
     @libcore.api.CorePlatformApi
     public static byte[] decode(char[] encoded) throws IllegalArgumentException {
@@ -138,11 +174,15 @@
     }
 
     /**
-     * Decodes the provided hexadecimal string into a byte array. If {@code allowSingleChar}
-     * is {@code true} odd-length inputs are allowed and the first character is interpreted
-     * as the lower bits of the first result byte.
+     * Decodes the provided hexadecimal sequence.
      *
-     * Throws an {@code IllegalArgumentException} if the input is malformed.
+     * @param  encoded char array of hexadecimal characters to decode. Letters
+     *         can be either uppercase or lowercase.
+     * @param  allowSingleChar If {@code true} odd-length inputs are allowed and
+     *         the first character is interpreted as the lower bits of the first
+     *         result byte. If {@code false} odd-length inputs are not allowed.
+     * @return the decoded data
+     * @throws IllegalArgumentException if the input is malformed
      */
     @libcore.api.CorePlatformApi
     public static byte[] decode(char[] encoded, boolean allowSingleChar)
diff --git a/luni/src/main/native/Register.cpp b/luni/src/main/native/Register.cpp
index e3b0a10..91cabf7 100644
--- a/luni/src/main/native/Register.cpp
+++ b/luni/src/main/native/Register.cpp
@@ -45,7 +45,6 @@
     REGISTER(register_libcore_io_Memory);
     REGISTER(register_libcore_math_NativeBN);
     REGISTER(register_libcore_util_NativeAllocationRegistry);
-    REGISTER(register_org_apache_harmony_dalvik_NativeTestTarget);
     REGISTER(register_org_apache_harmony_xml_ExpatParser);
     REGISTER(register_sun_misc_Unsafe);
 #undef REGISTER
diff --git a/luni/src/test/java/libcore/android/system/OsTest.java b/luni/src/test/java/libcore/android/system/OsTest.java
index 35019db..355d340 100644
--- a/luni/src/test/java/libcore/android/system/OsTest.java
+++ b/luni/src/test/java/libcore/android/system/OsTest.java
@@ -1103,8 +1103,8 @@
     }
 
     public void test_socket_setSockoptTimeval_effective() throws Exception {
-        int timeoutValueMillis = 50;
-        int allowedTimeoutMillis = 500;
+        int timeoutValueMillis = 250;
+        int allowedTimeoutMillis = 3000;
 
         FileDescriptor fd = Os.socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
         try {
@@ -1116,8 +1116,15 @@
             long startTime = System.nanoTime();
             expectException(() -> Os.read(fd, request, 0, request.length),
                     ErrnoException.class, EAGAIN, "Expected timeout");
-            long endTime = System.nanoTime();
-            assertTrue(Duration.ofNanos(endTime - startTime).toMillis() < allowedTimeoutMillis);
+            long durationMillis = Duration.ofNanos(System.nanoTime() - startTime).toMillis();
+            // TODO(b/176104885): Sometimes returns 1 msec early. It's unclear that's correct.
+            // We haven't seen this on modern devices, and allow it for now. Needs investigation.
+            assertTrue("Timeout of " + timeoutValueMillis + "ms returned after "
+                    + durationMillis +"ms",
+                durationMillis >= timeoutValueMillis - 1);
+            assertTrue("Timeout of " + timeoutValueMillis + "ms failed to return within "
+                    + allowedTimeoutMillis  + "ms",
+                durationMillis < allowedTimeoutMillis);
         } finally {
             Os.close(fd);
         }
diff --git a/luni/src/test/java/libcore/android/system/StructTimevalTest.java b/luni/src/test/java/libcore/android/system/StructTimevalTest.java
index f427980..b5ca9e5 100644
--- a/luni/src/test/java/libcore/android/system/StructTimevalTest.java
+++ b/luni/src/test/java/libcore/android/system/StructTimevalTest.java
@@ -42,6 +42,8 @@
         // An array of { testMillisValue, expectedSeconds, expectedMicros }
         return new Object[][] {
                 { 0L, 0L, 0L },
+                { 1000L, 1L, 0L },
+                { -1000L, -1L, 0L },
 
                 // +ve and -ve cases close to zero seconds.
                 { 23L, 0L, 23L * US_PER_MS /* 23000 */ },
diff --git a/luni/src/test/java/libcore/java/lang/ByteTest.java b/luni/src/test/java/libcore/java/lang/ByteTest.java
index f051b91..821d060 100644
--- a/luni/src/test/java/libcore/java/lang/ByteTest.java
+++ b/luni/src/test/java/libcore/java/lang/ByteTest.java
@@ -57,4 +57,37 @@
             assertEquals(b, Long.valueOf(b).byteValue());
         }
     }
+
+    public void testCompareUnsigned() {
+        // Ascending order of unsigned(value)
+        final byte a = 0;
+        final byte b = 3;
+        final byte y = -2; // 254
+        final byte z = -1; // 255
+
+        assertTrue(Byte.compareUnsigned(a, b) < 0);
+        assertTrue(Byte.compareUnsigned(a, y) < 0);
+        assertTrue(Byte.compareUnsigned(a, z) < 0);
+        assertTrue(Byte.compareUnsigned(b, y) < 0);
+        assertTrue(Byte.compareUnsigned(b, z) < 0);
+        assertTrue(Byte.compareUnsigned(y, z) < 0);
+
+        assertTrue(Byte.compareUnsigned(b, a) > 0);
+        assertTrue(Byte.compareUnsigned(y, a) > 0);
+        assertTrue(Byte.compareUnsigned(y, b) > 0);
+        assertTrue(Byte.compareUnsigned(z, a) > 0);
+        assertTrue(Byte.compareUnsigned(z, b) > 0);
+        assertTrue(Byte.compareUnsigned(z, y) > 0);
+
+        assertTrue(Byte.compareUnsigned(a, a) == 0);
+        assertTrue(Byte.compareUnsigned(b, b) == 0);
+        assertTrue(Byte.compareUnsigned(y, y) == 0);
+        assertTrue(Byte.compareUnsigned(z, z) == 0);
+
+        assertTrue(Byte.compareUnsigned(Byte.MIN_VALUE, (byte)128) == 0);
+        assertTrue(Byte.compareUnsigned(Byte.MAX_VALUE, (byte)127) == 0);
+        assertTrue(Byte.compareUnsigned(Byte.MIN_VALUE, Byte.MAX_VALUE) > 0);
+        assertTrue(Byte.compareUnsigned(Byte.MIN_VALUE, z) < 0);
+        assertTrue(Byte.compareUnsigned(Byte.MAX_VALUE, z) < 0);
+    }
 }
diff --git a/luni/src/test/java/libcore/java/lang/OldClassTest.java b/luni/src/test/java/libcore/java/lang/OldClassTest.java
index e0955bc..a4af7d1 100644
--- a/luni/src/test/java/libcore/java/lang/OldClassTest.java
+++ b/luni/src/test/java/libcore/java/lang/OldClassTest.java
@@ -469,7 +469,7 @@
                       thisPackage.getName());
 
       Package stringPackage = String.class.getPackage();
-      assertNotNull("java.lang", stringPackage.getName());
+      assertEquals("java.lang", stringPackage.getName());
 
       String hyts_package_name = "hyts_package_dex.jar";
       File resources = Support_Resources.createTempFolder();
@@ -517,6 +517,66 @@
       }
     }
 
+    // Android-note: Uses dalvik.system.PathClassLoader.
+    // Different behavior between cts host and run-core-test")
+    public void test_getPackageName() {
+
+      String thisPackage = getClass().getPackageName();
+      assertEquals("libcore.java.lang", thisPackage);
+
+      String stringPackage = String.class.getPackageName();
+      assertEquals("java.lang", stringPackage);
+  
+      String stringArrayPackage = String[].class.getPackageName();
+      assertEquals("java.lang", stringArrayPackage);
+
+      String stringArrayArrayPackage = String[][].class.getPackageName();
+      assertEquals("java.lang", stringArrayArrayPackage);
+
+      String intPackage = int.class.getPackageName();
+      assertEquals("java.lang", intPackage);
+
+      String intArrayPackage = int[].class.getPackageName();
+      assertEquals("java.lang", intPackage);
+
+      String hyts_package_name = "hyts_package_dex.jar";
+      File resources = Support_Resources.createTempFolder();
+      Support_Resources.copyFile(resources, "Package", hyts_package_name);
+
+      String resPath = resources.toString();
+      if (resPath.charAt(0) == '/' || resPath.charAt(0) == '\\')
+          resPath = resPath.substring(1);
+
+      try {
+
+          URL resourceURL = new URL("file:/" + resPath + "/Package/"
+                  + hyts_package_name);
+
+          ClassLoader cl = Support_ClassLoader.getInstance(resourceURL,
+                  getClass().getClassLoader());
+
+          Class clazz = cl.loadClass("C");
+          assertEquals("", clazz.getPackageName());
+
+          clazz = Class.forName("[LC;", false, cl);
+          assertEquals("", clazz.getPackageName());
+
+          clazz = Class.forName("[[LC;", false, cl);
+          assertEquals("", clazz.getPackageName());
+
+          clazz = cl.loadClass("a.b.C");
+          assertEquals("a.b", clazz.getPackageName());
+
+          clazz = Class.forName("[La.b.C;", false, cl);
+          assertEquals("a.b", clazz.getPackageName());
+
+          clazz = Class.forName("[[La.b.C;", false, cl);
+          assertEquals("a.b", clazz.getPackageName());
+      } catch(Exception e) {
+          fail("Unexpected exception was thrown: " + e.toString());
+      }
+    }
+
     public void test_getSigners() {
         assertNull(void.class.getSigners());
         assertNull(PublicTestClass.class.getSigners());
diff --git a/luni/src/test/java/libcore/java/lang/PackageTest.java b/luni/src/test/java/libcore/java/lang/PackageTest.java
index 672af5d..0ea412c 100644
--- a/luni/src/test/java/libcore/java/lang/PackageTest.java
+++ b/luni/src/test/java/libcore/java/lang/PackageTest.java
@@ -46,6 +46,12 @@
         assertEquals(getClass().getPackage(), libcoreJavaLang);
     }
 
+    public void testGetPackageName() {
+        Package libcoreJavaLang = Package.getPackage("libcore.java.lang");
+        assertEquals("libcore.java.lang", getClass().getPackageName());
+        assertEquals(getClass().getPackageName(), libcoreJavaLang.getName());
+    }
+
     // http://b/28057303
     @TargetSdkVersion(24)
     public void test_toString_targetSdkVersion_24() throws Exception {
diff --git a/luni/src/test/java/libcore/java/lang/ShortTest.java b/luni/src/test/java/libcore/java/lang/ShortTest.java
index a3db71a..d805f8e 100644
--- a/luni/src/test/java/libcore/java/lang/ShortTest.java
+++ b/luni/src/test/java/libcore/java/lang/ShortTest.java
@@ -57,4 +57,37 @@
             assertEquals(b, Long.valueOf(b).shortValue());
         }
     }
+
+    public void testCompareUnsigned() {
+        // Ascending order of unsigned(value)
+        final short a = 0;
+        final short b = 3;
+        final short y = -2; // 65534
+        final short z = -1; // 65535
+
+        assertTrue(Short.compareUnsigned(a, b) < 0);
+        assertTrue(Short.compareUnsigned(a, y) < 0);
+        assertTrue(Short.compareUnsigned(a, z) < 0);
+        assertTrue(Short.compareUnsigned(b, y) < 0);
+        assertTrue(Short.compareUnsigned(b, z) < 0);
+        assertTrue(Short.compareUnsigned(y, z) < 0);
+
+        assertTrue(Short.compareUnsigned(b, a) > 0);
+        assertTrue(Short.compareUnsigned(y, a) > 0);
+        assertTrue(Short.compareUnsigned(y, b) > 0);
+        assertTrue(Short.compareUnsigned(z, a) > 0);
+        assertTrue(Short.compareUnsigned(z, b) > 0);
+        assertTrue(Short.compareUnsigned(z, y) > 0);
+
+        assertTrue(Short.compareUnsigned(a, a) == 0);
+        assertTrue(Short.compareUnsigned(b, b) == 0);
+        assertTrue(Short.compareUnsigned(y, y) == 0);
+        assertTrue(Short.compareUnsigned(z, z) == 0);
+
+        assertTrue(Short.compareUnsigned(Short.MIN_VALUE, (short)32768) == 0);
+        assertTrue(Short.compareUnsigned(Short.MAX_VALUE, (short)32767) == 0);
+        assertTrue(Short.compareUnsigned(Short.MIN_VALUE, Short.MAX_VALUE) > 0);
+        assertTrue(Short.compareUnsigned(Short.MIN_VALUE, z) < 0);
+        assertTrue(Short.compareUnsigned(Short.MAX_VALUE, z) < 0);
+    }
 }
diff --git a/luni/src/test/java/libcore/java/net/SocketTest.java b/luni/src/test/java/libcore/java/net/SocketTest.java
index 3e1c1a6..df12a29 100644
--- a/luni/src/test/java/libcore/java/net/SocketTest.java
+++ b/luni/src/test/java/libcore/java/net/SocketTest.java
@@ -598,13 +598,12 @@
     public void testSocketTestAllAddresses() throws Exception {
         // Socket Ctor should try all sockets.
         //
-        // This test creates a server socket bound to 127.0.0.1 or ::1 only, and connects using a
+        // This test creates server sockets bound to 127.0.0.1 and ::1, and connects using a
         // hostname that resolves to both addresses. We should be able to connect to the server
         // socket in either setup.
         final String loopbackHost = ALL_LOOPBACK_HOSTNAME;
 
-        assertTrue("Loopback DNS record is unreachable or is invalid.", checkLoopbackHost(
-                loopbackHost));
+        checkLoopbackHost(loopbackHost);
 
         final int port = 9999;
         for (InetAddress addr : new InetAddress[]{ Inet4Address.LOOPBACK, Inet6Address.LOOPBACK }) {
@@ -622,15 +621,16 @@
         }
     }
 
-    /** Confirm the supplied hostname maps to only loopback addresses. */
-    private static boolean checkLoopbackHost(String host) {
-        try {
-            List<InetAddress> addrs = Arrays.asList(InetAddress.getAllByName(host));
-            return addrs.stream().allMatch(InetAddress::isLoopbackAddress) &&
-                    addrs.contains(Inet4Address.LOOPBACK) && addrs.contains(Inet6Address.LOOPBACK);
-        } catch (UnknownHostException e) {
-            return false;
-        }
+    /** Confirm the supplied hostname maps to only loopback addresses, both IPv4 and IPv6. */
+    private static void checkLoopbackHost(String host) throws UnknownHostException {
+        InetAddress[] addrArray = InetAddress.getAllByName(host);
+        final String addressesString = Arrays.toString(addrArray);
+        List<InetAddress> addrs = Arrays.asList(addrArray);
+        final String msg = ALL_LOOPBACK_HOSTNAME
+                + " must only return loopback addresses, both IPv4 and IPv6. Got: "
+                + addressesString;
+        assertTrue(msg, addrs.stream().allMatch(InetAddress::isLoopbackAddress)
+                && addrs.contains(Inet4Address.LOOPBACK) && addrs.contains(Inet6Address.LOOPBACK));
     }
 
     private static boolean canConnect(String host, int port) {
diff --git a/luni/src/test/java/libcore/java/time/format/DateTimeFormatterTest.java b/luni/src/test/java/libcore/java/time/format/DateTimeFormatterTest.java
index 3e29594..7ab33f7 100644
--- a/luni/src/test/java/libcore/java/time/format/DateTimeFormatterTest.java
+++ b/luni/src/test/java/libcore/java/time/format/DateTimeFormatterTest.java
@@ -19,10 +19,15 @@
 
 import java.time.Instant;
 import java.time.ZoneId;
+import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
+import java.time.chrono.Chronology;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
 import java.time.format.DecimalStyle;
+import java.time.format.FormatStyle;
+import java.time.temporal.ChronoField;
+import java.time.temporal.ChronoUnit;
 import java.time.temporal.TemporalAccessor;
 import java.util.Locale;
 
@@ -86,4 +91,86 @@
     private static String formatWithPattern(Locale l, String pattern, TemporalAccessor datetime) {
         return DateTimeFormatter.ofPattern(pattern, l).format(datetime);
     }
+
+    // 1 January 2022 00:00:00 GMT+00:00
+    private static final Instant TEST_INSTANT = Instant.ofEpochSecond(1640995200L);
+
+    // Regression test for http://b/174804526 when DateTimeFormatter fetches symbol 'B' from ICU.
+    @Test
+    public void test_format_locale_my_MM() {
+        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT)
+                .withLocale(new Locale("my", "MM"))
+                .withZone(ZoneOffset.UTC);
+        assertEquals("0:00", dateTimeFormatter.format(TEST_INSTANT));
+        TemporalAccessor accessor = dateTimeFormatter.parse("23:59");
+        assertEquals(23, accessor.getLong(ChronoField.HOUR_OF_DAY));
+        assertEquals(59, accessor.getLong(ChronoField.MINUTE_OF_HOUR));
+    }
+
+
+    /**
+     * Test {@link DateTimeFormatter#format(TemporalAccessor)} does not crash on available locales.
+     */
+    @Test
+    public void test_format_allLocales() {
+        for (Locale locale : Locale.getAvailableLocales()) {
+            for (FormatStyle formatStyle : FormatStyle.values()) {
+                try {
+                    DateTimeFormatter.ofLocalizedTime(formatStyle)
+                            .withLocale(locale)
+                            .withZone(ZoneOffset.UTC)
+                            .format(TEST_INSTANT);
+
+                    DateTimeFormatter.ofLocalizedDate(formatStyle)
+                            .withLocale(locale)
+                            .withZone(ZoneOffset.UTC)
+                            .format(TEST_INSTANT);
+
+                    DateTimeFormatter.ofLocalizedDateTime(formatStyle)
+                            .withLocale(locale)
+                            .withZone(ZoneOffset.UTC)
+                            .format(TEST_INSTANT);
+                } catch (RuntimeException cause) {
+                    throw new RuntimeException("locale:" + locale +
+                            " formatStyle:" + formatStyle.name(), cause);
+                }
+            }
+        }
+    }
+
+    /**
+     * Test {@link DateTimeFormatter#format(TemporalAccessor)} does not crash on available locales
+     * with all possible Chronologies.
+     */
+    @Test
+    public void test_format_allLocales_allChronologies() {
+        for (Locale locale : Locale.getAvailableLocales()) {
+            for (Chronology chronology : Chronology.getAvailableChronologies()) {
+                for (FormatStyle formatStyle : FormatStyle.values()) {
+                    try {
+                        DateTimeFormatter.ofLocalizedTime(formatStyle)
+                                .withLocale(locale)
+                                .withChronology(chronology)
+                                .withZone(ZoneOffset.UTC)
+                                .format(TEST_INSTANT);
+
+                        DateTimeFormatter.ofLocalizedDate(formatStyle)
+                                .withLocale(locale)
+                                .withChronology(chronology)
+                                .withZone(ZoneOffset.UTC)
+                                .format(TEST_INSTANT);
+
+                        DateTimeFormatter.ofLocalizedDateTime(formatStyle)
+                                .withLocale(locale)
+                                .withChronology(chronology)
+                                .withZone(ZoneOffset.UTC)
+                                .format(TEST_INSTANT);
+                    } catch (RuntimeException cause) {
+                        throw new RuntimeException("locale:" + locale +
+                                " formatStyle:" + formatStyle.name(), cause);
+                    }
+                }
+            }
+        }
+    }
 }
diff --git a/luni/src/test/java/libcore/libcore/icu/ICUTest.java b/luni/src/test/java/libcore/libcore/icu/ICUTest.java
index e98486d..a5577a5 100644
--- a/luni/src/test/java/libcore/libcore/icu/ICUTest.java
+++ b/luni/src/test/java/libcore/libcore/icu/ICUTest.java
@@ -237,6 +237,32 @@
     assertTrue(c.compare("AF", "af") < 0);
   }
 
+  public void testTransformIcuDateTimePattern_forJavaTime() {
+    // Example patterns coming from locale my-MM
+    assertTransformIcuDateTimePattern("B H:mm", "H:mm");
+    assertTransformIcuDateTimePattern("B HH:mm:ss", "HH:mm:ss");
+    assertTransformIcuDateTimePattern("dd-MM-yy B HH:mm:ss", "dd-MM-yy HH:mm:ss");
+    assertTransformIcuDateTimePattern("y၊ MMM d B HH:mm:ss", "y၊ MMM d HH:mm:ss");
+
+    // Other examples
+    assertTransformIcuDateTimePattern("H:mm B", "H:mm");
+    assertTransformIcuDateTimePattern("H:mm b", "H:mm");
+    assertTransformIcuDateTimePattern("b H:mm", "H:mm");
+    assertTransformIcuDateTimePattern("B H:mm:ss, E", "H:mm:ss, E");
+
+    // Examples with no effect
+    assertTransformIcuDateTimePattern("hh:mm b", "hh:mm b"); // No change for 12-hour format
+    assertTransformIcuDateTimePattern("hh:mm B", "hh:mm B"); // No change for 12-hour format
+    assertTransformIcuDateTimePattern("B h:mm:ss, E", "B h:mm:ss, E");
+    // No change when no hour is specified
+    assertTransformIcuDateTimePattern("dd-MM-yy B", "dd-MM-yy B");
+  }
+
+  private static void assertTransformIcuDateTimePattern(String input, String expectedOutput) {
+    String pattern = ICU.transformIcuDateTimePattern_forJavaTime(input);
+    assertEquals("input:" + input, expectedOutput, pattern);
+  }
+
   public void testSetDefault() {
       String current = ICU.getDefaultLocale();
 
diff --git a/mmodules/core_platform_api/api/legacy_platform/current.txt b/mmodules/core_platform_api/api/legacy_platform/current.txt
index d9e25ee..a4a2899 100644
--- a/mmodules/core_platform_api/api/legacy_platform/current.txt
+++ b/mmodules/core_platform_api/api/legacy_platform/current.txt
@@ -734,7 +734,6 @@
   public final class Class<T> implements java.lang.reflect.AnnotatedElement java.lang.reflect.GenericDeclaration java.io.Serializable java.lang.reflect.Type {
     method @dalvik.annotation.optimization.FastNative public java.lang.reflect.Field[] getDeclaredFieldsUnchecked(boolean);
     method @dalvik.annotation.optimization.FastNative public java.lang.reflect.Method[] getDeclaredMethodsUnchecked(boolean);
-    method public String getPackageName$();
   }
 
   public final class Math {
@@ -842,10 +841,6 @@
     method public java.util.Map.Entry<K,V> eldest();
   }
 
-  public final class Locale implements java.lang.Cloneable java.io.Serializable {
-    method public static String adjustLanguageCode(String);
-  }
-
 }
 
 package java.util.concurrent {
@@ -1008,10 +1003,6 @@
 
 package libcore.util {
 
-  public final class ArrayUtils {
-    method public static void throwsIfOutOfBounds(int, int, int);
-  }
-
   public final class EmptyArray {
     field public static final boolean[] BOOLEAN;
     field public static final byte[] BYTE;
@@ -1097,32 +1088,6 @@
 
 }
 
-package org.apache.harmony.dalvik {
-
-  public final class NativeTestTarget {
-    ctor public NativeTestTarget();
-    method public static void emptyInlineMethod();
-    method public static void emptyInternalStaticMethod();
-    method public void emptyJniMethod0();
-    method @dalvik.annotation.optimization.FastNative public void emptyJniMethod0_Fast();
-    method public void emptyJniMethod6(int, int, int, int, int, int);
-    method public void emptyJniMethod6L(String, String[], int[][], Object, Object[], Object[][][][]);
-    method @dalvik.annotation.optimization.FastNative public void emptyJniMethod6L_Fast(String, String[], int[][], Object, Object[], Object[][][][]);
-    method @dalvik.annotation.optimization.FastNative public void emptyJniMethod6_Fast(int, int, int, int, int, int);
-    method public static void emptyJniStaticMethod0();
-    method @dalvik.annotation.optimization.CriticalNative public static void emptyJniStaticMethod0_Critical();
-    method @dalvik.annotation.optimization.FastNative public static void emptyJniStaticMethod0_Fast();
-    method public static void emptyJniStaticMethod6(int, int, int, int, int, int);
-    method public static void emptyJniStaticMethod6L(String, String[], int[][], Object, Object[], Object[][][][]);
-    method @dalvik.annotation.optimization.FastNative public static void emptyJniStaticMethod6L_Fast(String, String[], int[][], Object, Object[], Object[][][][]);
-    method @dalvik.annotation.optimization.CriticalNative public static void emptyJniStaticMethod6_Critical(int, int, int, int, int, int);
-    method @dalvik.annotation.optimization.FastNative public static void emptyJniStaticMethod6_Fast(int, int, int, int, int, int);
-    method public static void emptyJniStaticSynchronizedMethod0();
-    method public void emptyJniSynchronizedMethod0();
-  }
-
-}
-
 package org.apache.harmony.dalvik.ddmc {
 
   public class Chunk {
@@ -1256,11 +1221,3 @@
 
 }
 
-package sun.util.locale {
-
-  public class LanguageTag {
-    method public static boolean isLanguage(String);
-  }
-
-}
-
diff --git a/non_openjdk_java_files.bp b/non_openjdk_java_files.bp
index fe3335d..b40556c 100644
--- a/non_openjdk_java_files.bp
+++ b/non_openjdk_java_files.bp
@@ -50,7 +50,6 @@
         "dalvik/src/main/java/dalvik/system/TemporaryDirectory.java",
         "dalvik/src/main/java/dalvik/system/VMDebug.java",
         "dalvik/src/main/java/dalvik/system/ZygoteHooks.java",
-        "dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java",
         "dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/Chunk.java",
         "dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/ChunkHandler.java",
         "dalvik/src/main/java/org/apache/harmony/dalvik/ddmc/DdmServer.java",
diff --git a/ojluni/annotations/mmodule/java/lang/Class.annotated.java b/ojluni/annotations/mmodule/java/lang/Class.annotated.java
index fd80abb..096a52b 100644
--- a/ojluni/annotations/mmodule/java/lang/Class.annotated.java
+++ b/ojluni/annotations/mmodule/java/lang/Class.annotated.java
@@ -83,7 +83,6 @@
 
 public java.lang.Package getPackage() { throw new RuntimeException("Stub!"); }
 
-@libcore.api.CorePlatformApi
 public java.lang.String getPackageName$() { throw new RuntimeException("Stub!"); }
 
 public java.lang.Class<?>[] getInterfaces() { throw new RuntimeException("Stub!"); }
diff --git a/ojluni/annotations/mmodule/java/util/Locale.annotated.java b/ojluni/annotations/mmodule/java/util/Locale.annotated.java
deleted file mode 100644
index d8aad03..0000000
--- a/ojluni/annotations/mmodule/java/util/Locale.annotated.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
- * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
- *
- * The original version of this source code and documentation
- * is copyrighted and owned by Taligent, Inc., a wholly-owned
- * subsidiary of IBM. These materials are provided under terms
- * of a License Agreement between Taligent and Sun. This technology
- * is protected by multiple US and International patents.
- *
- * This notice and attribution to Taligent may not be removed.
- * Taligent is a registered trademark of Taligent, Inc.
- *
- */
-
-
-package java.util;
-
-import java.text.MessageFormat;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-
-@SuppressWarnings({"unchecked", "deprecation", "all"})
-public final class Locale implements java.lang.Cloneable, java.io.Serializable {
-
-public Locale(java.lang.String language, java.lang.String country, java.lang.String variant) { throw new RuntimeException("Stub!"); }
-
-public Locale(java.lang.String language, java.lang.String country) { throw new RuntimeException("Stub!"); }
-
-public Locale(java.lang.String language) { throw new RuntimeException("Stub!"); }
-
-public static java.util.Locale getDefault() { throw new RuntimeException("Stub!"); }
-
-public static java.util.Locale getDefault(java.util.Locale.Category category) { throw new RuntimeException("Stub!"); }
-
-public static java.util.Locale initDefault() { throw new RuntimeException("Stub!"); }
-
-public static synchronized void setDefault(java.util.Locale newLocale) { throw new RuntimeException("Stub!"); }
-
-public static synchronized void setDefault(java.util.Locale.Category category, java.util.Locale newLocale) { throw new RuntimeException("Stub!"); }
-
-public static java.util.Locale[] getAvailableLocales() { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String[] getISOCountries() { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String[] getISOLanguages() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getLanguage() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getScript() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getCountry() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getVariant() { throw new RuntimeException("Stub!"); }
-
-public boolean hasExtensions() { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale stripExtensions() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getExtension(char key) { throw new RuntimeException("Stub!"); }
-
-public java.util.Set<java.lang.Character> getExtensionKeys() { throw new RuntimeException("Stub!"); }
-
-public java.util.Set<java.lang.String> getUnicodeLocaleAttributes() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getUnicodeLocaleType(java.lang.String key) { throw new RuntimeException("Stub!"); }
-
-public java.util.Set<java.lang.String> getUnicodeLocaleKeys() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String toString() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String toLanguageTag() { throw new RuntimeException("Stub!"); }
-
-public static java.util.Locale forLanguageTag(java.lang.String languageTag) { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getISO3Language() throws java.util.MissingResourceException { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getISO3Country() throws java.util.MissingResourceException { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayLanguage() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayLanguage(java.util.Locale locale) { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayScript() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayScript(java.util.Locale inLocale) { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayCountry() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayCountry(java.util.Locale locale) { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayVariant() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayVariant(java.util.Locale inLocale) { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayName() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getDisplayName(java.util.Locale locale) { throw new RuntimeException("Stub!"); }
-
-public java.lang.Object clone() { throw new RuntimeException("Stub!"); }
-
-public int hashCode() { throw new RuntimeException("Stub!"); }
-
-public boolean equals(java.lang.Object obj) { throw new RuntimeException("Stub!"); }
-
-@libcore.api.CorePlatformApi
-public static java.lang.String adjustLanguageCode(java.lang.String languageCode) { throw new RuntimeException("Stub!"); }
-
-public static java.util.List<java.util.Locale> filter(java.util.List<java.util.Locale.LanguageRange> priorityList, java.util.Collection<java.util.Locale> locales, java.util.Locale.FilteringMode mode) { throw new RuntimeException("Stub!"); }
-
-public static java.util.List<java.util.Locale> filter(java.util.List<java.util.Locale.LanguageRange> priorityList, java.util.Collection<java.util.Locale> locales) { throw new RuntimeException("Stub!"); }
-
-public static java.util.List<java.lang.String> filterTags(java.util.List<java.util.Locale.LanguageRange> priorityList, java.util.Collection<java.lang.String> tags, java.util.Locale.FilteringMode mode) { throw new RuntimeException("Stub!"); }
-
-public static java.util.List<java.lang.String> filterTags(java.util.List<java.util.Locale.LanguageRange> priorityList, java.util.Collection<java.lang.String> tags) { throw new RuntimeException("Stub!"); }
-
-public static java.util.Locale lookup(java.util.List<java.util.Locale.LanguageRange> priorityList, java.util.Collection<java.util.Locale> locales) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String lookupTag(java.util.List<java.util.Locale.LanguageRange> priorityList, java.util.Collection<java.lang.String> tags) { throw new RuntimeException("Stub!"); }
-
-public static final java.util.Locale CANADA;
-static { CANADA = null; }
-
-public static final java.util.Locale CANADA_FRENCH;
-static { CANADA_FRENCH = null; }
-
-public static final java.util.Locale CHINA;
-static { CHINA = null; }
-
-public static final java.util.Locale CHINESE;
-static { CHINESE = null; }
-
-public static final java.util.Locale ENGLISH;
-static { ENGLISH = null; }
-
-public static final java.util.Locale FRANCE;
-static { FRANCE = null; }
-
-public static final java.util.Locale FRENCH;
-static { FRENCH = null; }
-
-public static final java.util.Locale GERMAN;
-static { GERMAN = null; }
-
-public static final java.util.Locale GERMANY;
-static { GERMANY = null; }
-
-public static final java.util.Locale ITALIAN;
-static { ITALIAN = null; }
-
-public static final java.util.Locale ITALY;
-static { ITALY = null; }
-
-public static final java.util.Locale JAPAN;
-static { JAPAN = null; }
-
-public static final java.util.Locale JAPANESE;
-static { JAPANESE = null; }
-
-public static final java.util.Locale KOREA;
-static { KOREA = null; }
-
-public static final java.util.Locale KOREAN;
-static { KOREAN = null; }
-
-public static final java.util.Locale PRC;
-static { PRC = null; }
-
-public static final char PRIVATE_USE_EXTENSION = 120; // 0x0078 'x'
-
-public static final java.util.Locale ROOT;
-static { ROOT = null; }
-
-public static final java.util.Locale SIMPLIFIED_CHINESE;
-static { SIMPLIFIED_CHINESE = null; }
-
-public static final java.util.Locale TAIWAN;
-static { TAIWAN = null; }
-
-public static final java.util.Locale TRADITIONAL_CHINESE;
-static { TRADITIONAL_CHINESE = null; }
-
-public static final java.util.Locale UK;
-static { UK = null; }
-
-public static final char UNICODE_LOCALE_EXTENSION = 117; // 0x0075 'u'
-
-public static final java.util.Locale US;
-static { US = null; }
-@SuppressWarnings({"unchecked", "deprecation", "all"})
-public static final class Builder {
-
-public Builder() { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder setLocale(java.util.Locale locale) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder setLanguageTag(java.lang.String languageTag) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder setLanguage(java.lang.String language) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder setScript(java.lang.String script) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder setRegion(java.lang.String region) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder setVariant(java.lang.String variant) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder setExtension(char key, java.lang.String value) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder setUnicodeLocaleKeyword(java.lang.String key, java.lang.String type) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder addUnicodeLocaleAttribute(java.lang.String attribute) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder removeUnicodeLocaleAttribute(java.lang.String attribute) { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder clear() { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale.Builder clearExtensions() { throw new RuntimeException("Stub!"); }
-
-public java.util.Locale build() { throw new RuntimeException("Stub!"); }
-}
-
-@SuppressWarnings({"unchecked", "deprecation", "all"})
-public static enum Category {
-DISPLAY,
-FORMAT;
-}
-
-@SuppressWarnings({"unchecked", "deprecation", "all"})
-public static enum FilteringMode {
-AUTOSELECT_FILTERING,
-EXTENDED_FILTERING,
-IGNORE_EXTENDED_RANGES,
-MAP_EXTENDED_RANGES,
-REJECT_EXTENDED_RANGES;
-}
-
-@SuppressWarnings({"unchecked", "deprecation", "all"})
-public static final class LanguageRange {
-
-public LanguageRange(java.lang.String range) { throw new RuntimeException("Stub!"); }
-
-public LanguageRange(java.lang.String range, double weight) { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getRange() { throw new RuntimeException("Stub!"); }
-
-public double getWeight() { throw new RuntimeException("Stub!"); }
-
-public static java.util.List<java.util.Locale.LanguageRange> parse(java.lang.String ranges) { throw new RuntimeException("Stub!"); }
-
-public static java.util.List<java.util.Locale.LanguageRange> parse(java.lang.String ranges, java.util.Map<java.lang.String, java.util.List<java.lang.String>> map) { throw new RuntimeException("Stub!"); }
-
-public static java.util.List<java.util.Locale.LanguageRange> mapEquivalents(java.util.List<java.util.Locale.LanguageRange> priorityList, java.util.Map<java.lang.String, java.util.List<java.lang.String>> map) { throw new RuntimeException("Stub!"); }
-
-public int hashCode() { throw new RuntimeException("Stub!"); }
-
-public boolean equals(java.lang.Object obj) { throw new RuntimeException("Stub!"); }
-
-public static final double MAX_WEIGHT = 1.0;
-
-public static final double MIN_WEIGHT = 0.0;
-}
-
-}
-
diff --git a/ojluni/annotations/mmodule/sun/util/locale/LanguageTag.annotated.java b/ojluni/annotations/mmodule/sun/util/locale/LanguageTag.annotated.java
deleted file mode 100644
index eaec071..0000000
--- a/ojluni/annotations/mmodule/sun/util/locale/LanguageTag.annotated.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- *******************************************************************************
- * Copyright (C) 2010, International Business Machines Corporation and         *
- * others. All Rights Reserved.                                                *
- *******************************************************************************
- */
-
-package sun.util.locale;
-
-@libcore.api.Hide
-@libcore.api.CorePlatformApi
-@SuppressWarnings({"unchecked", "deprecation", "all"})
-public class LanguageTag {
-
-LanguageTag() { throw new RuntimeException("Stub!"); }
-
-public static sun.util.locale.LanguageTag parse(java.lang.String languageTag, sun.util.locale.ParseStatus sts) { throw new RuntimeException("Stub!"); }
-
-public static sun.util.locale.LanguageTag parseLocale(sun.util.locale.BaseLocale baseLocale, sun.util.locale.LocaleExtensions localeExtensions) { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getLanguage() { throw new RuntimeException("Stub!"); }
-
-public java.util.List<java.lang.String> getExtlangs() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getScript() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getRegion() { throw new RuntimeException("Stub!"); }
-
-public java.util.List<java.lang.String> getVariants() { throw new RuntimeException("Stub!"); }
-
-public java.util.List<java.lang.String> getExtensions() { throw new RuntimeException("Stub!"); }
-
-public java.lang.String getPrivateuse() { throw new RuntimeException("Stub!"); }
-
-@libcore.api.CorePlatformApi
-public static boolean isLanguage(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static boolean isExtlang(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static boolean isScript(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static boolean isRegion(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static boolean isVariant(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static boolean isExtensionSingleton(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static boolean isExtensionSingletonChar(char c) { throw new RuntimeException("Stub!"); }
-
-public static boolean isExtensionSubtag(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static boolean isPrivateusePrefix(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static boolean isPrivateusePrefixChar(char c) { throw new RuntimeException("Stub!"); }
-
-public static boolean isPrivateuseSubtag(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizeLanguage(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizeExtlang(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizeScript(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizeRegion(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizeVariant(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizeExtension(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizeExtensionSingleton(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizeExtensionSubtag(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizePrivateuse(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public static java.lang.String canonicalizePrivateuseSubtag(java.lang.String s) { throw new RuntimeException("Stub!"); }
-
-public java.lang.String toString() { throw new RuntimeException("Stub!"); }
-
-public static final java.lang.String PRIVATEUSE = "x";
-
-public static final java.lang.String PRIVUSE_VARIANT_PREFIX = "lvariant";
-
-public static final java.lang.String SEP = "-";
-
-public static final java.lang.String UNDETERMINED = "und";
-}
-
diff --git a/ojluni/annotations/sdk/nullability/java/lang/Class.annotated.java b/ojluni/annotations/sdk/nullability/java/lang/Class.annotated.java
index cb99f54..ab0cc39 100644
--- a/ojluni/annotations/sdk/nullability/java/lang/Class.annotated.java
+++ b/ojluni/annotations/sdk/nullability/java/lang/Class.annotated.java
@@ -81,6 +81,8 @@
 
 @libcore.util.Nullable public java.lang.Package getPackage() { throw new RuntimeException("Stub!"); }
 
+@libcore.util.NonNull public java.lang.String getPackageName() { throw new RuntimeException("Stub!"); }
+
 public java.lang.@libcore.util.NonNull Class<?> @libcore.util.NonNull [] getInterfaces() { throw new RuntimeException("Stub!"); }
 
 public java.lang.reflect.@libcore.util.NonNull Type @libcore.util.NonNull [] getGenericInterfaces() { throw new RuntimeException("Stub!"); }
diff --git a/ojluni/src/main/java/java/lang/Byte.java b/ojluni/src/main/java/java/lang/Byte.java
index deb4ecb..bc397f9 100644
--- a/ojluni/src/main/java/java/lang/Byte.java
+++ b/ojluni/src/main/java/java/lang/Byte.java
@@ -25,6 +25,8 @@
 
 package java.lang;
 
+// Android-removed: Unsupported @HotSpotIntrinsicCandidate annotation.
+// import jdk.internal.HotSpotIntrinsicCandidate;
 import libcore.util.HexEncoding;
 
 /**
@@ -41,7 +43,7 @@
  * @author  Nakul Saraiya
  * @author  Joseph D. Darcy
  * @see     java.lang.Number
- * @since   JDK1.1
+ * @since   1.1
  */
 public final class Byte extends Number implements Comparable<Byte> {
 
@@ -100,6 +102,8 @@
      * @return a {@code Byte} instance representing {@code b}.
      * @since  1.5
      */
+    // Android-removed: Unsupported @HotSpotIntrinsicCandidate annotation.
+    // @HotSpotIntrinsicCandidate
     public static Byte valueOf(byte b) {
         final int offset = 128;
         return ByteCache.cache[(int)b + offset];
@@ -296,7 +300,13 @@
      *
      * @param value     the value to be represented by the
      *                  {@code Byte}.
+     *
+     * @deprecated
+     * It is rarely appropriate to use this constructor. The static factory
+     * {@link #valueOf(byte)} is generally a better choice, as it is
+     * likely to yield significantly better space and time performance.
      */
+    @Deprecated(since="9")
     public Byte(byte value) {
         this.value = value;
     }
@@ -310,10 +320,16 @@
      *
      * @param s         the {@code String} to be converted to a
      *                  {@code Byte}
-     * @throws           NumberFormatException If the {@code String}
+     * @throws          NumberFormatException if the {@code String}
      *                  does not contain a parsable {@code byte}.
-     * @see        java.lang.Byte#parseByte(java.lang.String, int)
+     *
+     * @deprecated
+     * It is rarely appropriate to use this constructor.
+     * Use {@link #parseByte(String)} to convert a string to a
+     * {@code byte} primitive, or use {@link #valueOf(String)}
+     * to convert a string to a {@code Byte} object.
      */
+    @Deprecated(since="9")
     public Byte(String s) throws NumberFormatException {
         this.value = parseByte(s, 10);
     }
@@ -322,6 +338,8 @@
      * Returns the value of this {@code Byte} as a
      * {@code byte}.
      */
+    // Android-removed: Unsupported @HotSpotIntrinsicCandidate annotation.
+    // @HotSpotIntrinsicCandidate
     public byte byteValue() {
         return value;
     }
@@ -461,6 +479,22 @@
     }
 
     /**
+     * Compares two {@code byte} values numerically treating the values
+     * as unsigned.
+     *
+     * @param  x the first {@code byte} to compare
+     * @param  y the second {@code byte} to compare
+     * @return the value {@code 0} if {@code x == y}; a value less
+     *         than {@code 0} if {@code x < y} as unsigned values; and
+     *         a value greater than {@code 0} if {@code x > y} as
+     *         unsigned values
+     * @since 9
+     */
+    public static int compareUnsigned(byte x, byte y) {
+        return Byte.toUnsignedInt(x) - Byte.toUnsignedInt(y);
+    }
+
+    /**
      * Converts the argument to an {@code int} by an unsigned
      * conversion.  In an unsigned conversion to an {@code int}, the
      * high-order 24 bits of the {@code int} are zero and the
diff --git a/ojluni/src/main/java/java/lang/Class.java b/ojluni/src/main/java/java/lang/Class.java
index 478c339..7925408 100644
--- a/ojluni/src/main/java/java/lang/Class.java
+++ b/ojluni/src/main/java/java/lang/Class.java
@@ -896,22 +896,53 @@
     public Package getPackage() {
         ClassLoader loader = getClassLoader();
         if (loader != null) {
-            String packageName = getPackageName$();
+            String packageName = getPackageName();
             return packageName != null ? loader.getPackage(packageName) : null;
         }
         return null;
     }
 
     /**
-     * Returns the package name of this class. This returns null for classes in
-     * the default package.
+     * Returns the fully qualified package name.
      *
-     * @hide
+     * <p> If this class is a top level class, then this method returns the fully
+     * qualified name of the package that the class is a member of, or the
+     * empty string if the class is in an unnamed package.
+     *
+     * <p> If this class is a member class, then this method is equivalent to
+     * invoking {@code getPackageName()} on the {@linkplain #getEnclosingClass
+     * enclosing class}.
+     *
+     * <p> If this class is a {@linkplain #isLocalClass local class} or an {@linkplain
+     * #isAnonymousClass() anonymous class}, then this method is equivalent to
+     * invoking {@code getPackageName()} on the {@linkplain #getDeclaringClass
+     * declaring class} of the {@linkplain #getEnclosingMethod enclosing method} or
+     * {@linkplain #getEnclosingConstructor enclosing constructor}.
+     *
+     * <p> If this class represents an array type then this method returns the
+     * package name of the element type. If this class represents a primitive
+     * type or void then the package name "{@code java.lang}" is returned.
+     *
+     * @return the fully qualified package name
+     *
+     * @since 9
+     * @spec JPMS
+     * @jls 6.7  Fully Qualified Names
      */
-    public String getPackageName$() {
-        String name = getName();
-        int last = name.lastIndexOf('.');
-        return last == -1 ? null : name.substring(0, last);
+    public String getPackageName() {
+            // BEGIN Android-changed: Don't use a private field as a cache.
+            Class<?> c = this;
+            while (c.isArray()) {
+                c = c.getComponentType();
+            }
+            if (c.isPrimitive()) {
+                return "java.lang";
+            } else {
+                String cn = c.getName();
+                int dot = cn.lastIndexOf('.');
+                return (dot != -1) ? cn.substring(0, dot).intern() : "";
+            }
+            // END Android-changed: Don't use a private field as a cache.
     }
 
 
diff --git a/ojluni/src/main/java/java/lang/Deprecated.java b/ojluni/src/main/java/java/lang/Deprecated.java
index 58a0691..0abadaa 100644
--- a/ojluni/src/main/java/java/lang/Deprecated.java
+++ b/ojluni/src/main/java/java/lang/Deprecated.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,17 +29,77 @@
 import static java.lang.annotation.ElementType.*;
 
 /**
- * A program element annotated &#64;Deprecated is one that programmers
- * are discouraged from using, typically because it is dangerous,
- * or because a better alternative exists.  Compilers warn when a
- * deprecated program element is used or overridden in non-deprecated code.
+ * A program element annotated {@code @Deprecated} is one that programmers
+ * are discouraged from using. An element may be deprecated for any of several
+ * reasons, for example, its usage is likely to lead to errors; it may
+ * be changed incompatibly or removed in a future version; it has been
+ * superseded by a newer, usually preferable alternative; or it is obsolete.
+ *
+ * <p>Compilers issue warnings when a deprecated program element is used or
+ * overridden in non-deprecated code. Use of the {@code @Deprecated}
+ * annotation on a local variable declaration or on a parameter declaration
+ * or a package declaration has no effect on the warnings issued by a compiler.
+ *
+ * <p>When a module is deprecated, the use of that module in {@code
+ * requires}, but not in {@code exports} or {@code opens} clauses causes
+ * a warning to be issued. A module being deprecated does <em>not</em> cause
+ * warnings to be issued for uses of types within the module.
+ *
+ * <p>This annotation type has a string-valued element {@code since}. The value
+ * of this element indicates the version in which the annotated program element
+ * was first deprecated.
+ *
+ * <p>This annotation type has a boolean-valued element {@code forRemoval}.
+ * A value of {@code true} indicates intent to remove the annotated program
+ * element in a future version. A value of {@code false} indicates that use of
+ * the annotated program element is discouraged, but at the time the program
+ * element was annotated, there was no specific intent to remove it.
+ *
+ * @apiNote
+ * It is strongly recommended that the reason for deprecating a program element
+ * be explained in the documentation, using the {@code @deprecated}
+ * javadoc tag. The documentation should also suggest and link to a
+ * recommended replacement API, if applicable. A replacement API often
+ * has subtly different semantics, so such issues should be discussed as
+ * well.
+ *
+ * <p>It is recommended that a {@code since} value be provided with all newly
+ * annotated program elements. Note that {@code since} cannot be mandatory,
+ * as there are many existing annotations that lack this element value.
+ *
+ * <p>There is no defined order among annotation elements. As a matter of
+ * style, the {@code since} element should be placed first.
+ *
+ * <p>The {@code @Deprecated} annotation should always be present if
+ * the {@code @deprecated} javadoc tag is present, and vice-versa.
  *
  * @author  Neal Gafter
  * @since 1.5
- * @jls 9.6.3.6 @Deprecated
+ * @jls 9.6.4.6 @Deprecated
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
+// Androrid-changed: Modules not supported yet
+// @Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, MODULE, PARAMETER, TYPE})
 @Target(value={CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE})
 public @interface Deprecated {
+    /**
+     * Returns the version in which the annotated element became deprecated.
+     * The version string is in the same format and namespace as the value of
+     * the {@code @since} javadoc tag. The default value is the empty
+     * string.
+     *
+     * @return the version string
+     * @since 9
+     */
+    String since() default "";
+
+    /**
+     * Indicates whether the annotated element is subject to removal in a
+     * future version. The default value is {@code false}.
+     *
+     * @return whether the element is subject to removal
+     * @since 9
+     */
+    boolean forRemoval() default false;
 }
diff --git a/ojluni/src/main/java/java/lang/Short.java b/ojluni/src/main/java/java/lang/Short.java
index 9fb3913..dd6e2e2 100644
--- a/ojluni/src/main/java/java/lang/Short.java
+++ b/ojluni/src/main/java/java/lang/Short.java
@@ -25,6 +25,9 @@
 
 package java.lang;
 
+// Android-removed: unsupported @HotSpotIntrinsicCandidate annotation.
+// import jdk.internal.HotSpotIntrinsicCandidate;
+
 /**
  * The {@code Short} class wraps a value of primitive type {@code
  * short} in an object.  An object of type {@code Short} contains a
@@ -38,7 +41,7 @@
  * @author  Nakul Saraiya
  * @author  Joseph D. Darcy
  * @see     java.lang.Number
- * @since   JDK1.1
+ * @since   1.1
  */
 public final class Short extends Number implements Comparable<Short> {
 
@@ -227,6 +230,8 @@
      * @return a {@code Short} instance representing {@code s}.
      * @since  1.5
      */
+    // Android-removed: unsupported @HotSpotIntrinsicCandidate annotation.
+    // @HotSpotIntrinsicCandidate
     public static Short valueOf(short s) {
         final int offset = 128;
         int sAsInt = s;
@@ -299,7 +304,13 @@
      *
      * @param value     the value to be represented by the
      *                  {@code Short}.
+     *
+     * @deprecated
+     * It is rarely appropriate to use this constructor. The static factory
+     * {@link #valueOf(short)} is generally a better choice, as it is
+     * likely to yield significantly better space and time performance.
      */
+    @Deprecated(since="9")
     public Short(short value) {
         this.value = value;
     }
@@ -315,8 +326,14 @@
      *          {@code Short}
      * @throws  NumberFormatException If the {@code String}
      *          does not contain a parsable {@code short}.
-     * @see     java.lang.Short#parseShort(java.lang.String, int)
+     *
+     * @deprecated
+     * It is rarely appropriate to use this constructor.
+     * Use {@link #parseShort(String)} to convert a string to a
+     * {@code short} primitive, or use {@link #valueOf(String)}
+     * to convert a string to a {@code Short} object.
      */
+    @Deprecated(since="9")
     public Short(String s) throws NumberFormatException {
         this.value = parseShort(s, 10);
     }
@@ -334,6 +351,8 @@
      * Returns the value of this {@code Short} as a
      * {@code short}.
      */
+    // Android-removed: unsupported @HotSpotIntrinsicCandidate annotation.
+    // @HotSpotIntrinsicCandidate
     public short shortValue() {
         return value;
     }
@@ -464,6 +483,22 @@
     }
 
     /**
+     * Compares two {@code short} values numerically treating the values
+     * as unsigned.
+     *
+     * @param  x the first {@code short} to compare
+     * @param  y the second {@code short} to compare
+     * @return the value {@code 0} if {@code x == y}; a value less
+     *         than {@code 0} if {@code x < y} as unsigned values; and
+     *         a value greater than {@code 0} if {@code x > y} as
+     *         unsigned values
+     * @since 9
+     */
+    public static int compareUnsigned(short x, short y) {
+        return Short.toUnsignedInt(x) - Short.toUnsignedInt(y);
+    }
+
+    /**
      * The number of bits used to represent a {@code short} value in two's
      * complement binary form.
      * @since 1.5
@@ -487,6 +522,8 @@
      *     the bytes in the specified {@code short} value.
      * @since 1.5
      */
+    // Android-removed: unsupported @HotSpotIntrinsicCandidate annotation.
+    // @HotSpotIntrinsicCandidate
     public static short reverseBytes(short i) {
         return (short) (((i & 0xFF00) >> 8) | (i << 8));
     }
diff --git a/ojluni/src/main/java/java/net/IDN.java b/ojluni/src/main/java/java/net/IDN.java
index 36559cf..5bce94c 100644
--- a/ojluni/src/main/java/java/net/IDN.java
+++ b/ojluni/src/main/java/java/net/IDN.java
@@ -25,7 +25,7 @@
  */
 package java.net;
 
-import android.icu.text.IDNA;
+import com.android.icu.text.ExtendedIDNA;
 
 /**
  * Provides methods to convert internationalized domain names (IDNs) between
@@ -105,7 +105,7 @@
     public static String toASCII(String input, int flag) {
         // BEGIN Android-changed: Use ICU4J implementation.
         try {
-            return IDNA.convertIDNToASCII(input, flag).toString();
+            return ExtendedIDNA.convertIDNToASCII(input, flag).toString();
         } catch (android.icu.text.StringPrepParseException e) {
             // b/113787610: "." is a valid IDN but is rejected by ICU.
             // Usage is relatively uncommon, so only check for it if ICU throws.
@@ -162,7 +162,7 @@
         try {
             // ICU only translates separators to ASCII for toASCII.
             // Java expects the translation for toUnicode too.
-            return convertFullStop(IDNA.convertIDNToUnicode(input, flag)).toString();
+            return convertFullStop(ExtendedIDNA.convertIDNToUnicode(input, flag)).toString();
         } catch (android.icu.text.StringPrepParseException e) {
             // The RI documentation explicitly states that if the conversion was unsuccessful
             // the original string is returned.
diff --git a/ojluni/src/main/java/java/nio/charset/Charset.java b/ojluni/src/main/java/java/nio/charset/Charset.java
index cdfbd09..2571569 100755
--- a/ojluni/src/main/java/java/nio/charset/Charset.java
+++ b/ojluni/src/main/java/java/nio/charset/Charset.java
@@ -26,7 +26,7 @@
 
 package java.nio.charset;
 
-import com.android.icu.charset.CharsetICU;
+import com.android.icu.charset.CharsetFactory;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
@@ -508,7 +508,7 @@
 
         // Android-changed: Drop support for "standard" and "extended"
         // providers.
-        if ((cs = CharsetICU.charsetForName(charsetName))  != null ||
+        if ((cs = CharsetFactory.create(charsetName))  != null ||
             (cs = lookupViaProviders(charsetName))              != null)
         {
             cache(charsetName, cs);
@@ -628,8 +628,8 @@
                     TreeMap<String,Charset> m =
                         new TreeMap<String,Charset>(
                             ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
-                    for (String charsetName : CharsetICU.getAvailableCharsetNames()) {
-                        Charset charset = CharsetICU.charsetForName(charsetName);
+                    for (String charsetName : CharsetFactory.getAvailableCharsetNames()) {
+                        Charset charset = CharsetFactory.create(charsetName);
                         m.put(charset.name(), charset);
                     }
                     // Android-changed: No more "standard" provider.
diff --git a/ojluni/src/main/java/java/text/DecimalFormat.java b/ojluni/src/main/java/java/text/DecimalFormat.java
index 547770c..1dc430c 100644
--- a/ojluni/src/main/java/java/text/DecimalFormat.java
+++ b/ojluni/src/main/java/java/text/DecimalFormat.java
@@ -54,6 +54,8 @@
 import libcore.icu.LocaleData;
 import android.icu.math.MathContext;
 
+import com.android.icu.text.CompatibleDecimalFormatFactory;
+
 /**
  * <code>DecimalFormat</code> is a concrete subclass of
  * <code>NumberFormat</code> that formats decimal numbers. It has a variety of
@@ -486,10 +488,9 @@
      * {@link #icuDecimalFormat} in the process. This should only be called from constructors.
      */
     private void initPattern(String pattern) {
-        this.icuDecimalFormat =  new android.icu.text.DecimalFormat(pattern,
-                symbols.getIcuDecimalFormatSymbols());
         // Android-changed: Compatibility mode for j.t.DecimalFormat. http://b/112355520
-        icuDecimalFormat.setParseJavaCompatible(true);
+        this.icuDecimalFormat = CompatibleDecimalFormatFactory.create(pattern,
+                symbols.getIcuDecimalFormatSymbols());
         updateFieldsFromIcu();
     }
 
diff --git a/ojluni/src/main/java/java/text/SimpleDateFormat.java b/ojluni/src/main/java/java/text/SimpleDateFormat.java
index ca5a504..b03ba0a 100644
--- a/ojluni/src/main/java/java/text/SimpleDateFormat.java
+++ b/ojluni/src/main/java/java/text/SimpleDateFormat.java
@@ -71,6 +71,8 @@
 
 // Android-changed: Added supported API level, removed unnecessary <br>
 // Android-changed: Clarified info about X symbol time zone parsing
+// Android-changed: Changed MMMMM to MMMM in month format example (ICU behavior).
+// http://b/147860740
 /**
  * <code>SimpleDateFormat</code> is a concrete class for formatting and
  * parsing dates in a locale-sensitive manner. It allows for formatting
@@ -422,7 +424,7 @@
  *         <td><code>"K:mm a, z"</code>
  *         <td><code>0:08 PM, PDT</code>
  *     <tr style="background-color: rgb(238, 238, 255);">
- *         <td><code>"yyyyy.MMMMM.dd GGG hh:mm aaa"</code>
+ *         <td><code>"yyyyy.MMMM.dd GGG hh:mm aaa"</code>
  *         <td><code>02001.July.04 AD 12:08 PM</code>
  *     <tr>
  *         <td><code>"EEE, d MMM yyyy HH:mm:ss Z"</code>
diff --git a/ojluni/src/main/java/java/time/TEST_MAPPING b/ojluni/src/main/java/java/time/TEST_MAPPING
index 5b24483..54d2ea6 100644
--- a/ojluni/src/main/java/java/time/TEST_MAPPING
+++ b/ojluni/src/main/java/java/time/TEST_MAPPING
@@ -7,7 +7,9 @@
           "include-filter": "libcore.java.time"
         }
       ]
-    },
+    }
+  ],
+  "presubmit-large": [
     {
       "name": "CtsLibcoreOjTestCases",
       "options": [
@@ -23,4 +25,4 @@
       ]
     }
   ]
-}
\ No newline at end of file
+}
diff --git a/ojluni/src/main/java/java/time/format/DateTimeFormatterBuilder.java b/ojluni/src/main/java/java/time/format/DateTimeFormatterBuilder.java
index f24f42a..fff8d9a 100644
--- a/ojluni/src/main/java/java/time/format/DateTimeFormatterBuilder.java
+++ b/ojluni/src/main/java/java/time/format/DateTimeFormatterBuilder.java
@@ -77,6 +77,10 @@
 import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
 import static java.time.temporal.ChronoField.YEAR;
 
+import com.android.icu.util.ExtendedCalendar;
+
+import libcore.icu.ICU;
+
 import java.lang.ref.SoftReference;
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -209,14 +213,20 @@
             throw new IllegalArgumentException("Either dateStyle or timeStyle must be non-null");
         }
 
-        // Android-changed: get format string from ICU.
+        // BEGIN Android-changed: get format string from ICU.
         // LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
         //         .getLocaleResources(locale);
         // String pattern = lr.getJavaTimeDateTimePattern(
         //         convertStyle(timeStyle), convertStyle(dateStyle), chrono.getCalendarType());
-        String pattern = Calendar.getDateTimeFormatString(
-                ULocale.forLocale(locale), chrono.getCalendarType(),
-                convertStyle(dateStyle), convertStyle(timeStyle));
+        ExtendedCalendar extendedCalendar = ICU.getExtendedCalendar(locale,
+                chrono.getCalendarType());
+        String pattern = extendedCalendar.getDateTimePattern(convertStyle(dateStyle),
+                convertStyle(timeStyle));
+        // Transform the pattern coming from ICU because DateTimeFormatter does not handle some date
+        // symbols, e.g. 'B' / 'b', and thus we use a heuristic algorithm to remove the symbol.
+        // See http://b/174804526.
+        pattern = ICU.transformIcuDateTimePattern_forJavaTime(pattern);
+        // END Android-changed: get format string from ICU.
         return pattern;
     }
 
diff --git a/ojluni/src/main/java/java/util/Locale.java b/ojluni/src/main/java/java/util/Locale.java
index 1ce4a202..80f9ed7 100644
--- a/ojluni/src/main/java/java/util/Locale.java
+++ b/ojluni/src/main/java/java/util/Locale.java
@@ -2750,24 +2750,6 @@
     }
     */
 
-    // BEGIN Android-added: adjustLanguageCode(), for internal use only.
-    /** @hide for internal use only. */
-    public static String adjustLanguageCode(String languageCode) {
-        String adjusted = languageCode.toLowerCase(Locale.US);
-        // Map new language codes to the obsolete language
-        // codes so the correct resource bundles will be used.
-        if (languageCode.equals("he")) {
-            adjusted = "iw";
-        } else if (languageCode.equals("id")) {
-            adjusted = "in";
-        } else if (languageCode.equals("yi")) {
-            adjusted = "ji";
-        }
-
-        return adjusted;
-    }
-    // END Android-added: adjustLanguageCode(), for internal use only.
-
     /**
      * Enum for locale categories.  These locale categories are used to get/set
      * the default locale for the specific functionality represented by the
diff --git a/ojluni/src/main/java/java/util/TimeZone.java b/ojluni/src/main/java/java/util/TimeZone.java
index 89dcbfc..265a59d 100644
--- a/ojluni/src/main/java/java/util/TimeZone.java
+++ b/ojluni/src/main/java/java/util/TimeZone.java
@@ -42,6 +42,8 @@
 import android.icu.text.TimeZoneNames;
 import com.android.i18n.timezone.ZoneInfoData;
 import com.android.i18n.timezone.ZoneInfoDb;
+import com.android.icu.util.ExtendedTimeZone;
+
 import java.io.IOException;
 import java.io.Serializable;
 import java.time.ZoneId;
@@ -745,7 +747,7 @@
         }
         defaultTimeZone = timeZone != null ? (TimeZone) timeZone.clone() : null;
         // Android-changed: notify ICU4J of changed default TimeZone.
-        android.icu.util.TimeZone.setICUDefault(null);
+        ExtendedTimeZone.clearDefaultTimeZone();
     }
 
     /**
diff --git a/openjdk_java_files.bp b/openjdk_java_files.bp
index 4af083f..a9f1dee 100644
--- a/openjdk_java_files.bp
+++ b/openjdk_java_files.bp
@@ -1425,7 +1425,6 @@
         "ojluni/src/main/java/sun/security/util/DerEncoder.java",
         "ojluni/src/main/java/sun/security/util/ObjectIdentifier.java",
         "ojluni/src/main/java/sun/security/x509/AlgorithmId.java",
-        "ojluni/src/main/java/sun/util/locale/LanguageTag.java",
     ],
 }
 
@@ -1799,6 +1798,7 @@
         "ojluni/src/main/java/sun/util/locale/BaseLocale.java",
         "ojluni/src/main/java/sun/util/locale/Extension.java",
         "ojluni/src/main/java/sun/util/locale/InternalLocaleBuilder.java",
+        "ojluni/src/main/java/sun/util/locale/LanguageTag.java",
         "ojluni/src/main/java/sun/util/locale/LocaleEquivalentMaps.java",
         "ojluni/src/main/java/sun/util/locale/LocaleExtensions.java",
         "ojluni/src/main/java/sun/util/locale/LocaleMatcher.java",