Merge changes I0308ddf9,I3227c00e,I76ba1af4,Id27c561a

* changes:
  8u121-b13 integration for java.net - Document Android changes
  Integrate upstream changes forgotten in the update to OpenJDK 8u121-b13
  Remove unncessary hostname assignment in Inet6Address.initif
  Remove DatagramSocket.setNetworkInterface
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..2230ac7
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,3 @@
+build = [
+    "NativeCode.bp",
+]
diff --git a/Android.mk b/Android.mk
index 3c25583..1427f4b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -29,11 +29,6 @@
 include $(LOCAL_PATH)/JavaLibrary.mk
 
 #
-# Include the definitions to build the native code.
-#
-
-include $(LOCAL_PATH)/NativeCode.mk
-
 # Disable test modules if LIBCORE_SKIP_TESTS environment variable is set.
 #
 
diff --git a/NativeCode.bp b/NativeCode.bp
new file mode 100644
index 0000000..3b63072
--- /dev/null
+++ b/NativeCode.bp
@@ -0,0 +1,205 @@
+// 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.
+
+//
+// Definitions for building the native code needed for the core library.
+//
+
+// Defaults that apply to all of the modules
+cc_defaults {
+    name: "core_native_defaults",
+    host_supported: true,
+    local_include_dirs: ["include"],
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+    ],
+    cppflags = ["-DU_USING_ICU_NAMESPACE=0"],
+
+    static_libs: [
+        "libbase",
+        "libfdlibm",
+    ],
+
+    shared_libs: [
+        "liblog",
+        "libnativehelper",
+    ],
+
+    host_ldlibs: [
+        "-ldl",
+        "-lpthread",
+    ],
+
+    target: {
+        linux: {
+            host_ldlibs: ["-lrt"],
+        },
+        darwin: {
+            enabled: false,
+        },
+    },
+}
+
+cc_library_shared {
+    name: "libjavacore",
+    defaults: ["core_native_defaults"],
+    srcs: [
+        ":luni_native_srcs",
+        "dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp"
+    ],
+
+    shared_libs: [
+        "libcrypto",
+        "libexpat",
+        "libicuuc",
+        "libicui18n",
+        "libnativehelper",
+    ],
+    static_libs: [
+        "libziparchive",
+        "libbase",
+    ],
+    target: {
+        android: {
+            shared_libs: [
+                "libutils",
+                "libz",
+            ],
+        },
+        host: {
+            shared_libs: [
+                "libz-host",
+            ],
+        },
+    },
+}
+
+cc_defaults {
+    name: "libopenjdk_native_defaults",
+    defaults: ["core_native_defaults"],
+    srcs: [":libopenjdk_native_srcs"],
+    cflags: [
+        // TODO(narayan): Prune down this list of exclusions once the underlying
+        // issues have been fixed. Most of these are small changes except for
+        // -Wunused-parameter.
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+        "-Wno-parentheses-equality",
+        "-Wno-constant-logical-operand",
+        "-Wno-sometimes-uninitialized",
+
+        // TODO(http://b/64362645): remove when upstream replaces readdir_r with readdir.
+        "-Wno-deprecated-declarations",
+    ],
+
+    shared_libs: [
+        "libcrypto",
+        "libicuuc",
+        "libssl",
+
+        "libnativehelper",
+    ],
+    static_libs: ["libfdlibm"],
+
+    target: {
+        linux: {
+            cflags: [ // Sigh.
+                "-D_LARGEFILE64_SOURCE",
+                "-D_GNU_SOURCE",
+                "-DLINUX",
+                "-D__GLIBC__",
+            ],
+        },
+        android: {
+            shared_libs: ["libz"],
+        },
+        host: {
+            shared_libs: ["libz-host"],
+        },
+    },
+
+    notice: "ojluni/NOTICE",
+}
+
+cc_library_shared {
+    name: "libopenjdk",
+    defaults: ["libopenjdk_native_defaults"],
+    shared_libs: [
+        "libopenjdkjvm",
+    ],
+}
+
+// Debug version of libopenjdk. Depends on libopenjdkjvmd.
+cc_library_shared {
+    name: "libopenjdkd",
+    defaults: ["libopenjdk_native_defaults"],
+    shared_libs: [
+        "libopenjdkjvmd",
+    ],
+}
+
+// Test JNI library.
+cc_library_shared {
+    name: "libjavacoretests",
+    defaults: ["core_native_defaults"],
+    host_supported:true,
+
+    srcs: [
+        "luni/src/test/native/dalvik_system_JniTest.cpp",
+        "luni/src/test/native/libcore_java_io_FileTest.cpp",
+        "luni/src/test/native/libcore_java_lang_ThreadTest.cpp",
+        "luni/src/test/native/libcore_java_nio_BufferTest.cpp",
+        "luni/src/test/native/libcore_util_NativeAllocationRegistryTest.cpp",
+    ],
+    target: {
+        android: {
+            shared_libs: ["libnativehelper_compat_libc++"],
+        },
+    },
+
+    strip: {
+        keep_symbols: true,
+    },
+}
+
+// Set of gtest unit tests.
+cc_test {
+    name: "libjavacore-unit-tests",
+    defaults: ["core_native_defaults"],
+
+    // Add -fno-builtin so that the compiler doesn't attempt to inline
+    // memcpy calls that are not really aligned.
+    cflags: ["-fno-builtin"],
+    srcs: ["luni/src/test/native/libcore_io_Memory_test.cpp"],
+
+    shared_libs: ["libnativehelper"],
+}
+
+// Set of benchmarks for libjavacore functions.
+cc_benchmark {
+    name: "libjavacore-benchmarks",
+    defaults: ["core_native_defaults"],
+
+    srcs: ["luni/src/benchmark/native/libcore_io_Memory_bench.cpp"],
+    test_suites: ["device-tests"],
+
+    shared_libs: ["libnativehelper"],
+}
+
+subdirs = [
+    "luni/src/main/native",
+    "ojluni/src/main/native",
+]
diff --git a/NativeCode.mk b/NativeCode.mk
deleted file mode 100644
index cedc69b..0000000
--- a/NativeCode.mk
+++ /dev/null
@@ -1,293 +0,0 @@
-# -*- mode: makefile -*-
-# 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.
-
-#
-# Definitions for building the native code needed for the core library.
-#
-
-#
-# Common definitions for host and target.
-#
-
-# These two definitions are used to help sanity check what's put in
-# sub.mk. See, the "error" directives immediately below.
-core_magic_local_target := ...//::default:://...
-core_local_path := $(LOCAL_PATH)
-
-# Include a submakefile, resolve its source file locations,
-# and stick them on core_src_files.  The submakefiles are
-# free to append to LOCAL_SRC_FILES, LOCAL_C_INCLUDES,
-# LOCAL_SHARED_LIBRARIES, or LOCAL_STATIC_LIBRARIES, but nothing
-# else. All other LOCAL_* variables will be ignored.
-#
-# $(1): directory containing the makefile to include
-define include-core-native-dir
-    LOCAL_SRC_FILES :=
-    include $(LOCAL_PATH)/$(1)/sub.mk
-    ifneq ($$(LOCAL_MODULE),$(core_magic_local_target))
-        $$(error $(LOCAL_PATH)/$(1)/sub.mk should not include CLEAR_VARS \
-            or define LOCAL_MODULE)
-    endif
-    ifneq ($$(LOCAL_PATH),$(core_local_path))
-        $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH)
-    endif
-    core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
-    LOCAL_SRC_FILES :=
-endef
-
-define include-openjdk-native-dir
-    LOCAL_SRC_FILES :=
-    include $(LOCAL_PATH)/$(1)/openjdksub.mk
-    openjdk_core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
-    LOCAL_SRC_FILES :=
-endef
-
-# Set up the default state. Note: We use CLEAR_VARS here, even though
-# we aren't quite defining a new rule yet, to make sure that the
-# sub.mk files don't see anything stray from the last rule that was
-# set up.
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := $(core_magic_local_target)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
-core_src_files :=
-openjdk_core_src_files :=
-
-#Include the sub.mk for openjdk.
-$(foreach dir, \
-    ojluni/src/main/native, \
-    $(eval $(call include-openjdk-native-dir,$(dir))))
-
-# Include the sub.mk files.
-$(foreach dir, \
-    dalvik/src/main/native luni/src/main/native, \
-    $(eval $(call include-core-native-dir,$(dir))))
-
-# Extract out the allowed LOCAL_* variables.
-core_c_includes := libcore/include $(LOCAL_C_INCLUDES)
-core_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
-core_static_libraries := $(LOCAL_STATIC_LIBRARIES)
-libart_cflags := $(LOCAL_CFLAGS) -Wall -Wextra -Werror
-core_cppflags += -DU_USING_ICU_NAMESPACE=0
-# TODO(narayan): Prune down this list of exclusions once the underlying
-# issues have been fixed. Most of these are small changes except for
-# -Wunused-parameter.
-openjdk_cflags := $(libart_cflags) \
-    -Wno-unused-parameter \
-    -Wno-unused-variable \
-    -Wno-parentheses-equality \
-    -Wno-constant-logical-operand \
-    -Wno-sometimes-uninitialized
-
-# TODO(http://b/64362645): remove when upstream replaces readdir_r with readdir.
-openjdk_cflags += -Wno-deprecated-declarations
-
-core_test_files := \
-  luni/src/test/native/dalvik_system_JniTest.cpp \
-  luni/src/test/native/libcore_java_io_FileTest.cpp \
-  luni/src/test/native/libcore_java_lang_ThreadTest.cpp \
-  luni/src/test/native/libcore_java_nio_BufferTest.cpp \
-  luni/src/test/native/libcore_util_NativeAllocationRegistryTest.cpp \
-
-#
-# Build for the target (device).
-#
-
-include $(CLEAR_VARS)
-LOCAL_CFLAGS += $(libart_cflags)
-LOCAL_CPPFLAGS += $(core_cppflags)
-LOCAL_SRC_FILES += $(core_src_files)
-LOCAL_C_INCLUDES += $(core_c_includes)
-LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libcrypto libdl libexpat libicuuc libicui18n libnativehelper libz libutils
-LOCAL_STATIC_LIBRARIES += $(core_static_libraries) libziparchive libbase
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libjavacore
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
-LOCAL_CXX_STL := libc++
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS += $(libart_cflags)
-LOCAL_CPPFLAGS += $(core_cppflags)
-ifeq ($(TARGET_ARCH),arm)
-# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4"
-LOCAL_CFLAGS += -Wno-psabi
-endif
-
-# Define the rules.
-LOCAL_CFLAGS += $(openjdk_cflags)
-LOCAL_SRC_FILES := $(openjdk_core_src_files)
-LOCAL_C_INCLUDES := $(core_c_includes)
-LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libcrypto libicuuc libssl libz
-LOCAL_SHARED_LIBRARIES += libopenjdkjvm libnativehelper libdl
-LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libopenjdk
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/ojluni/NOTICE
-LOCAL_CXX_STL := libc++
-include $(BUILD_SHARED_LIBRARY)
-
-# Debug version of libopenjdk. Depends on libopenjdkjvmd.
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS += $(libart_cflags)
-LOCAL_CPPFLAGS += $(core_cppflags)
-ifeq ($(TARGET_ARCH),arm)
-# Ignore "note: the mangling of 'va_list' has changed in GCC 4.4"
-LOCAL_CFLAGS += -Wno-psabi
-endif
-
-LOCAL_CFLAGS += $(openjdk_cflags)
-LOCAL_SRC_FILES := $(openjdk_core_src_files)
-LOCAL_C_INCLUDES := $(core_c_includes)
-LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libcrypto libicuuc libssl libz
-LOCAL_SHARED_LIBRARIES += libopenjdkjvmd libnativehelper libdl
-LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libopenjdkd
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/ojluni/NOTICE
-LOCAL_CXX_STL := libc++
-include $(BUILD_SHARED_LIBRARY)
-
-# Test JNI library.
-ifeq ($(LIBCORE_SKIP_TESTS),)
-
-include $(CLEAR_VARS)
-LOCAL_CFLAGS += $(libart_cflags)
-LOCAL_CPPFLAGS += $(core_cppflags)
-LOCAL_SRC_FILES += $(core_test_files)
-LOCAL_C_INCLUDES += libcore/include
-LOCAL_SHARED_LIBRARIES += libnativehelper_compat_libc++
-LOCAL_MODULE_TAGS := optional
-LOCAL_STRIP_MODULE := keep_symbols
-LOCAL_MODULE := libjavacoretests
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
-LOCAL_CXX_STL := libc++
-include $(BUILD_SHARED_LIBRARY)
-
-endif # LIBCORE_SKIP_TESTS
-
-# Set of gtest unit tests.
-include $(CLEAR_VARS)
-# Add -fno-builtin so that the compiler doesn't attempt to inline
-# memcpy calls that are not really aligned.
-LOCAL_CFLAGS += $(libart_cflags) -fno-builtin
-LOCAL_CPPFLAGS += $(core_cppflags)
-LOCAL_SRC_FILES += \
-  luni/src/test/native/libcore_io_Memory_test.cpp \
-
-LOCAL_C_INCLUDES += libcore/include
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := libjavacore-unit-tests
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
-LOCAL_SHARED_LIBRARIES := libnativehelper
-LOCAL_CXX_STL := libc++
-include $(BUILD_NATIVE_TEST)
-
-# Set of benchmarks for libjavacore functions.
-include $(CLEAR_VARS)
-LOCAL_CFLAGS += $(libart_cflags)
-LOCAL_CPPFLAGS += $(core_cppflags)
-LOCAL_SRC_FILES += \
-  luni/src/benchmark/native/libcore_io_Memory_bench.cpp \
-
-LOCAL_C_INCLUDES += libcore/include
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := libjavacore-benchmarks
-LOCAL_COMPATIBILITY_SUITE := device-tests
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
-LOCAL_SHARED_LIBRARIES := libnativehelper
-LOCAL_CXX_STL := libc++
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-include $(BUILD_NATIVE_BENCHMARK)
-
-
-#
-# Build for the host.
-#
-
-ifeq ($(HOST_OS),linux)
-
-include $(CLEAR_VARS)
-LOCAL_CLANG := true
-LOCAL_SRC_FILES += $(core_src_files)
-LOCAL_CFLAGS += $(libart_cflags)
-LOCAL_C_INCLUDES += $(core_c_includes)
-LOCAL_CPPFLAGS += $(core_cppflags)
-LOCAL_LDLIBS += -ldl -lpthread
-ifeq ($(HOST_OS),linux)
-LOCAL_LDLIBS += -lrt
-endif
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libjavacore
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
-LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libexpat libicuuc libicui18n libcrypto libz-host libziparchive
-LOCAL_STATIC_LIBRARIES += $(core_static_libraries)
-LOCAL_MULTILIB := both
-LOCAL_CXX_STL := libc++
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-# Debug version of libopenjdk (host). Depends on libopenjdkjvmd.
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(openjdk_core_src_files)
-LOCAL_C_INCLUDES := $(core_c_includes)
-LOCAL_CFLAGS := -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DLINUX -D__GLIBC__ # Sigh.
-LOCAL_CFLAGS += $(openjdk_cflags)
-LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libicuuc libcrypto libz-host
-LOCAL_SHARED_LIBRARIES += libopenjdkjvmd libnativehelper
-LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
-LOCAL_MODULE_TAGS := optional
-LOCAL_LDLIBS += -ldl -lpthread -lrt
-LOCAL_MODULE := libopenjdkd
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/ojluni/NOTICE
-LOCAL_MULTILIB := both
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(openjdk_core_src_files)
-LOCAL_C_INCLUDES := $(core_c_includes)
-LOCAL_CFLAGS := -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DLINUX -D__GLIBC__ # Sigh.
-LOCAL_CFLAGS += $(openjdk_cflags)
-LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libicuuc libcrypto libz-host
-LOCAL_SHARED_LIBRARIES += libopenjdkjvm libnativehelper
-LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
-LOCAL_MODULE_TAGS := optional
-LOCAL_LDLIBS += -ldl -lpthread -lrt
-LOCAL_MODULE := libopenjdk
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/ojluni/NOTICE
-LOCAL_MULTILIB := both
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-ifeq ($(LIBCORE_SKIP_TESTS),)
-    include $(CLEAR_VARS)
-    LOCAL_CLANG := true
-    LOCAL_SRC_FILES += $(core_test_files)
-    LOCAL_CFLAGS += $(libart_cflags)
-    LOCAL_C_INCLUDES += libcore/include
-    LOCAL_CPPFLAGS += $(core_cppflags)
-    LOCAL_LDLIBS += -ldl -lpthread
-    LOCAL_MODULE_TAGS := optional
-    LOCAL_MODULE := libjavacoretests
-    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk
-    LOCAL_SHARED_LIBRARIES := libnativehelper
-    LOCAL_MULTILIB := both
-    LOCAL_CXX_STL := libc++
-    include $(BUILD_HOST_SHARED_LIBRARY)
-endif # LIBCORE_SKIP_TESTS
-
-endif # HOST_OS == linux
diff --git a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
index c96016f..47e4ad4 100644
--- a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
+++ b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
@@ -53,12 +53,12 @@
     }
 
     /**
-     * Called by the zygote in the child process after every fork. The debug
-     * flags from {@code debugFlags} are applied to the child process. The string
+     * Called by the zygote in the child process after every fork. The runtime
+     * flags from {@code runtimeFlags} are applied to the child process. The string
      * {@code instructionSet} determines whether to use a native bridge.
      */
-    public void postForkChild(int debugFlags, boolean isSystemServer, String instructionSet) {
-        nativePostForkChild(token, debugFlags, isSystemServer, instructionSet);
+    public void postForkChild(int runtimeFlags, boolean isSystemServer, String instructionSet) {
+        nativePostForkChild(token, runtimeFlags, isSystemServer, instructionSet);
 
         Math.setRandomSeedInternal(System.currentTimeMillis());
     }
@@ -73,7 +73,7 @@
     }
 
     private static native long nativePreFork();
-    private static native void nativePostForkChild(long token, int debugFlags,
+    private static native void nativePostForkChild(long token, int runtimeFlags,
                                                    boolean isSystemServer, String instructionSet);
 
     /**
diff --git a/dalvik/src/main/native/sub.mk b/dalvik/src/main/native/sub.mk
deleted file mode 100644
index 4adc8a1..0000000
--- a/dalvik/src/main/native/sub.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# -*- mode: makefile -*-
-# This file is included by the top-level libcore Android.mk.
-# It's not a normal makefile, so we don't include CLEAR_VARS
-# or BUILD_*_LIBRARY.
-
-LOCAL_SRC_FILES := \
-	org_apache_harmony_dalvik_NativeTestTarget.cpp
-
-#LOCAL_C_INCLUDES +=
-
-# Any shared/static libs that are listed here must also
-# be listed in libs/nativehelper/Android.mk.
-# TODO: fix this requirement
-
-#LOCAL_SHARED_LIBRARIES +=
-
-#LOCAL_STATIC_LIBRARIES +=
diff --git a/luni/src/main/native/Android.bp b/luni/src/main/native/Android.bp
new file mode 100644
index 0000000..a8e7ee7
--- /dev/null
+++ b/luni/src/main/native/Android.bp
@@ -0,0 +1,28 @@
+filegroup {
+    name: "luni_native_srcs",
+    srcs: [
+        "ExecStrings.cpp",
+        "IcuUtilities.cpp",
+        "JniException.cpp",
+        "NetworkUtilities.cpp",
+        "Register.cpp",
+        "ZipUtilities.cpp",
+        "android_system_OsConstants.cpp",
+        "cbigint.cpp",
+        "java_lang_StringToReal.cpp",
+        "java_lang_invoke_MethodHandle.cpp",
+        "java_math_NativeBN.cpp",
+        "java_util_regex_Matcher.cpp",
+        "java_util_regex_Pattern.cpp",
+        "libcore_icu_ICU.cpp",
+        "libcore_icu_NativeConverter.cpp",
+        "libcore_icu_TimeZoneNames.cpp",
+        "libcore_io_AsynchronousCloseMonitor.cpp",
+        "libcore_io_Linux.cpp",
+        "libcore_io_Memory.cpp",
+        "libcore_util_NativeAllocationRegistry.cpp",
+        "org_apache_harmony_xml_ExpatParser.cpp",
+        "sun_misc_Unsafe.cpp",
+        "valueOf.cpp",
+    ],
+}
diff --git a/luni/src/main/native/sub.mk b/luni/src/main/native/sub.mk
deleted file mode 100644
index 0706ce8..0000000
--- a/luni/src/main/native/sub.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# -*- mode: makefile -*-
-# This file is included by the top-level libcore Android.mk.
-# It's not a normal makefile, so we don't include CLEAR_VARS
-# or BUILD_*_LIBRARY.
-
-LOCAL_SRC_FILES := \
-    ExecStrings.cpp \
-    IcuUtilities.cpp \
-    JniException.cpp \
-    NetworkUtilities.cpp \
-    Register.cpp \
-    ZipUtilities.cpp \
-    android_system_OsConstants.cpp \
-    cbigint.cpp \
-    java_lang_StringToReal.cpp \
-    java_lang_invoke_MethodHandle.cpp \
-    java_math_NativeBN.cpp \
-    java_util_regex_Matcher.cpp \
-    java_util_regex_Pattern.cpp \
-    libcore_icu_ICU.cpp \
-    libcore_icu_NativeConverter.cpp \
-    libcore_icu_TimeZoneNames.cpp \
-    libcore_io_AsynchronousCloseMonitor.cpp \
-    libcore_io_Linux.cpp \
-    libcore_io_Memory.cpp \
-    libcore_util_NativeAllocationRegistry.cpp \
-    org_apache_harmony_xml_ExpatParser.cpp \
-    sun_misc_Unsafe.cpp \
-    valueOf.cpp \
-
-LOCAL_STATIC_LIBRARIES += \
-    libbase \
-    libfdlibm \
-
-LOCAL_SHARED_LIBRARIES += \
-    liblog \
-    libnativehelper \
diff --git a/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java b/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
index e6a2938..4171062 100644
--- a/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
+++ b/luni/src/test/java/libcore/java/net/ServerSocketConcurrentCloseTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package libcore.java.net;
 
 import junit.framework.TestCase;
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
index d9a7b4f..eed6b11 100644
--- a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
+++ b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
@@ -33,6 +33,7 @@
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLEngineResult;
 import javax.net.ssl.SSLEngineResult.HandshakeStatus;
+import javax.net.ssl.SSLEngineResult.Status;
 import javax.net.ssl.SSLException;
 import javax.net.ssl.SSLHandshakeException;
 import javax.net.ssl.SSLParameters;
@@ -850,4 +851,33 @@
             server.get();
         }
     }
+
+    public void test_SSLEngine_CloseOutbound() throws Exception {
+        try (final TestSSLEnginePair pair = TestSSLEnginePair.create()) {
+            assertConnected(pair);
+
+            pair.client.closeOutbound();
+            ByteBuffer clientOut = ByteBuffer.allocate(pair.client.getSession().getPacketBufferSize());
+            SSLEngineResult res = pair.client.wrap(ByteBuffer.wrap(new byte[0]), clientOut);
+            assertEquals(Status.CLOSED, res.getStatus());
+            assertEquals(HandshakeStatus.NOT_HANDSHAKING, res.getHandshakeStatus());
+
+            clientOut.flip();
+            ByteBuffer serverIn = ByteBuffer.allocate(pair.server.getSession().getApplicationBufferSize());
+            res = pair.server.unwrap(clientOut, serverIn);
+            assertEquals(Status.CLOSED, res.getStatus());
+            assertEquals(HandshakeStatus.NEED_WRAP, res.getHandshakeStatus());
+
+            ByteBuffer serverOut = ByteBuffer.allocate(pair.server.getSession().getPacketBufferSize());
+            res = pair.server.wrap(ByteBuffer.wrap(new byte[0]), serverOut);
+            assertEquals(Status.CLOSED, res.getStatus());
+            assertEquals(HandshakeStatus.NOT_HANDSHAKING, res.getHandshakeStatus());
+
+            serverOut.flip();
+            ByteBuffer clientIn = ByteBuffer.allocate(pair.client.getSession().getApplicationBufferSize());
+            res = pair.client.unwrap(serverOut, clientIn);
+            assertEquals(Status.CLOSED, res.getStatus());
+            assertEquals(HandshakeStatus.NOT_HANDSHAKING, res.getHandshakeStatus());
+        }
+    }
 }
diff --git a/ojluni/src/main/java/java/util/Locale.java b/ojluni/src/main/java/java/util/Locale.java
index 9073504..9d9f3e4 100644
--- a/ojluni/src/main/java/java/util/Locale.java
+++ b/ojluni/src/main/java/java/util/Locale.java
@@ -516,7 +516,7 @@
  *     <td><a href="http://site.icu-project.org/download/56">ICU 56.1</a></td>
  *     <td><a href="http://cldr.unicode.org/index/downloads/cldr-28">CLDR 28</a></td>
  *     <td><a href="http://www.unicode.org/versions/Unicode8.0.0/">Unicode 8.0</a></td></tr>
- * <tr><td>Android O</td>
+ * <tr><td>Android 8.0 (Oreo)</td>
  *     <td><a href="http://site.icu-project.org/download/58">ICU 58.2</a></td>
  *     <td><a href="http://cldr.unicode.org/index/downloads/cldr-30">CLDR 30.0.3</a></td>
  *     <td><a href="http://www.unicode.org/versions/Unicode9.0.0/">Unicode 9.0</a></td></tr>
diff --git a/ojluni/src/main/native/Android.bp b/ojluni/src/main/native/Android.bp
new file mode 100644
index 0000000..71546ca
--- /dev/null
+++ b/ojluni/src/main/native/Android.bp
@@ -0,0 +1,65 @@
+filegroup {
+    name: "libopenjdk_native_srcs",
+    srcs: [
+        "java_util_zip_ZipFile.c",
+        "java_util_zip_Inflater.c",
+        "java_util_zip_Deflater.c",
+        "java_util_zip_CRC32.c",
+        "Adler32.c",
+        "zip_util.c",
+        "jni_util.c",
+        "jni_util_md.c",
+        "io_util.c",
+        "canonicalize_md.c",
+        "FileDescriptor_md.c",
+        "DatagramChannelImpl.c",
+        "DatagramDispatcher.c",
+        "Console_md.c",
+        "IOUtil.c",
+        "PollArrayWrapper.c",
+        "SocketChannelImpl.c",
+        "FileChannelImpl.c",
+        "FileDispatcherImpl.c",
+        "FileOutputStream_md.c",
+        "FileInputStream.c",
+        "FileSystemPreferences.c",
+        "EPoll.c",
+        "EPollPort.c",
+        "UnixAsynchronousServerSocketChannelImpl.c",
+        "UnixAsynchronousSocketChannelImpl.c",
+        "io_util_md.c",
+        "NativeThread.c",
+        "FileKey.c",
+        "UnixFileSystem_md.c",
+        "ObjectStreamClass.c",
+        "ObjectOutputStream.c",
+        "ObjectInputStream.c",
+        "LinuxNativeDispatcher.c",
+        "LinuxWatchService.c",
+        "UnixCopyFile.c",
+        "UnixNativeDispatcher.c",
+        "InetAddress.c",
+        "net_util.c",
+        "net_util_md.c",
+        "Net.c",
+        "MappedByteBuffer.c",
+        "Inet6Address.c",
+        "Inet4Address.c",
+        "linux_close.cpp",
+        "ServerSocketChannelImpl.c",
+        "SocketInputStream.c",
+        "SocketOutputStream.c",
+        "Float.c",
+        "Double.c",
+        "StrictMath.c",
+        "Math.c",
+        "ProcessEnvironment_md.c",
+        "System.c",
+        "Runtime.c",
+        "UNIXProcess_md.c",
+        "Bits.c",
+        "Character.cpp",
+        "Register.cpp",
+        "socket_tagger_util.cpp",
+    ],
+}
diff --git a/ojluni/src/main/native/openjdksub.mk b/ojluni/src/main/native/openjdksub.mk
deleted file mode 100644
index d60bc09..0000000
--- a/ojluni/src/main/native/openjdksub.mk
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- mode: makefile -*-
-# This file is included by the top-level libcore Android.mk.
-# It's not a normal makefile, so we don't include CLEAR_VARS
-# or BUILD_*_LIBRARY.
-
-srcdir := ojluni/src/main/native
-LOCAL_SRC_FILES := \
-    java_util_zip_ZipFile.c \
-    java_util_zip_Inflater.c \
-    java_util_zip_Deflater.c \
-    java_util_zip_CRC32.c \
-    Adler32.c \
-    zip_util.c \
-    jni_util.c \
-    jni_util_md.c \
-    io_util.c \
-    canonicalize_md.c \
-    FileDescriptor_md.c \
-    DatagramChannelImpl.c \
-    DatagramDispatcher.c \
-    Console_md.c \
-    IOUtil.c \
-    PollArrayWrapper.c \
-    SocketChannelImpl.c \
-    FileChannelImpl.c \
-    FileDispatcherImpl.c \
-    FileOutputStream_md.c \
-    FileInputStream.c \
-    FileSystemPreferences.c \
-    EPoll.c \
-    EPollPort.c \
-    UnixAsynchronousServerSocketChannelImpl.c \
-    UnixAsynchronousSocketChannelImpl.c \
-    io_util_md.c \
-    NativeThread.c \
-    FileKey.c \
-    UnixFileSystem_md.c \
-    ObjectStreamClass.c \
-    ObjectOutputStream.c \
-    ObjectInputStream.c \
-    LinuxNativeDispatcher.c \
-    LinuxWatchService.c \
-    UnixCopyFile.c \
-    UnixNativeDispatcher.c \
-    InetAddress.c \
-    net_util.c \
-    net_util_md.c \
-    Net.c \
-    MappedByteBuffer.c \
-    Inet6Address.c \
-    Inet4Address.c \
-    linux_close.cpp \
-    ServerSocketChannelImpl.c \
-    SocketInputStream.c \
-    SocketOutputStream.c \
-    Float.c \
-    Double.c \
-    StrictMath.c \
-    Math.c \
-    ProcessEnvironment_md.c \
-    System.c \
-    Runtime.c \
-    UNIXProcess_md.c \
-    Bits.c \
-    Character.cpp \
-    Register.cpp \
-    socket_tagger_util.cpp \
-
-LOCAL_C_INCLUDES += \
-       libcore/$(srcdir) \
-       external/fdlibm \
-       external/zlib \
-       external/icu/icu4c/source/common \