Merge "Fix test to match behavior of OpenJDK and RI"
diff --git a/NativeCode.mk b/NativeCode.mk
index a9fde9b..56556e1 100644
--- a/NativeCode.mk
+++ b/NativeCode.mk
@@ -122,7 +122,7 @@
 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 += libart libnativehelper libdl
+LOCAL_SHARED_LIBRARIES += libopenjdkjvm libnativehelper libdl
 LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := libopenjdk
@@ -210,7 +210,7 @@
 LOCAL_C_INCLUDES := $(core_c_includes)
 LOCAL_CFLAGS := -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DLINUX -D__GLIBC__ # Sigh.
 LOCAL_SHARED_LIBRARIES := $(core_shared_libraries) libicuuc-host libcrypto-host libz-host
-LOCAL_SHARED_LIBRARIES += libart libnativehelper
+LOCAL_SHARED_LIBRARIES += libopenjdkjvm libnativehelper
 LOCAL_STATIC_LIBRARIES := $(core_static_libraries) libfdlibm
 LOCAL_MODULE_TAGS := optional
 LOCAL_LDLIBS += -ldl -lpthread
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/NumberFormatTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/NumberFormatTest.java
index 98d1ba7..df9eefc 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/NumberFormatTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/NumberFormatTest.java
@@ -179,8 +179,8 @@
                 "Test7: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).toPattern() returned wrong pattern",
                 variant, format.toPattern());
         assertEquals(
-                "Test8: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).format(-35.76) returned wrong value",
-                "\u200f-\u0666", format.format(-6));
+                "Test8: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).format(-6) returned wrong value",
+                "-\u0666", format.format(-6));
         assertEquals(
                 "Test9: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parse(\"-36-\") returned wrong number",
                 new Long(36), format.parse("36-"));
diff --git a/luni/src/main/native/AsynchronousCloseMonitor.cpp b/luni/src/main/native/AsynchronousCloseMonitor.cpp
deleted file mode 100644
index 6c9b2e5..0000000
--- a/luni/src/main/native/AsynchronousCloseMonitor.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2010 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 "AsynchronousCloseMonitor"
-
-#include "AsynchronousCloseMonitor.h"
-#include "cutils/log.h"
-
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-
-/**
- * We use an intrusive doubly-linked list to keep track of blocked threads.
- * This gives us O(1) insertion and removal, and means we don't need to do any allocation.
- * (The objects themselves are stack-allocated.)
- * Waking potentially-blocked threads when a file descriptor is closed is O(n) in the total number
- * of blocked threads (not the number of threads actually blocked on the file descriptor in
- * question). For now at least, this seems like a good compromise for Android.
- */
-static pthread_mutex_t blockedThreadListMutex = PTHREAD_MUTEX_INITIALIZER;
-static AsynchronousCloseMonitor* blockedThreadList = NULL;
-
-/**
- * The specific signal chosen here is arbitrary, but bionic needs to know so that SIGRTMIN
- * starts at a higher value.
- */
-static const int BLOCKED_THREAD_SIGNAL = __SIGRTMIN + 2;
-
-static void blockedThreadSignalHandler(int /*signal*/) {
-    // Do nothing. We only sent this signal for its side-effect of interrupting syscalls.
-}
-
-void AsynchronousCloseMonitor::init() {
-    // Ensure that the signal we send interrupts system calls but doesn't kill threads.
-    // Using sigaction(2) lets us ensure that the SA_RESTART flag is not set.
-    // (The whole reason we're sending this signal is to unblock system calls!)
-    struct sigaction sa;
-    memset(&sa, 0, sizeof(sa));
-    sa.sa_handler = blockedThreadSignalHandler;
-    sa.sa_flags = 0;
-    int rc = sigaction(BLOCKED_THREAD_SIGNAL, &sa, NULL);
-    if (rc == -1) {
-        ALOGE("setting blocked thread signal handler failed: %s", strerror(errno));
-    }
-}
-
-void AsynchronousCloseMonitor::signalBlockedThreads(int fd) {
-    ScopedPthreadMutexLock lock(&blockedThreadListMutex);
-    for (AsynchronousCloseMonitor* it = blockedThreadList; it != NULL; it = it->mNext) {
-        if (it->mFd == fd) {
-            it->mSignaled = true;
-            pthread_kill(it->mThread, BLOCKED_THREAD_SIGNAL);
-            // Keep going, because there may be more than one thread...
-        }
-    }
-}
-
-bool AsynchronousCloseMonitor::wasSignaled() const {
-    return mSignaled;
-}
-
-AsynchronousCloseMonitor::AsynchronousCloseMonitor(int fd) {
-    ScopedPthreadMutexLock lock(&blockedThreadListMutex);
-    // Who are we, and what are we waiting for?
-    mThread = pthread_self();
-    mFd = fd;
-    mSignaled = false;
-    // Insert ourselves at the head of the intrusive doubly-linked list...
-    mPrev = NULL;
-    mNext = blockedThreadList;
-    if (mNext != NULL) {
-        mNext->mPrev = this;
-    }
-    blockedThreadList = this;
-}
-
-AsynchronousCloseMonitor::~AsynchronousCloseMonitor() {
-    ScopedPthreadMutexLock lock(&blockedThreadListMutex);
-    // Unlink ourselves from the intrusive doubly-linked list...
-    if (mNext != NULL) {
-        mNext->mPrev = mPrev;
-    }
-    if (mPrev == NULL) {
-        blockedThreadList = mNext;
-    } else {
-        mPrev->mNext = mNext;
-    }
-}
diff --git a/luni/src/main/native/AsynchronousCloseMonitor.h b/luni/src/main/native/AsynchronousCloseMonitor.h
deleted file mode 100644
index eefbbdf..0000000
--- a/luni/src/main/native/AsynchronousCloseMonitor.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef ASYNCHRONOUS_CLOSE_MONITOR_H_included
-#define ASYNCHRONOUS_CLOSE_MONITOR_H_included
-
-#include "ScopedPthreadMutexLock.h"
-#include <pthread.h>
-
-/**
- * AsynchronousCloseMonitor helps implement Java's asynchronous close semantics.
- *
- * AsynchronousCloseMonitor::init must be called before anything else.
- *
- * Every blocking I/O operation must be surrounded by an AsynchronousCloseMonitor
- * instance. For example:
- *
- *   {
- *     AsynchronousCloseMonitor monitor(fd);
- *     byteCount = ::read(fd, buf, sizeof(buf));
- *   }
- *
- * To interrupt all threads currently blocked on file descriptor 'fd', call signalBlockedThreads:
- *
- *   AsynchronousCloseMonitor::signalBlockedThreads(fd);
- *
- * To test to see if the interruption was due to the signalBlockedThreads call:
- *
- *   monitor.wasSignaled();
- */
-class AsynchronousCloseMonitor {
-public:
-    AsynchronousCloseMonitor(int fd);
-    ~AsynchronousCloseMonitor();
-    bool wasSignaled() const;
-
-    static void init();
-
-    static void signalBlockedThreads(int fd);
-
-private:
-    AsynchronousCloseMonitor* mPrev;
-    AsynchronousCloseMonitor* mNext;
-    pthread_t mThread;
-    int mFd;
-    bool mSignaled;
-
-    // Disallow copy and assignment.
-    AsynchronousCloseMonitor(const AsynchronousCloseMonitor&);
-    void operator=(const AsynchronousCloseMonitor&);
-};
-
-#endif  // ASYNCHRONOUS_CLOSE_MONITOR_H_included
diff --git a/luni/src/main/native/java_io_File.cpp b/luni/src/main/native/java_io_File.cpp
deleted file mode 100644
index 046fc4f..0000000
--- a/luni/src/main/native/java_io_File.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-#define LOG_TAG "File"
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "JniException.h"
-#include "ScopedPrimitiveArray.h"
-#include "ScopedUtfChars.h"
-#include "toStringArray.h"
-
-#include <string>
-#include <vector>
-
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <time.h>
-#include <unistd.h>
-#include <utime.h>
-
-static jstring File_canonicalizePath(JNIEnv* env, jclass, jstring javaPath) {
-  ScopedUtfChars path(env, javaPath);
-  if (path.c_str() == NULL) {
-    return NULL;
-  }
-
-  extern bool canonicalize_path(const char* path, std::string& resolved);
-  std::string result;
-  if (!canonicalize_path(path.c_str(), result)) {
-    jniThrowIOException(env, errno);
-    return NULL;
-  }
-  return env->NewStringUTF(result.c_str());
-}
-
-static jboolean File_setLastModifiedImpl(JNIEnv* env, jclass, jstring javaPath, jlong ms) {
-  ScopedUtfChars path(env, javaPath);
-  if (path.c_str() == NULL) {
-    return JNI_FALSE;
-  }
-
-  // We want to preserve the access time.
-  struct stat sb;
-  if (stat(path.c_str(), &sb) == -1) {
-    return JNI_FALSE;
-  }
-
-  // TODO: we could get microsecond resolution with utimes(3), "legacy" though it is.
-  utimbuf times;
-  times.actime = sb.st_atime;
-  times.modtime = static_cast<time_t>(ms / 1000);
-  return (utime(path.c_str(), &times) == 0);
-}
-
-// Iterates over the filenames in the given directory.
-class ScopedReaddir {
- public:
-  ScopedReaddir(const char* path) {
-    mDirStream = opendir(path);
-    mIsBad = (mDirStream == NULL);
-  }
-
-  ~ScopedReaddir() {
-    if (mDirStream != NULL) {
-      closedir(mDirStream);
-    }
-  }
-
-  // Returns the next filename, or NULL.
-  const char* next() {
-    if (mIsBad) {
-      return NULL;
-    }
-    errno = 0;
-    dirent* result = readdir(mDirStream);
-    if (result != NULL) {
-      return result->d_name;
-    }
-    if (errno != 0) {
-      mIsBad = true;
-    }
-    return NULL;
-  }
-
-  // Has an error occurred on this stream?
-  bool isBad() const {
-    return mIsBad;
-  }
-
- private:
-  DIR* mDirStream;
-  bool mIsBad;
-
-  // Disallow copy and assignment.
-  ScopedReaddir(const ScopedReaddir&);
-  void operator=(const ScopedReaddir&);
-};
-
-typedef std::vector<std::string> DirEntries;
-
-// Reads the directory referred to by 'pathBytes', adding each directory entry
-// to 'entries'.
-static bool readDirectory(JNIEnv* env, jstring javaPath, DirEntries& entries) {
-  ScopedUtfChars path(env, javaPath);
-  if (path.c_str() == NULL) {
-    return false;
-  }
-
-  ScopedReaddir dir(path.c_str());
-  const char* filename;
-  while ((filename = dir.next()) != NULL) {
-    if (strcmp(filename, ".") != 0 && strcmp(filename, "..") != 0) {
-      // TODO: this hides allocation failures from us. Push directory iteration up into Java?
-      entries.push_back(filename);
-    }
-  }
-  return !dir.isBad();
-}
-
-static jobjectArray File_listImpl(JNIEnv* env, jclass, jstring javaPath) {
-  // Read the directory entries into an intermediate form.
-  DirEntries entries;
-  if (!readDirectory(env, javaPath, entries)) {
-    return NULL;
-  }
-  // Translate the intermediate form into a Java String[].
-  return toStringArray(env, entries);
-}
-
-static JNINativeMethod gMethods[] = {
-  NATIVE_METHOD(File, canonicalizePath, "(Ljava/lang/String;)Ljava/lang/String;"),
-  NATIVE_METHOD(File, listImpl, "(Ljava/lang/String;)[Ljava/lang/String;"),
-  NATIVE_METHOD(File, setLastModifiedImpl, "(Ljava/lang/String;J)Z"),
-};
-void register_java_io_File(JNIEnv* env) {
-  jniRegisterNativeMethods(env, "java/io/File", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_io_FileDescriptor.cpp b/luni/src/main/native/java_io_FileDescriptor.cpp
deleted file mode 100644
index 2a7820f..0000000
--- a/luni/src/main/native/java_io_FileDescriptor.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2014 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 "FileDescriptor"
-
-#include "JniConstants.h"
-
-#include <sys/socket.h>
-#include <sys/types.h>
-
-static jboolean FileDescriptor_isSocket(JNIEnv*, jclass, jint fd) {
-  // If getsockopt succeeds, we know we're dealing with a socket.
-  // This is the cheapest way we know of to test whether an fd is a socket.
-  int option;
-  socklen_t option_length = sizeof(option);
-  return TEMP_FAILURE_RETRY(getsockopt(fd, SOL_SOCKET, SO_DEBUG, &option, &option_length)) == 0;
-}
-
-static JNINativeMethod gMethods[] = {
-  NATIVE_METHOD(FileDescriptor, isSocket, "(I)Z"),
-};
-void register_java_io_FileDescriptor(JNIEnv* env) {
-  jniRegisterNativeMethods(env, "java/io/FileDescriptor", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_io_ObjectStreamClass.cpp b/luni/src/main/native/java_io_ObjectStreamClass.cpp
deleted file mode 100644
index 9a1b632..0000000
--- a/luni/src/main/native/java_io_ObjectStreamClass.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-#define LOG_TAG "ObjectStreamClass"
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-
-static jobject getSignature(JNIEnv* env, jclass c, jobject object) {
-    jmethodID mid = env->GetMethodID(c, "getSignature", "()Ljava/lang/String;");
-    if (!mid) {
-        return NULL;
-    }
-    jclass objectClass = env->GetObjectClass(object);
-    return env->CallNonvirtualObjectMethod(object, objectClass, mid);
-}
-
-static jobject ObjectStreamClass_getFieldSignature(JNIEnv* env, jclass, jobject field) {
-    return getSignature(env, JniConstants::fieldClass, field);
-}
-
-static jobject ObjectStreamClass_getMethodSignature(JNIEnv* env, jclass, jobject method) {
-    return getSignature(env, JniConstants::methodClass, method);
-}
-
-static jobject ObjectStreamClass_getConstructorSignature(JNIEnv* env, jclass, jobject constructor) {
-    return getSignature(env, JniConstants::constructorClass, constructor);
-}
-
-static jboolean ObjectStreamClass_hasClinit(JNIEnv * env, jclass, jclass targetClass) {
-    jmethodID mid = env->GetStaticMethodID(targetClass, "<clinit>", "()V");
-    env->ExceptionClear();
-    return (mid != 0);
-}
-
-static jlong ObjectStreamClass_getConstructorId(JNIEnv* env, jclass, jclass constructorClass) {
-    return reinterpret_cast<jlong>(env->GetMethodID(constructorClass, "<init>", "()V"));
-}
-
-static jobject ObjectStreamClass_newInstance(JNIEnv* env, jclass, jclass instantiationClass, jlong methodId) {
-    return env->NewObject(instantiationClass, reinterpret_cast<jmethodID>(methodId));
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(ObjectStreamClass, getConstructorId, "(Ljava/lang/Class;)J"),
-    NATIVE_METHOD(ObjectStreamClass, getConstructorSignature, "(Ljava/lang/reflect/Constructor;)Ljava/lang/String;"),
-    NATIVE_METHOD(ObjectStreamClass, getFieldSignature, "(Ljava/lang/reflect/Field;)Ljava/lang/String;"),
-    NATIVE_METHOD(ObjectStreamClass, getMethodSignature, "(Ljava/lang/reflect/Method;)Ljava/lang/String;"),
-    NATIVE_METHOD(ObjectStreamClass, hasClinit, "(Ljava/lang/Class;)Z"),
-    NATIVE_METHOD(ObjectStreamClass, newInstance, "(Ljava/lang/Class;J)Ljava/lang/Object;"),
-};
-void register_java_io_ObjectStreamClass(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/io/ObjectStreamClass", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_lang_Character.cpp b/luni/src/main/native/java_lang_Character.cpp
deleted file mode 100644
index 4022f4b..0000000
--- a/luni/src/main/native/java_lang_Character.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2006 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 "Character"
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "ScopedUtfChars.h"
-#include "unicode/uchar.h"
-#include "unicode/uscript.h"
-#include <math.h>
-#include <stdio.h> // For BUFSIZ
-#include <stdlib.h>
-
-static jint Character_digitImpl(JNIEnv*, jclass, jint codePoint, jint radix) {
-    return u_digit(codePoint, radix);
-}
-
-static jint Character_getTypeImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_charType(codePoint);
-}
-
-static jbyte Character_getIcuDirectionality(JNIEnv*, jclass, jint codePoint) {
-    return u_charDirection(codePoint);
-}
-
-static jboolean Character_isMirroredImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isMirrored(codePoint);
-}
-
-static jstring Character_getNameImpl(JNIEnv* env, jclass, jint codePoint) {
-    // U_UNICODE_CHAR_NAME gives us the modern names for characters. For control characters,
-    // we need U_EXTENDED_CHAR_NAME to get "NULL" rather than "BASIC LATIN 0" and so on.
-    // We could just use U_EXTENDED_CHAR_NAME except that it returns strings for characters
-    // that aren't unassigned but that don't have names, and those strings aren't in the form
-    // Java specifies.
-    bool isControl = (codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f));
-    UCharNameChoice nameType = isControl ? U_EXTENDED_CHAR_NAME : U_UNICODE_CHAR_NAME;
-    UErrorCode status = U_ZERO_ERROR;
-    char buf[BUFSIZ]; // TODO: is there a more sensible upper bound?
-    int32_t byteCount = u_charName(codePoint, nameType, &buf[0], sizeof(buf), &status);
-    return (U_FAILURE(status) || byteCount == 0) ? NULL : env->NewStringUTF(buf);
-}
-
-static jint Character_getNumericValueImpl(JNIEnv*, jclass, jint codePoint) {
-    double result = u_getNumericValue(codePoint);
-    if (result == U_NO_NUMERIC_VALUE) {
-        return -1;
-    } else if (result < 0 || floor(result + 0.5) != result) {
-        return -2;
-    }
-    return static_cast<jint>(result);
-}
-
-static jboolean Character_isDefinedImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isdefined(codePoint);
-}
-
-static jboolean Character_isDigitImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isdigit(codePoint);
-}
-
-static jboolean Character_isIdentifierIgnorableImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isIDIgnorable(codePoint);
-}
-
-static jboolean Character_isLetterImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isalpha(codePoint);
-}
-
-static jboolean Character_isLetterOrDigitImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isalnum(codePoint);
-}
-
-static jboolean Character_isSpaceCharImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isJavaSpaceChar(codePoint);
-}
-
-static jboolean Character_isTitleCaseImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_istitle(codePoint);
-}
-
-static jboolean Character_isUnicodeIdentifierPartImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isIDPart(codePoint);
-}
-
-static jboolean Character_isUnicodeIdentifierStartImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isIDStart(codePoint);
-}
-
-static jboolean Character_isWhitespaceImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isWhitespace(codePoint);
-}
-
-static jint Character_toLowerCaseImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_tolower(codePoint);
-}
-
-static jint Character_toTitleCaseImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_totitle(codePoint);
-}
-
-static jint Character_toUpperCaseImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_toupper(codePoint);
-}
-
-static jboolean Character_isUpperCaseImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_isupper(codePoint);
-}
-
-static jboolean Character_isLowerCaseImpl(JNIEnv*, jclass, jint codePoint) {
-    return u_islower(codePoint);
-}
-
-static int Character_unicodeBlockForName(JNIEnv* env, jclass, jstring javaBlockName) {
-    ScopedUtfChars blockName(env, javaBlockName);
-    if (blockName.c_str() == NULL) {
-        return 0;
-    }
-    return u_getPropertyValueEnum(UCHAR_BLOCK, blockName.c_str());
-}
-
-static int Character_unicodeBlockForCodePoint(JNIEnv*, jclass, jint codePoint) {
-    return ublock_getCode(codePoint);
-}
-
-static int Character_unicodeScriptForName(JNIEnv* env, jclass, jstring javaScriptName) {
-    ScopedUtfChars scriptName(env, javaScriptName);
-    if (scriptName.c_str() == NULL) {
-        return -1;
-    }
-
-    return u_getPropertyValueEnum(UCHAR_SCRIPT, scriptName.c_str());
-}
-
-static int Character_unicodeScriptForCodePoint(JNIEnv*, jclass, jint codePoint) {
-    UErrorCode status = U_ZERO_ERROR;
-    const UScriptCode script = uscript_getScript(codePoint, &status);
-    if (status != U_ZERO_ERROR) {
-        return -1;
-    }
-
-    return script;
-}
-
-static jboolean Character_isAlphabetic(JNIEnv*, jclass, jint codePoint) {
-  return u_hasBinaryProperty(codePoint, UCHAR_ALPHABETIC);
-}
-
-static jboolean Character_isIdeographic(JNIEnv*, jclass, jint codePoint) {
-  return u_hasBinaryProperty(codePoint, UCHAR_IDEOGRAPHIC);
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(Character, digitImpl, "!(II)I"),
-    NATIVE_METHOD(Character, getIcuDirectionality, "!(I)B"),
-    NATIVE_METHOD(Character, getNameImpl, "(I)Ljava/lang/String;"),
-    NATIVE_METHOD(Character, getNumericValueImpl, "!(I)I"),
-    NATIVE_METHOD(Character, getTypeImpl, "!(I)I"),
-    NATIVE_METHOD(Character, isAlphabetic, "!(I)Z"),
-    NATIVE_METHOD(Character, isDefinedImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isDigitImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isIdentifierIgnorableImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isIdeographic, "!(I)Z"),
-    NATIVE_METHOD(Character, isLetterImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isLetterOrDigitImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isLowerCaseImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isMirroredImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isSpaceCharImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isTitleCaseImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isUnicodeIdentifierPartImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isUnicodeIdentifierStartImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isUpperCaseImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, isWhitespaceImpl, "!(I)Z"),
-    NATIVE_METHOD(Character, toLowerCaseImpl, "!(I)I"),
-    NATIVE_METHOD(Character, toTitleCaseImpl, "!(I)I"),
-    NATIVE_METHOD(Character, toUpperCaseImpl, "!(I)I"),
-    NATIVE_METHOD(Character, unicodeBlockForName, "(Ljava/lang/String;)I"),
-    NATIVE_METHOD(Character, unicodeBlockForCodePoint, "!(I)I"),
-    NATIVE_METHOD(Character, unicodeScriptForName, "(Ljava/lang/String;)I"),
-    NATIVE_METHOD(Character, unicodeScriptForCodePoint, "!(I)I"),
-};
-void register_java_lang_Character(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/lang/Character", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_lang_Double.cpp b/luni/src/main/native/java_lang_Double.cpp
deleted file mode 100644
index 186bd26..0000000
--- a/luni/src/main/native/java_lang_Double.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2005 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 "Double"
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-
-union Double {
-    uint64_t bits;
-    double d;
-};
-
-static jlong Double_doubleToRawLongBits(JNIEnv*, jclass, jdouble val) {
-    Double d;
-    d.d = val;
-    return d.bits;
-}
-
-static jdouble Double_longBitsToDouble(JNIEnv*, jclass, jlong val) {
-    Double d;
-    d.bits = val;
-    return d.d;
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(Double, doubleToRawLongBits, "(D)J"),
-    NATIVE_METHOD(Double, longBitsToDouble, "(J)D"),
-};
-void register_java_lang_Double(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/lang/Double", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_lang_Float.cpp b/luni/src/main/native/java_lang_Float.cpp
deleted file mode 100644
index 3852516..0000000
--- a/luni/src/main/native/java_lang_Float.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2005 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 "Float"
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "Portability.h"
-
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-union Float {
-    unsigned int bits;
-    float f;
-};
-
-jint Float_floatToRawIntBits(JNIEnv*, jclass, jfloat val) {
-    Float f;
-    f.f = val;
-    return f.bits;
-}
-
-jfloat Float_intBitsToFloat(JNIEnv*, jclass, jint val) {
-    Float f;
-    f.bits = val;
-    return f.f;
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(Float, floatToRawIntBits, "(F)I"),
-    NATIVE_METHOD(Float, intBitsToFloat, "(I)F"),
-};
-void register_java_lang_Float(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/lang/Float", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_lang_Math.cpp b/luni/src/main/native/java_lang_Math.cpp
deleted file mode 100644
index 83c39bd..0000000
--- a/luni/src/main/native/java_lang_Math.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2006 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 "Math"
-
-#include "jni.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
-
-#include <stdlib.h>
-#include <math.h>
-
-static jdouble Math_sin(JNIEnv*, jclass, jdouble a) {
-    return sin(a);
-}
-
-static jdouble Math_cos(JNIEnv*, jclass, jdouble a) {
-    return cos(a);
-}
-
-static jdouble Math_tan(JNIEnv*, jclass, jdouble a) {
-    return tan(a);
-}
-
-static jdouble Math_asin(JNIEnv*, jclass, jdouble a) {
-    return asin(a);
-}
-
-static jdouble Math_acos(JNIEnv*, jclass, jdouble a) {
-    return acos(a);
-}
-
-static jdouble Math_atan(JNIEnv*, jclass, jdouble a) {
-    return atan(a);
-}
-
-static jdouble Math_exp(JNIEnv*, jclass, jdouble a) {
-    return exp(a);
-}
-
-static jdouble Math_log(JNIEnv*, jclass, jdouble a) {
-    return log(a);
-}
-
-static jdouble Math_IEEEremainder(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return remainder(a, b);
-}
-
-static jdouble Math_floor(JNIEnv*, jclass, jdouble a) {
-    return floor(a);
-}
-
-static jdouble Math_ceil(JNIEnv*, jclass, jdouble a) {
-    return ceil(a);
-}
-
-static jdouble Math_rint(JNIEnv*, jclass, jdouble a) {
-    return rint(a);
-}
-
-static jdouble Math_atan2(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return atan2(a, b);
-}
-
-static jdouble Math_pow(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return pow(a, b);
-}
-
-static jdouble Math_sinh(JNIEnv*, jclass, jdouble a) {
-    return sinh(a);
-}
-
-static jdouble Math_tanh(JNIEnv*, jclass, jdouble a) {
-    return tanh(a);
-}
-
-static jdouble Math_cosh(JNIEnv*, jclass, jdouble a) {
-    return cosh(a);
-}
-
-static jdouble Math_log10(JNIEnv*, jclass, jdouble a) {
-    return log10(a);
-}
-
-static jdouble Math_cbrt(JNIEnv*, jclass, jdouble a) {
-    return cbrt(a);
-}
-
-static jdouble Math_sqrt(JNIEnv*, jclass, jdouble a) {
-    return sqrt(a);
-}
-
-static jdouble Math_expm1(JNIEnv*, jclass, jdouble a) {
-    return expm1(a);
-}
-
-static jdouble Math_hypot(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return hypot(a, b);
-}
-
-static jdouble Math_log1p(JNIEnv*, jclass, jdouble a) {
-    return log1p(a);
-}
-
-static jdouble Math_nextafter(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return nextafter(a, b);
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(Math, IEEEremainder, "!(DD)D"),
-    NATIVE_METHOD(Math, acos, "!(D)D"),
-    NATIVE_METHOD(Math, asin, "!(D)D"),
-    NATIVE_METHOD(Math, atan, "!(D)D"),
-    NATIVE_METHOD(Math, atan2, "!(DD)D"),
-    NATIVE_METHOD(Math, cbrt, "!(D)D"),
-    NATIVE_METHOD(Math, ceil, "!(D)D"),
-    NATIVE_METHOD(Math, cos, "!(D)D"),
-    NATIVE_METHOD(Math, cosh, "!(D)D"),
-    NATIVE_METHOD(Math, exp, "!(D)D"),
-    NATIVE_METHOD(Math, expm1, "!(D)D"),
-    NATIVE_METHOD(Math, floor, "!(D)D"),
-    NATIVE_METHOD(Math, hypot, "!(DD)D"),
-    NATIVE_METHOD(Math, log, "!(D)D"),
-    NATIVE_METHOD(Math, log10, "!(D)D"),
-    NATIVE_METHOD(Math, log1p, "!(D)D"),
-    NATIVE_METHOD(Math, nextafter, "!(DD)D"),
-    NATIVE_METHOD(Math, pow, "!(DD)D"),
-    NATIVE_METHOD(Math, rint, "!(D)D"),
-    NATIVE_METHOD(Math, sin, "!(D)D"),
-    NATIVE_METHOD(Math, sinh, "!(D)D"),
-    NATIVE_METHOD(Math, sqrt, "!(D)D"),
-    NATIVE_METHOD(Math, tan, "!(D)D"),
-    NATIVE_METHOD(Math, tanh, "!(D)D"),
-};
-void register_java_lang_Math(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/lang/Math", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_lang_ProcessManager.cpp b/luni/src/main/native/java_lang_ProcessManager.cpp
deleted file mode 100644
index 7d2079d..0000000
--- a/luni/src/main/native/java_lang_ProcessManager.cpp
+++ /dev/null
@@ -1,225 +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 "ProcessManager"
-
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/resource.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include "cutils/log.h"
-#include "jni.h"
-#include "ExecStrings.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "Portability.h"
-#include "ScopedLocalRef.h"
-#include "toStringArray.h"
-
-static void CloseNonStandardFds(int status_pipe_fd) {
-  // On Cygwin, Linux, and Solaris, the best way to close iterates over "/proc/self/fd/".
-  const char* fd_path = "/proc/self/fd";
-
-  DIR* d = opendir(fd_path);
-  int dir_fd = dirfd(d);
-  dirent* e;
-  while ((e = readdir(d)) != NULL) {
-    char* end;
-    int fd = strtol(e->d_name, &end, 10);
-    if (!*end) {
-      if (fd > STDERR_FILENO && fd != dir_fd && fd != status_pipe_fd) {
-        close(fd);
-      }
-    }
-  }
-  closedir(d);
-}
-
-#define PIPE_COUNT 4 // Number of pipes used to communicate with child.
-
-static void ClosePipes(int pipes[], int skip_fd) {
-  for (int i = 0; i < PIPE_COUNT * 2; i++) {
-    int fd = pipes[i];
-    if (fd != -1 && fd != skip_fd) {
-      close(pipes[i]);
-    }
-  }
-}
-
-static void AbortChild(int status_pipe_fd) {
-  int error = errno;
-  TEMP_FAILURE_RETRY(write(status_pipe_fd, &error, sizeof(int)));
-  close(status_pipe_fd);
-  _exit(127);
-}
-
-/** Executes a command in a child process. */
-static pid_t ExecuteProcess(JNIEnv* env, char** commands, char** environment,
-                            const char* workingDirectory, jobject inDescriptor,
-                            jobject outDescriptor, jobject errDescriptor,
-                            jboolean redirectErrorStream) {
-
-  // Create 4 pipes: stdin, stdout, stderr, and an exec() status pipe.
-  int pipes[PIPE_COUNT * 2] = { -1, -1, -1, -1, -1, -1, -1, -1 };
-  for (int i = 0; i < PIPE_COUNT; i++) {
-    if (pipe(pipes + i * 2) == -1) {
-      jniThrowIOException(env, errno);
-      ClosePipes(pipes, -1);
-      return -1;
-    }
-  }
-  int stdinIn = pipes[0];
-  int stdinOut = pipes[1];
-  int stdoutIn = pipes[2];
-  int stdoutOut = pipes[3];
-  int stderrIn = pipes[4];
-  int stderrOut = pipes[5];
-  int statusIn = pipes[6];
-  int statusOut = pipes[7];
-
-  pid_t childPid = fork();
-
-  // If fork() failed...
-  if (childPid == -1) {
-    jniThrowIOException(env, errno);
-    ClosePipes(pipes, -1);
-    return -1;
-  }
-
-  // If this is the child process...
-  if (childPid == 0) {
-    // Note: We cannot malloc(3) or free(3) after this point!
-    // A thread in the parent that no longer exists in the child may have held the heap lock
-    // when we forked, so an attempt to malloc(3) or free(3) would result in deadlock.
-
-    // Replace stdin, out, and err with pipes.
-    dup2(stdinIn, 0);
-    dup2(stdoutOut, 1);
-    if (redirectErrorStream) {
-      dup2(stdoutOut, 2);
-    } else {
-      dup2(stderrOut, 2);
-    }
-
-    // Close all but statusOut. This saves some work in the next step.
-    ClosePipes(pipes, statusOut);
-
-    // Make statusOut automatically close if execvp() succeeds.
-    fcntl(statusOut, F_SETFD, FD_CLOEXEC);
-
-    // Close remaining unwanted open fds.
-    CloseNonStandardFds(statusOut);
-
-    // Switch to working directory.
-    if (workingDirectory != NULL) {
-      if (chdir(workingDirectory) == -1) {
-        AbortChild(statusOut);
-      }
-    }
-
-    // Set up environment.
-    if (environment != NULL) {
-      extern char** environ; // Standard, but not in any header file.
-      environ = environment;
-    }
-
-    // Execute process. By convention, the first argument in the arg array
-    // should be the command itself.
-    execvp(commands[0], commands);
-    AbortChild(statusOut);
-  }
-
-  // This is the parent process.
-
-  // Close child's pipe ends.
-  close(stdinIn);
-  close(stdoutOut);
-  close(stderrOut);
-  close(statusOut);
-
-  // Check status pipe for an error code. If execvp(2) succeeds, the other
-  // end of the pipe should automatically close, in which case, we'll read
-  // nothing.
-  int child_errno;
-  ssize_t count = TEMP_FAILURE_RETRY(read(statusIn, &child_errno, sizeof(int)));
-  close(statusIn);
-  if (count > 0) {
-    // chdir(2) or execvp(2) in the child failed.
-    // TODO: track which so we can be more specific in the detail message.
-    jniThrowIOException(env, child_errno);
-
-    close(stdoutIn);
-    close(stdinOut);
-    close(stderrIn);
-
-    // Reap our zombie child right away.
-    int status;
-    int rc = TEMP_FAILURE_RETRY(waitpid(childPid, &status, 0));
-    if (rc == -1) {
-      ALOGW("waitpid on failed exec failed: %s", strerror(errno));
-    }
-
-    return -1;
-  }
-
-  // Fill in file descriptor wrappers.
-  jniSetFileDescriptorOfFD(env, inDescriptor, stdoutIn);
-  jniSetFileDescriptorOfFD(env, outDescriptor, stdinOut);
-  jniSetFileDescriptorOfFD(env, errDescriptor, stderrIn);
-
-  return childPid;
-}
-
-/**
- * Converts Java String[] to char** and delegates to ExecuteProcess().
- */
-static pid_t ProcessManager_exec(JNIEnv* env, jclass, jobjectArray javaCommands,
-                                 jobjectArray javaEnvironment, jstring javaWorkingDirectory,
-                                 jobject inDescriptor, jobject outDescriptor, jobject errDescriptor,
-                                 jboolean redirectErrorStream) {
-
-  ExecStrings commands(env, javaCommands);
-  ExecStrings environment(env, javaEnvironment);
-
-  // Extract working directory string.
-  const char* workingDirectory = NULL;
-  if (javaWorkingDirectory != NULL) {
-    workingDirectory = env->GetStringUTFChars(javaWorkingDirectory, NULL);
-  }
-
-  pid_t result = ExecuteProcess(env, commands.get(), environment.get(), workingDirectory,
-                                inDescriptor, outDescriptor, errDescriptor, redirectErrorStream);
-
-  // Clean up working directory string.
-  if (javaWorkingDirectory != NULL) {
-    env->ReleaseStringUTFChars(javaWorkingDirectory, workingDirectory);
-  }
-
-  return result;
-}
-
-static JNINativeMethod gMethods[] = {
-  NATIVE_METHOD(ProcessManager, exec, "([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Z)I"),
-};
-void register_java_lang_ProcessManager(JNIEnv* env) {
-  jniRegisterNativeMethods(env, "java/lang/ProcessManager", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_lang_RealToString.cpp b/luni/src/main/native/java_lang_RealToString.cpp
deleted file mode 100644
index 9b412b5..0000000
--- a/luni/src/main/native/java_lang_RealToString.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-#define LOG_TAG "RealToString"
-
-#include <string.h>
-#include <math.h>
-#include <stdlib.h>
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "ScopedLocalRef.h"
-#include "ScopedPrimitiveArray.h"
-#include "cbigint.h"
-
-#define INV_LOG_OF_TEN_BASE_2 (0.30102999566398114) /* Local */
-
-/*NB the Number converter methods are synchronized so it is possible to
- *have global data for use by bigIntDigitGenerator */
-#define RM_SIZE 21     /* Local. */
-#define STemp_SIZE 22  /* Local. */
-
-/* The algorithm for this particular function can be found in:
- *
- *      Printing Floating-Point Numbers Quickly and Accurately, Robert
- *      G. Burger, and R. Kent Dybvig, Programming Language Design and
- *      Implementation (PLDI) 1996, pp.108-116.
- *
- * The previous implementation of this function combined m+ and m- into
- * one single M which caused some inaccuracy of the last digit. The
- * particular case below shows this inaccuracy:
- *
- *       System.out.println(new Double((1.234123412431233E107)).toString());
- *       System.out.println(new Double((1.2341234124312331E107)).toString());
- *       System.out.println(new Double((1.2341234124312332E107)).toString());
- *
- *       outputs the following:
- *
- *           1.234123412431233E107
- *           1.234123412431233E107
- *           1.234123412431233E107
- *
- *       instead of:
- *
- *           1.234123412431233E107
- *           1.2341234124312331E107
- *           1.2341234124312331E107
- *
- */
-void RealToString_bigIntDigitGenerator(JNIEnv* env, jobject obj, jlong f, jint e,
-        jboolean isDenormalized, jint p) {
-  int RLength, SLength, TempLength, mplus_Length, mminus_Length;
-  int high, low, i;
-  jint k, firstK, U;
-
-  uint64_t R[RM_SIZE], S[STemp_SIZE], mplus[RM_SIZE], mminus[RM_SIZE], Temp[STemp_SIZE];
-
-  memset (R     , 0, RM_SIZE    * sizeof (uint64_t));
-  memset (S     , 0, STemp_SIZE * sizeof (uint64_t));
-  memset (mplus , 0, RM_SIZE    * sizeof (uint64_t));
-  memset (mminus, 0, RM_SIZE    * sizeof (uint64_t));
-  memset (Temp  , 0, STemp_SIZE * sizeof (uint64_t));
-
-  if (e >= 0)
-    {
-      *R = f;
-      *mplus = *mminus = 1;
-      simpleShiftLeftHighPrecision (mminus, RM_SIZE, e);
-      if (f != (INT64_C(1) << p))
-        {
-          simpleShiftLeftHighPrecision (R, RM_SIZE, e + 1);
-          *S = 2;
-          /*
-           * m+ = m+ << e results in 1.0e23 to be printed as
-           * 0.9999999999999999E23
-           * m+ = m+ << e+1 results in 1.0e23 to be printed as
-           * 1.0e23 (caused too much rounding)
-           *      470fffffffffffff = 2.0769187434139308E34
-           *      4710000000000000 = 2.076918743413931E34
-           */
-          simpleShiftLeftHighPrecision (mplus, RM_SIZE, e);
-        }
-      else
-        {
-          simpleShiftLeftHighPrecision (R, RM_SIZE, e + 2);
-          *S = 4;
-          simpleShiftLeftHighPrecision (mplus, RM_SIZE, e + 1);
-        }
-    }
-  else
-    {
-      if (isDenormalized || (f != (INT64_C(1) << p)))
-        {
-          *R = f << 1;
-          *S = 1;
-          simpleShiftLeftHighPrecision (S, STemp_SIZE, 1 - e);
-          *mplus = *mminus = 1;
-        }
-      else
-        {
-          *R = f << 2;
-          *S = 1;
-          simpleShiftLeftHighPrecision (S, STemp_SIZE, 2 - e);
-          *mplus = 2;
-          *mminus = 1;
-        }
-    }
-
-  k = static_cast<int>(ceil ((e + p - 1) * INV_LOG_OF_TEN_BASE_2 - 1e-10));
-
-  if (k > 0)
-    {
-      timesTenToTheEHighPrecision (S, STemp_SIZE, k);
-    }
-  else
-    {
-      timesTenToTheEHighPrecision (R     , RM_SIZE, -k);
-      timesTenToTheEHighPrecision (mplus , RM_SIZE, -k);
-      timesTenToTheEHighPrecision (mminus, RM_SIZE, -k);
-    }
-
-  RLength = mplus_Length = mminus_Length = RM_SIZE;
-  SLength = TempLength = STemp_SIZE;
-
-  memset (Temp + RM_SIZE, 0, (STemp_SIZE - RM_SIZE) * sizeof (uint64_t));
-  memcpy (Temp, R, RM_SIZE * sizeof (uint64_t));
-
-  while (RLength > 1 && R[RLength - 1] == 0)
-    --RLength;
-  while (mplus_Length > 1 && mplus[mplus_Length - 1] == 0)
-    --mplus_Length;
-  while (mminus_Length > 1 && mminus[mminus_Length - 1] == 0)
-    --mminus_Length;
-  while (SLength > 1 && S[SLength - 1] == 0)
-    --SLength;
-  TempLength = (RLength > mplus_Length ? RLength : mplus_Length) + 1;
-  addHighPrecision (Temp, TempLength, mplus, mplus_Length);
-
-  if (compareHighPrecision (Temp, TempLength, S, SLength) >= 0)
-    {
-      firstK = k;
-    }
-  else
-    {
-      firstK = k - 1;
-      simpleAppendDecimalDigitHighPrecision (R     , ++RLength      , 0);
-      simpleAppendDecimalDigitHighPrecision (mplus , ++mplus_Length , 0);
-      simpleAppendDecimalDigitHighPrecision (mminus, ++mminus_Length, 0);
-      while (RLength > 1 && R[RLength - 1] == 0)
-        --RLength;
-      while (mplus_Length > 1 && mplus[mplus_Length - 1] == 0)
-        --mplus_Length;
-      while (mminus_Length > 1 && mminus[mminus_Length - 1] == 0)
-        --mminus_Length;
-    }
-
-  static jfieldID digitsFid = env->GetFieldID(JniConstants::realToStringClass, "digits", "[I");
-  ScopedLocalRef<jintArray> javaDigits(env, reinterpret_cast<jintArray>(env->GetObjectField(obj, digitsFid)));
-  ScopedIntArrayRW digits(env, javaDigits.get());
-  if (digits.get() == NULL) {
-    return;
-  }
-
-  jint digitCount = 0;
-  do
-    {
-      U = 0;
-      for (i = 3; i >= 0; --i)
-        {
-          TempLength = SLength + 1;
-          Temp[SLength] = 0;
-          memcpy (Temp, S, SLength * sizeof (uint64_t));
-          simpleShiftLeftHighPrecision (Temp, TempLength, i);
-          if (compareHighPrecision (R, RLength, Temp, TempLength) >= 0)
-            {
-              subtractHighPrecision (R, RLength, Temp, TempLength);
-              U += 1 << i;
-            }
-        }
-
-      low = compareHighPrecision (R, RLength, mminus, mminus_Length) <= 0;
-
-      memset (Temp + RLength, 0, (STemp_SIZE - RLength) * sizeof (uint64_t));
-      memcpy (Temp, R, RLength * sizeof (uint64_t));
-      TempLength = (RLength > mplus_Length ? RLength : mplus_Length) + 1;
-      addHighPrecision (Temp, TempLength, mplus, mplus_Length);
-
-      high = compareHighPrecision (Temp, TempLength, S, SLength) >= 0;
-
-      if (low || high)
-        break;
-
-      simpleAppendDecimalDigitHighPrecision (R     , ++RLength      , 0);
-      simpleAppendDecimalDigitHighPrecision (mplus , ++mplus_Length , 0);
-      simpleAppendDecimalDigitHighPrecision (mminus, ++mminus_Length, 0);
-      while (RLength > 1 && R[RLength - 1] == 0)
-        --RLength;
-      while (mplus_Length > 1 && mplus[mplus_Length - 1] == 0)
-        --mplus_Length;
-      while (mminus_Length > 1 && mminus[mminus_Length - 1] == 0)
-        --mminus_Length;
-      digits[digitCount++] = U;
-    }
-  while (1);
-
-  simpleShiftLeftHighPrecision (R, ++RLength, 1);
-  if (low && !high)
-    digits[digitCount++] = U;
-  else if (high && !low)
-    digits[digitCount++] = U + 1;
-  else if (compareHighPrecision (R, RLength, S, SLength) < 0)
-    digits[digitCount++] = U;
-  else
-    digits[digitCount++] = U + 1;
-
-  static jfieldID digitCountFid = env->GetFieldID(JniConstants::realToStringClass, "digitCount", "I");
-  env->SetIntField(obj, digitCountFid, digitCount);
-
-  static jfieldID firstKFid = env->GetFieldID(JniConstants::realToStringClass, "firstK", "I");
-  env->SetIntField(obj, firstKFid, firstK);
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(RealToString, bigIntDigitGenerator, "(JIZI)V"),
-};
-void register_java_lang_RealToString(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/lang/RealToString", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_lang_StrictMath.cpp b/luni/src/main/native/java_lang_StrictMath.cpp
deleted file mode 100644
index d0bb8ce..0000000
--- a/luni/src/main/native/java_lang_StrictMath.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006 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 "StrictMath"
-
-#include "../../external/fdlibm/fdlibm.h"
-
-#include "jni.h"
-#include "JNIHelp.h"
-#include "JniConstants.h"
-
-static jdouble StrictMath_sin(JNIEnv*, jclass, jdouble a) {
-    return ieee_sin(a);
-}
-
-static jdouble StrictMath_cos(JNIEnv*, jclass, jdouble a) {
-    return ieee_cos(a);
-}
-
-static jdouble StrictMath_tan(JNIEnv*, jclass, jdouble a) {
-    return ieee_tan(a);
-}
-
-static jdouble StrictMath_sqrt(JNIEnv*, jclass, jdouble a) {
-    return ieee_sqrt(a);
-}
-
-static jdouble StrictMath_IEEEremainder(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return ieee_remainder(a, b);
-}
-
-static jdouble StrictMath_rint(JNIEnv*, jclass, jdouble a) {
-    return ieee_rint(a);
-}
-
-static jdouble StrictMath_pow(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return ieee_pow(a,b);
-}
-
-static jdouble StrictMath_hypot(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return ieee_hypot(a, b);
-}
-
-static jdouble StrictMath_nextafter(JNIEnv*, jclass, jdouble a, jdouble b) {
-    return ieee_nextafter(a, b);
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(StrictMath, IEEEremainder, "!(DD)D"),
-    NATIVE_METHOD(StrictMath, cos, "!(D)D"),
-    NATIVE_METHOD(StrictMath, hypot, "!(DD)D"),
-    NATIVE_METHOD(StrictMath, nextafter, "!(DD)D"),
-    NATIVE_METHOD(StrictMath, pow, "!(DD)D"),
-    NATIVE_METHOD(StrictMath, rint, "!(D)D"),
-    NATIVE_METHOD(StrictMath, sin, "!(D)D"),
-    NATIVE_METHOD(StrictMath, sqrt, "!(D)D"),
-    NATIVE_METHOD(StrictMath, tan, "!(D)D"),
-};
-void register_java_lang_StrictMath(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/lang/StrictMath", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_lang_System.cpp b/luni/src/main/native/java_lang_System.cpp
deleted file mode 100644
index 1ba230a..0000000
--- a/luni/src/main/native/java_lang_System.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2008 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 "System"
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "ScopedUtfChars.h"
-#include "cutils/log.h"
-#include "openssl/opensslv.h"
-#include "toStringArray.h"
-#include "zlib.h"
-
-#include <string>
-#include <vector>
-
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-#include <time.h>
-#include <unistd.h>
-
-#if defined(__ANDROID__)
-extern "C" void android_get_LD_LIBRARY_PATH(char*, size_t);
-#endif
-
-static void System_log(JNIEnv* env, jclass, jchar type, jstring javaMessage, jthrowable exception) {
-    ScopedUtfChars message(env, javaMessage);
-    if (message.c_str() == NULL) {
-        // Since this function is used for last-gasp debugging output, be noisy on failure.
-        ALOGE("message.c_str() == NULL");
-        return;
-    }
-    int priority;
-    switch (type) {
-    case 'D': case 'd': priority = ANDROID_LOG_DEBUG;   break;
-    case 'E': case 'e': priority = ANDROID_LOG_ERROR;   break;
-    case 'F': case 'f': priority = ANDROID_LOG_FATAL;   break;
-    case 'I': case 'i': priority = ANDROID_LOG_INFO;    break;
-    case 'S': case 's': priority = ANDROID_LOG_SILENT;  break;
-    case 'V': case 'v': priority = ANDROID_LOG_VERBOSE; break;
-    case 'W': case 'w': priority = ANDROID_LOG_WARN;    break;
-    default:            priority = ANDROID_LOG_DEFAULT; break;
-    }
-    LOG_PRI(priority, LOG_TAG, "%s", message.c_str());
-    if (exception != NULL) {
-        jniLogException(env, priority, LOG_TAG, exception);
-    }
-}
-
-// Sets a field via JNI. Used for the standard streams, which are read-only otherwise.
-static void System_setFieldImpl(JNIEnv* env, jclass clazz,
-        jstring javaName, jstring javaSignature, jobject object) {
-    ScopedUtfChars name(env, javaName);
-    if (name.c_str() == NULL) {
-        return;
-    }
-    ScopedUtfChars signature(env, javaSignature);
-    if (signature.c_str() == NULL) {
-        return;
-    }
-    jfieldID fieldID = env->GetStaticFieldID(clazz, name.c_str(), signature.c_str());
-    env->SetStaticObjectField(clazz, fieldID, object);
-}
-
-static jobjectArray System_specialProperties(JNIEnv* env, jclass) {
-    std::vector<std::string> properties;
-
-    char path[PATH_MAX];
-    properties.push_back(std::string("user.dir=") + getcwd(path, sizeof(path)));
-
-    properties.push_back("android.zlib.version=" ZLIB_VERSION);
-#if defined(OPENSSL_IS_BORINGSSL)
-    properties.push_back("android.openssl.version=BoringSSL");
-#else
-    properties.push_back("android.openssl.version=" OPENSSL_VERSION_TEXT);
-#endif
-
-    const char* library_path = getenv("LD_LIBRARY_PATH");
-#if defined(__ANDROID__)
-    if (library_path == NULL) {
-        android_get_LD_LIBRARY_PATH(path, sizeof(path));
-        library_path = path;
-    }
-#endif
-    if (library_path == NULL) {
-        library_path = "";
-    }
-    properties.push_back(std::string("java.library.path=") + library_path);
-
-    return toStringArray(env, properties);
-}
-
-static jlong System_currentTimeMillis(JNIEnv*, jclass) {
-    timeval now;
-    gettimeofday(&now, NULL);
-    jlong when = now.tv_sec * 1000LL + now.tv_usec / 1000;
-    return when;
-}
-
-static jlong System_nanoTime(JNIEnv*, jclass) {
-    timespec now;
-    clock_gettime(CLOCK_MONOTONIC, &now);
-    return now.tv_sec * 1000000000LL + now.tv_nsec;
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(System, currentTimeMillis, "!()J"),
-    NATIVE_METHOD(System, log, "(CLjava/lang/String;Ljava/lang/Throwable;)V"),
-    NATIVE_METHOD(System, nanoTime, "!()J"),
-    NATIVE_METHOD(System, setFieldImpl, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V"),
-    NATIVE_METHOD(System, specialProperties, "()[Ljava/lang/String;"),
-};
-void register_java_lang_System(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/lang/System", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_util_zip_Adler32.cpp b/luni/src/main/native/java_util_zip_Adler32.cpp
deleted file mode 100644
index 9358f26..0000000
--- a/luni/src/main/native/java_util_zip_Adler32.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Adler32"
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "ScopedPrimitiveArray.h"
-#include "jni.h"
-#include "zlib.h"
-
-static jlong Adler32_updateImpl(JNIEnv* env, jobject, jbyteArray byteArray, int off, int len, jlong crc) {
-    ScopedByteArrayRO bytes(env, byteArray);
-    if (bytes.get() == NULL) {
-        return 0;
-    }
-    return adler32(crc, reinterpret_cast<const Bytef*>(bytes.get() + off), len);
-}
-
-static jlong Adler32_updateByteImpl(JNIEnv*, jobject, jint val, jlong crc) {
-    Bytef bytefVal = val;
-    return adler32(crc, reinterpret_cast<const Bytef*>(&bytefVal), 1);
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(Adler32, updateImpl, "([BIIJ)J"),
-    NATIVE_METHOD(Adler32, updateByteImpl, "(IJ)J"),
-};
-void register_java_util_zip_Adler32(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/util/zip/Adler32", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_util_zip_CRC32.cpp b/luni/src/main/native/java_util_zip_CRC32.cpp
deleted file mode 100644
index 502a4ec..0000000
--- a/luni/src/main/native/java_util_zip_CRC32.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "CRC32"
-
-#include "JNIHelp.h"
-#include "JniConstants.h"
-#include "ScopedPrimitiveArray.h"
-#include "jni.h"
-#include "zlib.h"
-
-static jlong CRC32_updateImpl(JNIEnv* env, jobject, jbyteArray byteArray, int off, int len, jlong crc) {
-    ScopedByteArrayRO bytes(env, byteArray);
-    if (bytes.get() == NULL) {
-        return 0;
-    }
-    jlong result = crc32(crc, reinterpret_cast<const Bytef*>(bytes.get() + off), len);
-    return result;
-}
-
-static jlong CRC32_updateByteImpl(JNIEnv*, jobject, jbyte val, jlong crc) {
-    return crc32(crc, reinterpret_cast<const Bytef*>(&val), 1);
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(CRC32, updateImpl, "([BIIJ)J"),
-    NATIVE_METHOD(CRC32, updateByteImpl, "(BJ)J"),
-};
-void register_java_util_zip_CRC32(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/util/zip/CRC32", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_util_zip_Deflater.cpp b/luni/src/main/native/java_util_zip_Deflater.cpp
deleted file mode 100644
index d963824..0000000
--- a/luni/src/main/native/java_util_zip_Deflater.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Deflater"
-
-#include "JniConstants.h"
-#include "JniException.h"
-#include "ScopedPrimitiveArray.h"
-#include "ZipUtilities.h"
-#include "zutil.h" // For DEF_WBITS and DEF_MEM_LEVEL.
-
-static void Deflater_setDictionaryImpl(JNIEnv* env, jobject, jbyteArray dict, int off, int len, jlong handle) {
-    toNativeZipStream(handle)->setDictionary(env, dict, off, len, false);
-}
-
-static jlong Deflater_getTotalInImpl(JNIEnv*, jobject, jlong handle) {
-    return toNativeZipStream(handle)->totalIn;
-}
-
-static jlong Deflater_getTotalOutImpl(JNIEnv*, jobject, jlong handle) {
-    return toNativeZipStream(handle)->totalOut;
-}
-
-static jint Deflater_getAdlerImpl(JNIEnv*, jobject, jlong handle) {
-    return toNativeZipStream(handle)->stream.adler;
-}
-
-static jlong Deflater_createStream(JNIEnv * env, jobject, jint level, jint strategy, jboolean noHeader) {
-    std::unique_ptr<NativeZipStream> jstream(new NativeZipStream);
-    if (jstream.get() == NULL) {
-        jniThrowOutOfMemoryError(env, NULL);
-        return -1;
-    }
-
-    /*
-     * See zlib.h for documentation of the deflateInit2 windowBits and memLevel parameters.
-     *
-     * zconf.h says the "requirements for deflate are (in bytes):
-     *         (1 << (windowBits+2)) +  (1 << (memLevel+9))
-     * that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
-     * plus a few kilobytes for small objects."
-     */
-    int windowBits = noHeader ? -DEF_WBITS : DEF_WBITS;
-    int memLevel = DEF_MEM_LEVEL;
-    int err = deflateInit2(&jstream->stream, level, Z_DEFLATED, windowBits, memLevel, strategy);
-    if (err != Z_OK) {
-        throwExceptionForZlibError(env, "java/lang/IllegalArgumentException", err, jstream.get());
-        return -1;
-    }
-    return reinterpret_cast<uintptr_t>(jstream.release());
-}
-
-static void Deflater_setInputImpl(JNIEnv* env, jobject, jbyteArray buf, jint off, jint len, jlong handle) {
-    toNativeZipStream(handle)->setInput(env, buf, off, len);
-}
-
-static jint Deflater_deflateImpl(JNIEnv* env, jobject recv, jbyteArray buf, int off, int len, jlong handle, int flushStyle) {
-    NativeZipStream* stream = toNativeZipStream(handle);
-    ScopedByteArrayRW out(env, buf);
-    if (out.get() == NULL) {
-        return -1;
-    }
-    stream->stream.next_out = reinterpret_cast<Bytef*>(out.get() + off);
-    stream->stream.avail_out = len;
-
-    Bytef* initialNextIn = stream->stream.next_in;
-    Bytef* initialNextOut = stream->stream.next_out;
-
-    int err = deflate(&stream->stream, flushStyle);
-    switch (err) {
-    case Z_OK:
-        break;
-    case Z_STREAM_END:
-        static jfieldID finished = env->GetFieldID(JniConstants::deflaterClass, "finished", "Z");
-        env->SetBooleanField(recv, finished, JNI_TRUE);
-        break;
-    case Z_BUF_ERROR:
-        // zlib reports this "if no progress is possible (for example avail_in or avail_out was
-        // zero) ... Z_BUF_ERROR is not fatal, and deflate() can be called again with more
-        // input and more output space to continue compressing".
-        break;
-    default:
-        throwExceptionForZlibError(env, "java/util/zip/DataFormatException", err, stream);
-        return -1;
-    }
-
-    jint bytesRead = stream->stream.next_in - initialNextIn;
-    jint bytesWritten = stream->stream.next_out - initialNextOut;
-
-    stream->totalIn += bytesRead;
-    stream->totalOut += bytesWritten;
-
-    static jfieldID inReadField = env->GetFieldID(JniConstants::deflaterClass, "inRead", "I");
-    jint inReadValue = env->GetIntField(recv, inReadField);
-    inReadValue += bytesRead;
-    env->SetIntField(recv, inReadField, inReadValue);
-    return bytesWritten;
-}
-
-static void Deflater_endImpl(JNIEnv*, jobject, jlong handle) {
-    NativeZipStream* stream = toNativeZipStream(handle);
-    deflateEnd(&stream->stream);
-    delete stream;
-}
-
-static void Deflater_resetImpl(JNIEnv* env, jobject, jlong handle) {
-    NativeZipStream* stream = toNativeZipStream(handle);
-    stream->totalIn = 0;
-    stream->totalOut = 0;
-    int err = deflateReset(&stream->stream);
-    if (err != Z_OK) {
-        throwExceptionForZlibError(env, "java/lang/IllegalArgumentException", err, stream);
-    }
-}
-
-static void Deflater_setLevelsImpl(JNIEnv* env, jobject, int level, int strategy, jlong handle) {
-    NativeZipStream* stream = toNativeZipStream(handle);
-    // The deflateParams documentation says that avail_out must never be 0 because it may be
-    // necessary to flush, but the Java API ensures that we only get here if there's nothing
-    // to flush. To be on the safe side, make sure that we're not pointing to a no longer valid
-    // buffer.
-    stream->stream.next_out = reinterpret_cast<Bytef*>(NULL);
-    stream->stream.avail_out = 0;
-    int err = deflateParams(&stream->stream, level, strategy);
-    if (err != Z_OK) {
-        throwExceptionForZlibError(env, "java/lang/IllegalStateException", err, stream);
-    }
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(Deflater, createStream, "(IIZ)J"),
-    NATIVE_METHOD(Deflater, deflateImpl, "([BIIJI)I"),
-    NATIVE_METHOD(Deflater, endImpl, "(J)V"),
-    NATIVE_METHOD(Deflater, getAdlerImpl, "(J)I"),
-    NATIVE_METHOD(Deflater, getTotalInImpl, "(J)J"),
-    NATIVE_METHOD(Deflater, getTotalOutImpl, "(J)J"),
-    NATIVE_METHOD(Deflater, resetImpl, "(J)V"),
-    NATIVE_METHOD(Deflater, setDictionaryImpl, "([BIIJ)V"),
-    NATIVE_METHOD(Deflater, setInputImpl, "([BIIJ)V"),
-    NATIVE_METHOD(Deflater, setLevelsImpl, "(IIJ)V"),
-};
-void register_java_util_zip_Deflater(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/util/zip/Deflater", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/java_util_zip_Inflater.cpp b/luni/src/main/native/java_util_zip_Inflater.cpp
deleted file mode 100644
index f0878ff..0000000
--- a/luni/src/main/native/java_util_zip_Inflater.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Inflater"
-
-#include "JniConstants.h"
-#include "JniException.h"
-#include "ScopedPrimitiveArray.h"
-#include "ZipUtilities.h"
-#include "zutil.h" // For DEF_WBITS and DEF_MEM_LEVEL.
-#include <errno.h>
-
-static jlong Inflater_createStream(JNIEnv* env, jobject, jboolean noHeader) {
-    std::unique_ptr<NativeZipStream> jstream(new NativeZipStream);
-    if (jstream.get() == NULL) {
-        jniThrowOutOfMemoryError(env, NULL);
-        return -1;
-    }
-    jstream->stream.adler = 1;
-
-    /*
-     * See zlib.h for documentation of the inflateInit2 windowBits parameter.
-     *
-     * zconf.h says the "requirements for inflate are (in bytes) 1 << windowBits
-     * that is, 32K for windowBits=15 (default value) plus a few kilobytes
-     * for small objects." This means that we can happily use the default
-     * here without worrying about memory consumption.
-     */
-    int err = inflateInit2(&jstream->stream, noHeader ? -DEF_WBITS : DEF_WBITS);
-    if (err != Z_OK) {
-        throwExceptionForZlibError(env, "java/lang/IllegalArgumentException", err, jstream.get());
-        return -1;
-    }
-    return reinterpret_cast<uintptr_t>(jstream.release());
-}
-
-static void Inflater_setInputImpl(JNIEnv* env, jobject, jbyteArray buf, jint off, jint len, jlong handle) {
-    toNativeZipStream(handle)->setInput(env, buf, off, len);
-}
-
-static jint Inflater_setFileInputImpl(JNIEnv* env, jobject, jobject javaFileDescriptor, jlong off, jint len, jlong handle) {
-    NativeZipStream* stream = toNativeZipStream(handle);
-
-    // We reuse the existing native buffer if it's large enough.
-    // TODO: benchmark.
-    if (stream->inCap < len) {
-        stream->setInput(env, NULL, 0, len);
-    } else {
-        stream->stream.next_in = reinterpret_cast<Bytef*>(&stream->input[0]);
-        stream->stream.avail_in = len;
-    }
-
-    // As an Android-specific optimization, we read directly onto the native heap.
-    // The original code used Java to read onto the Java heap and then called setInput(byte[]).
-    // TODO: benchmark.
-    int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
-    int rc = TEMP_FAILURE_RETRY(lseek(fd, off, SEEK_SET));
-    if (rc == -1) {
-        jniThrowIOException(env, errno);
-        return 0;
-    }
-    jint totalByteCount = 0;
-    Bytef* dst = reinterpret_cast<Bytef*>(&stream->input[0]);
-    ssize_t byteCount;
-    while ((byteCount = TEMP_FAILURE_RETRY(read(fd, dst, len))) > 0) {
-        dst += byteCount;
-        len -= byteCount;
-        totalByteCount += byteCount;
-    }
-    if (byteCount == -1) {
-        jniThrowIOException(env, errno);
-        return 0;
-    }
-    return totalByteCount;
-}
-
-static jint Inflater_inflateImpl(JNIEnv* env, jobject recv, jbyteArray buf, int off, int len, jlong handle) {
-    NativeZipStream* stream = toNativeZipStream(handle);
-    ScopedByteArrayRW out(env, buf);
-    if (out.get() == NULL) {
-        return -1;
-    }
-    stream->stream.next_out = reinterpret_cast<Bytef*>(out.get() + off);
-    stream->stream.avail_out = len;
-
-    Bytef* initialNextIn = stream->stream.next_in;
-    Bytef* initialNextOut = stream->stream.next_out;
-
-    int err = inflate(&stream->stream, Z_SYNC_FLUSH);
-    switch (err) {
-    case Z_OK:
-        break;
-    case Z_NEED_DICT:
-        static jfieldID needsDictionary = env->GetFieldID(JniConstants::inflaterClass, "needsDictionary", "Z");
-        env->SetBooleanField(recv, needsDictionary, JNI_TRUE);
-        break;
-    case Z_STREAM_END:
-        static jfieldID finished = env->GetFieldID(JniConstants::inflaterClass, "finished", "Z");
-        env->SetBooleanField(recv, finished, JNI_TRUE);
-        break;
-    case Z_STREAM_ERROR:
-        return 0;
-    default:
-        throwExceptionForZlibError(env, "java/util/zip/DataFormatException", err, stream);
-        return -1;
-    }
-
-    jint bytesRead = stream->stream.next_in - initialNextIn;
-    jint bytesWritten = stream->stream.next_out - initialNextOut;
-
-    stream->totalIn += bytesRead;
-    stream->totalOut += bytesWritten;
-
-    static jfieldID inReadField = env->GetFieldID(JniConstants::inflaterClass, "inRead", "I");
-    jint inReadValue = env->GetIntField(recv, inReadField);
-    inReadValue += bytesRead;
-    env->SetIntField(recv, inReadField, inReadValue);
-    return bytesWritten;
-}
-
-static jint Inflater_getAdlerImpl(JNIEnv*, jobject, jlong handle) {
-    return toNativeZipStream(handle)->stream.adler;
-}
-
-static void Inflater_endImpl(JNIEnv*, jobject, jlong handle) {
-    NativeZipStream* stream = toNativeZipStream(handle);
-    inflateEnd(&stream->stream);
-    delete stream;
-}
-
-static void Inflater_setDictionaryImpl(JNIEnv* env, jobject, jbyteArray dict, int off, int len, jlong handle) {
-    toNativeZipStream(handle)->setDictionary(env, dict, off, len, true);
-}
-
-static void Inflater_resetImpl(JNIEnv* env, jobject, jlong handle) {
-    NativeZipStream* stream = toNativeZipStream(handle);
-    stream->totalIn = 0;
-    stream->totalOut = 0;
-    int err = inflateReset(&stream->stream);
-    if (err != Z_OK) {
-        throwExceptionForZlibError(env, "java/lang/IllegalArgumentException", err, stream);
-    }
-}
-
-static jlong Inflater_getTotalOutImpl(JNIEnv*, jobject, jlong handle) {
-    return toNativeZipStream(handle)->totalOut;
-}
-
-static jlong Inflater_getTotalInImpl(JNIEnv*, jobject, jlong handle) {
-    return toNativeZipStream(handle)->totalIn;
-}
-
-static JNINativeMethod gMethods[] = {
-    NATIVE_METHOD(Inflater, createStream, "(Z)J"),
-    NATIVE_METHOD(Inflater, endImpl, "(J)V"),
-    NATIVE_METHOD(Inflater, getAdlerImpl, "(J)I"),
-    NATIVE_METHOD(Inflater, getTotalInImpl, "(J)J"),
-    NATIVE_METHOD(Inflater, getTotalOutImpl, "(J)J"),
-    NATIVE_METHOD(Inflater, inflateImpl, "([BIIJ)I"),
-    NATIVE_METHOD(Inflater, resetImpl, "(J)V"),
-    NATIVE_METHOD(Inflater, setDictionaryImpl, "([BIIJ)V"),
-    NATIVE_METHOD(Inflater, setFileInputImpl, "(Ljava/io/FileDescriptor;JIJ)I"),
-    NATIVE_METHOD(Inflater, setInputImpl, "([BIIJ)V"),
-};
-void register_java_util_zip_Inflater(JNIEnv* env) {
-    jniRegisterNativeMethods(env, "java/util/zip/Inflater", gMethods, NELEM(gMethods));
-}
diff --git a/luni/src/main/native/sub.mk b/luni/src/main/native/sub.mk
index 72a0da7..f3ea56e 100644
--- a/luni/src/main/native/sub.mk
+++ b/luni/src/main/native/sub.mk
@@ -4,7 +4,6 @@
 # or BUILD_*_LIBRARY.
 
 LOCAL_SRC_FILES := \
-    AsynchronousCloseMonitor.cpp \
     ExecStrings.cpp \
     IcuUtilities.cpp \
     JniException.cpp \
diff --git a/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java b/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
index ec8ddb4..5f440a4 100644
--- a/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
+++ b/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
@@ -111,11 +111,8 @@
     // http://b/18785260
     public void testMultiCharMinusSignAndPercentage() {
         DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.forLanguageTag("ar-AR"));
-        // TODO(narayan): Investigate.
-        // assertTrue(dfs.getMinusSign().length() > 1);
-        // assertTrue(dfs.getPercent().length() > 1);
 
-        assertEquals('%', dfs.getPercent());
+        assertEquals('٪', dfs.getPercent());
         assertEquals('-', dfs.getMinusSign());
     }
 
diff --git a/ojluni/src/main/java/java/lang/Class.java b/ojluni/src/main/java/java/lang/Class.java
index f0b14ba..dd97313 100755
--- a/ojluni/src/main/java/java/lang/Class.java
+++ b/ojluni/src/main/java/java/lang/Class.java
@@ -183,9 +183,6 @@
     /** access flags; low 16 bits are defined by VM spec */
     private transient int accessFlags;
 
-    /** static, private, and &lt;init&gt; methods. */
-    private transient long directMethods;
-
     /**
      * Instance fields. These describe the layout of the contents of an Object. Note that only the
      * fields directly declared by this class are listed in iFields; fields declared by a
@@ -196,12 +193,12 @@
      */
     private transient long iFields;
 
+    /** All methods with this class as the base for virtual dispatch. */
+    private transient long methods;
+
     /** Static fields */
     private transient long sFields;
 
-    /** Virtual methods defined in this class; invoked through vtable. */
-    private transient long virtualMethods;
-
     /** Class flags to help the GC with object scanning. */
     private transient int classFlags;
 
@@ -254,6 +251,12 @@
     /** State of class initialization */
     private transient int status;
 
+    /** Offset of the first virtual method copied from an interface in the methods array. */
+    private transient short copiedMethodsOffset;
+
+    /** Offset of the first virtual method defined in this class in the methods array. */
+    private transient short virtualMethodsOffset;
+
     private AnnotationType annotationType;
 
     private static final int ANNOTATION  = 0x00002000;
diff --git a/ojluni/src/main/java/java/text/DecimalFormat.java b/ojluni/src/main/java/java/text/DecimalFormat.java
index 15081c4..b47dca0 100755
--- a/ojluni/src/main/java/java/text/DecimalFormat.java
+++ b/ojluni/src/main/java/java/text/DecimalFormat.java
@@ -796,6 +796,11 @@
      *             <code>pos</code> is null.
      */
     public Number parse(String text, ParsePosition pos) {
+        // Return early if the parse position is bogus.
+        if (pos.index < 0 || pos.index >= text.length()) {
+            return null;
+        }
+
         // This might return android.icu.math.BigDecimal, java.math.BigInteger or a primitive type.
         Number number = icuDecimalFormat.parse(text, pos);
         if (number == null) {
diff --git a/ojluni/src/main/java/java/text/DecimalFormatSymbols.java b/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
index 4082073..495fe60 100755
--- a/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/ojluni/src/main/java/java/text/DecimalFormatSymbols.java
@@ -44,7 +44,6 @@
 import java.text.spi.DecimalFormatSymbolsProvider;
 import java.util.Currency;
 import java.util.Locale;
-import java.util.ResourceBundle;
 import java.util.concurrent.ConcurrentHashMap;
 import libcore.icu.LocaleData;
 
@@ -565,15 +564,15 @@
             LocaleData localeData = LocaleData.get(locale);
             data = new Object[3];
             String[] values = new String[11];
-            values[0] = localeData.decimalSeparator + "";
-            values[1] = localeData.groupingSeparator + "";
-            values[2] = localeData.patternSeparator + "";
-            values[3] = localeData.percent + "";
-            values[4] = localeData.zeroDigit + "";
+            values[0] = String.valueOf(localeData.decimalSeparator);
+            values[1] = String.valueOf(localeData.groupingSeparator);
+            values[2] = String.valueOf(localeData.patternSeparator);
+            values[3] = String.valueOf(localeData.percent);
+            values[4] = String.valueOf(localeData.zeroDigit);
             values[5] = "#";
             values[6] = localeData.minusSign;
             values[7] = localeData.exponentSeparator;
-            values[8] = localeData.perMill + "";
+            values[8] = String.valueOf(localeData.perMill);
             values[9] = localeData.infinity;
             values[10] = localeData.NaN;
             data[0] = values;
@@ -585,10 +584,10 @@
         decimalSeparator = numberElements[0].charAt(0);
         groupingSeparator = numberElements[1].charAt(0);
         patternSeparator = numberElements[2].charAt(0);
-        percent = numberElements[3].charAt(0);
+        percent = maybeStripMarkers(numberElements[3], '%');
         zeroDigit = numberElements[4].charAt(0); //different for Arabic,etc.
         digit = numberElements[5].charAt(0);
-        minusSign = numberElements[6].charAt(0);
+        minusSign = maybeStripMarkers(numberElements[6], '-');
         exponential = numberElements[7].charAt(0);
         exponentialSeparator = numberElements[7]; //string representation new since 1.6
         perMill = numberElements[8].charAt(0);
@@ -636,6 +635,28 @@
     }
 
     /**
+     * Attempts to strip RTL, LTR and Arabic letter markers from {@code symbol}. If the symbol's
+     * length is 1, then the first char of the symbol is returned. If the symbol's length is 2 and
+     * the first char is a marker, then the second char is returned. In all other cases,
+     * {@code fallback} is returned.
+     */
+    private static char maybeStripMarkers(String symbol, char fallback) {
+        final int length = symbol.length();
+        if (length == 1) {
+            return symbol.charAt(0);
+        }
+
+        if (length == 2) {
+            char first = symbol.charAt(0);
+            if (first =='\u200E' || first =='\u200F' || first =='\u061C'); {
+                return symbol.charAt(1);
+            }
+        }
+
+        return fallback;
+    }
+
+    /**
      * Convert an instance of this class to the ICU version so that it can be used with ICU4J.
      * @hide
      */
diff --git a/ojluni/src/main/java/sun/nio/ch/SourceChannelImpl.java b/ojluni/src/main/java/sun/nio/ch/SourceChannelImpl.java
index 284f126..99b9dda 100755
--- a/ojluni/src/main/java/sun/nio/ch/SourceChannelImpl.java
+++ b/ojluni/src/main/java/sun/nio/ch/SourceChannelImpl.java
@@ -156,12 +156,10 @@
     }
 
     public int read(ByteBuffer dst) throws IOException {
-        ensureOpen();
-        // ----- BEGIN android -----
         if (dst == null) {
-          throw new NullPointerException();
+            throw new NullPointerException();
         }
-        // ----- END android -----
+        ensureOpen();
         synchronized (lock) {
             int n = 0;
             try {
diff --git a/ojluni/src/main/native/linux_close.c b/ojluni/src/main/native/linux_close.c
deleted file mode 100755
index 5665e85..0000000
--- a/ojluni/src/main/native/linux_close.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <sys/poll.h>
-
-/*
- * Stack allocated by thread when doing blocking operation
- */
-typedef struct threadEntry {
-    pthread_t thr;                      /* this thread */
-    struct threadEntry *next;           /* next thread */
-    int intr;                           /* interrupted */
-} threadEntry_t;
-
-/*
- * Heap allocated during initialized - one entry per fd
- */
-typedef struct {
-    pthread_mutex_t lock;               /* fd lock */
-    threadEntry_t *threads;             /* threads blocked on fd */
-} fdEntry_t;
-
-/*
- * Signal to unblock thread
- */
-static int sigWakeup = (__SIGRTMAX - 2);
-
-/*
- * The fd table and the number of file descriptors
- */
-static fdEntry_t *fdTable;
-static int fdCount;
-
-/*
- * Null signal handler
- */
-static void sig_wakeup(int sig) {
-}
-
-/*
- * Initialization routine (executed when library is loaded)
- * Allocate fd tables and sets up signal handler.
- */
-static void __attribute((constructor)) init() {
-    struct rlimit nbr_files;
-    sigset_t sigset;
-    struct sigaction sa;
-
-    /*
-     * Allocate table based on the maximum number of
-     * file descriptors.
-     */
-    getrlimit(RLIMIT_NOFILE, &nbr_files);
-    fdCount = nbr_files.rlim_max;
-    fdTable = (fdEntry_t *)calloc(fdCount, sizeof(fdEntry_t));
-    if (fdTable == NULL) {
-        fprintf(stderr, "library initialization failed - "
-                "unable to allocate file descriptor table - out of memory");
-        abort();
-    }
-
-    /*
-     * Setup the signal handler
-     */
-    sa.sa_handler = sig_wakeup;
-    sa.sa_flags   = 0;
-    sigemptyset(&sa.sa_mask);
-    sigaction(sigWakeup, &sa, NULL);
-
-    sigemptyset(&sigset);
-    sigaddset(&sigset, sigWakeup);
-    sigprocmask(SIG_UNBLOCK, &sigset, NULL);
-}
-
-/*
- * Return the fd table for this fd or NULL is fd out
- * of range.
- */
-static inline fdEntry_t *getFdEntry(int fd)
-{
-    if (fd < 0 || fd >= fdCount) {
-        return NULL;
-    }
-    return &fdTable[fd];
-}
-
-/*
- * Start a blocking operation :-
- *    Insert thread onto thread list for the fd.
- */
-static inline void startOp(fdEntry_t *fdEntry, threadEntry_t *self)
-{
-    self->thr = pthread_self();
-    self->intr = 0;
-
-    pthread_mutex_lock(&(fdEntry->lock));
-    {
-        self->next = fdEntry->threads;
-        fdEntry->threads = self;
-    }
-    pthread_mutex_unlock(&(fdEntry->lock));
-}
-
-/*
- * End a blocking operation :-
- *     Remove thread from thread list for the fd
- *     If fd has been interrupted then set errno to EBADF
- */
-static inline void endOp
-    (fdEntry_t *fdEntry, threadEntry_t *self)
-{
-    int orig_errno = errno;
-    pthread_mutex_lock(&(fdEntry->lock));
-    {
-        threadEntry_t *curr, *prev=NULL;
-        curr = fdEntry->threads;
-        while (curr != NULL) {
-            if (curr == self) {
-                if (curr->intr) {
-                    orig_errno = EBADF;
-                }
-                if (prev == NULL) {
-                    fdEntry->threads = curr->next;
-                } else {
-                    prev->next = curr->next;
-                }
-                break;
-            }
-            prev = curr;
-            curr = curr->next;
-        }
-    }
-    pthread_mutex_unlock(&(fdEntry->lock));
-    errno = orig_errno;
-}
-
-/*
- * Close or dup2 a file descriptor ensuring that all threads blocked on
- * the file descriptor are notified via a wakeup signal.
- *
- *      fd1 < 0    => close(fd2)
- *      fd1 >= 0   => dup2(fd1, fd2)
- *
- * Returns -1 with errno set if operation fails.
- */
-static int closefd(int fd1, int fd2) {
-    int rv, orig_errno;
-    fdEntry_t *fdEntry = getFdEntry(fd2);
-    if (fdEntry == NULL) {
-        errno = EBADF;
-        return -1;
-    }
-
-    /*
-     * Lock the fd to hold-off additional I/O on this fd.
-     */
-    pthread_mutex_lock(&(fdEntry->lock));
-
-    {
-        /*
-         * Send a wakeup signal to all threads blocked on this
-         * file descriptor.
-         */
-        threadEntry_t *curr = fdEntry->threads;
-        while (curr != NULL) {
-            curr->intr = 1;
-            pthread_kill( curr->thr, sigWakeup );
-            curr = curr->next;
-        }
-
-        /*
-         * And close/dup the file descriptor
-         * (restart if interrupted by signal)
-         */
-        do {
-            if (fd1 < 0) {
-                rv = close(fd2);
-            } else {
-                rv = dup2(fd1, fd2);
-            }
-        } while (rv == -1 && errno == EINTR);
-
-    }
-
-    /*
-     * Unlock without destroying errno
-     */
-    orig_errno = errno;
-    pthread_mutex_unlock(&(fdEntry->lock));
-    errno = orig_errno;
-
-    return rv;
-}
-
-/*
- * Wrapper for dup2 - same semantics as dup2 system call except
- * that any threads blocked in an I/O system call on fd2 will be
- * preempted and return -1/EBADF;
- */
-int NET_Dup2(int fd, int fd2) {
-    if (fd < 0) {
-        errno = EBADF;
-        return -1;
-    }
-    return closefd(fd, fd2);
-}
-
-/*
- * Wrapper for close - same semantics as close system call
- * except that any threads blocked in an I/O on fd will be
- * preempted and the I/O system call will return -1/EBADF.
- */
-int NET_SocketClose(int fd) {
-    return closefd(-1, fd);
-}
-
-/************** Basic I/O operations here ***************/
-
-/*
- * Macro to perform a blocking IO operation. Restarts
- * automatically if interrupted by signal (other than
- * our wakeup signal)
- */
-#define BLOCKING_IO_RETURN_INT(FD, FUNC) {      \
-    int ret;                                    \
-    threadEntry_t self;                         \
-    fdEntry_t *fdEntry = getFdEntry(FD);        \
-    if (fdEntry == NULL) {                      \
-        errno = EBADF;                          \
-        return -1;                              \
-    }                                           \
-    do {                                        \
-        startOp(fdEntry, &self);                \
-        ret = FUNC;                             \
-        endOp(fdEntry, &self);                  \
-    } while (ret == -1 && errno == EINTR);      \
-    return ret;                                 \
-}
-
-int NET_Read(int s, void* buf, size_t len) {
-    BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
-}
-
-int NET_ReadV(int s, const struct iovec * vector, int count) {
-    BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
-}
-
-int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
-       struct sockaddr *from, int *fromlen) {
-    socklen_t socklen = *fromlen;
-    BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, &socklen) );
-    *fromlen = socklen;
-}
-
-int NET_Send(int s, void *msg, int len, unsigned int flags) {
-    BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) );
-}
-
-int NET_WriteV(int s, const struct iovec * vector, int count) {
-    BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) );
-}
-
-int NET_SendTo(int s, const void *msg, int len,  unsigned  int
-       flags, const struct sockaddr *to, int tolen) {
-    BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
-}
-
-int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
-    socklen_t socklen = *addrlen;
-    BLOCKING_IO_RETURN_INT( s, accept(s, addr, &socklen) );
-    *addrlen = socklen;
-}
-
-int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
-    BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
-}
-
-#ifndef USE_SELECT
-int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
-    BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
-}
-#else
-int NET_Select(int s, fd_set *readfds, fd_set *writefds,
-               fd_set *exceptfds, struct timeval *timeout) {
-    BLOCKING_IO_RETURN_INT( s-1,
-                            select(s, readfds, writefds, exceptfds, timeout) );
-}
-#endif
-
-/*
- * Wrapper for poll(s, timeout).
- * Auto restarts with adjusted timeout if interrupted by
- * signal other than our wakeup signal.
- */
-int NET_Timeout(int s, long timeout) {
-    long prevtime = 0, newtime;
-    struct timeval t;
-    fdEntry_t *fdEntry = getFdEntry(s);
-
-    /*
-     * Check that fd hasn't been closed.
-     */
-    if (fdEntry == NULL) {
-        errno = EBADF;
-        return -1;
-    }
-
-    /*
-     * Pick up current time as may need to adjust timeout
-     */
-    if (timeout > 0) {
-        gettimeofday(&t, NULL);
-        prevtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
-    }
-
-    for(;;) {
-        struct pollfd pfd;
-        int rv;
-        threadEntry_t self;
-
-        /*
-         * Poll the fd. If interrupted by our wakeup signal
-         * errno will be set to EBADF.
-         */
-        pfd.fd = s;
-        pfd.events = POLLIN | POLLERR;
-
-        startOp(fdEntry, &self);
-        rv = poll(&pfd, 1, timeout);
-        endOp(fdEntry, &self);
-
-        /*
-         * If interrupted then adjust timeout. If timeout
-         * has expired return 0 (indicating timeout expired).
-         */
-        if (rv < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                gettimeofday(&t, NULL);
-                newtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0) {
-                    return 0;
-                }
-                prevtime = newtime;
-            }
-        } else {
-            return rv;
-        }
-
-    }
-}
diff --git a/ojluni/src/main/native/linux_close.cpp b/ojluni/src/main/native/linux_close.cpp
new file mode 100755
index 0000000..974b9b2
--- /dev/null
+++ b/ojluni/src/main/native/linux_close.cpp
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2001, 2011, 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <sys/poll.h>
+
+
+#include "AsynchronousCloseMonitor.h"
+
+extern "C" {
+
+/*
+ * Signal to unblock thread
+ */
+static int sigWakeup = (__SIGRTMAX - 2);
+
+/*
+ * Close or dup2 a file descriptor ensuring that all threads blocked on
+ * the file descriptor are notified via a wakeup signal.
+ *
+ *      fd1 < 0    => close(fd2)
+ *      fd1 >= 0   => dup2(fd1, fd2)
+ *
+ * Returns -1 with errno set if operation fails.
+ */
+static int closefd(int fd1, int fd2) {
+    int rv, orig_errno;
+
+    AsynchronousCloseMonitor::signalBlockedThreads(fd2);
+
+    /*
+     * And close/dup the file descriptor
+     * (restart if interrupted by signal)
+     */
+    do {
+      if (fd1 < 0) {
+        rv = close(fd2);
+      } else {
+        rv = dup2(fd1, fd2);
+      }
+    } while (rv == -1 && errno == EINTR);
+    return rv;
+}
+
+/*
+ * Wrapper for dup2 - same semantics as dup2 system call except
+ * that any threads blocked in an I/O system call on fd2 will be
+ * preempted and return -1/EBADF;
+ */
+int NET_Dup2(int fd, int fd2) {
+    if (fd < 0) {
+        errno = EBADF;
+        return -1;
+    }
+    return closefd(fd, fd2);
+}
+
+/*
+ * Wrapper for close - same semantics as close system call
+ * except that any threads blocked in an I/O on fd will be
+ * preempted and the I/O system call will return -1/EBADF.
+ */
+int NET_SocketClose(int fd) {
+    return closefd(-1, fd);
+}
+
+/************** Basic I/O operations here ***************/
+
+/*
+ * Macro to perform a blocking IO operation. Restarts
+ * automatically if interrupted by signal (other than
+ * our wakeup signal)
+ */
+#define BLOCKING_IO_RETURN_INT(FD, FUNC) {      \
+    int ret;                                    \
+    int _syscallErrno; \
+    do {                                        \
+        bool _wasSignaled; \
+        {                                       \
+            AsynchronousCloseMonitor _monitor(FD); \
+            ret = FUNC;                            \
+            _syscallErrno = errno; \
+            _wasSignaled = _monitor.wasSignaled(); \
+        } \
+        errno = _wasSignaled ? EBADF : _syscallErrno; \
+    } while (ret == -1 && errno == EINTR);      \
+    return ret;                                 \
+}
+
+
+int NET_Read(int s, void* buf, size_t len) {
+    BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
+}
+
+int NET_ReadV(int s, const struct iovec * vector, int count) {
+    BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
+}
+
+int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
+       struct sockaddr *from, int *fromlen) {
+    socklen_t socklen = *fromlen;
+    BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, &socklen) );
+    *fromlen = socklen;
+}
+
+int NET_Send(int s, void *msg, int len, unsigned int flags) {
+    BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) );
+}
+
+int NET_WriteV(int s, const struct iovec * vector, int count) {
+    BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) );
+}
+
+int NET_SendTo(int s, const void *msg, int len,  unsigned  int
+       flags, const struct sockaddr *to, int tolen) {
+    BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
+}
+
+int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
+    socklen_t socklen = *addrlen;
+    BLOCKING_IO_RETURN_INT( s, accept(s, addr, &socklen) );
+    *addrlen = socklen;
+}
+
+int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
+    BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
+}
+
+#ifndef USE_SELECT
+int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
+    BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
+}
+#else
+int NET_Select(int s, fd_set *readfds, fd_set *writefds,
+               fd_set *exceptfds, struct timeval *timeout) {
+    BLOCKING_IO_RETURN_INT( s-1,
+                            select(s, readfds, writefds, exceptfds, timeout) );
+}
+#endif
+
+/*
+ * Wrapper for poll(s, timeout).
+ * Auto restarts with adjusted timeout if interrupted by
+ * signal other than our wakeup signal.
+ */
+int NET_Timeout(int s, long timeout) {
+    long prevtime = 0, newtime;
+    struct timeval t;
+
+    /*
+     * Pick up current time as may need to adjust timeout
+     */
+    if (timeout > 0) {
+        gettimeofday(&t, NULL);
+        prevtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
+    }
+
+    for(;;) {
+        struct pollfd pfd;
+        int rv;
+
+        /*
+         * Poll the fd. If interrupted by our wakeup signal
+         * errno will be set to EBADF.
+         */
+        pfd.fd = s;
+        pfd.events = POLLIN | POLLERR;
+
+        bool wasSignaled;
+        int syscallErrno;
+        {
+          AsynchronousCloseMonitor monitor(s);
+          rv = poll(&pfd, 1, timeout);
+          syscallErrno = errno;
+          wasSignaled = monitor.wasSignaled();
+        }
+        errno = wasSignaled ? EBADF : syscallErrno;
+
+        /*
+         * If interrupted then adjust timeout. If timeout
+         * has expired return 0 (indicating timeout expired).
+         */
+        if (rv < 0 && errno == EINTR) {
+            if (timeout > 0) {
+                gettimeofday(&t, NULL);
+                newtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
+                timeout -= newtime - prevtime;
+                if (timeout <= 0) {
+                    return 0;
+                }
+                prevtime = newtime;
+            }
+        } else {
+            return rv;
+        }
+
+    }
+}
+
+}
diff --git a/ojluni/src/main/native/openjdksub.mk b/ojluni/src/main/native/openjdksub.mk
index f57fc6c..6ec6be1 100644
--- a/ojluni/src/main/native/openjdksub.mk
+++ b/ojluni/src/main/native/openjdksub.mk
@@ -43,7 +43,7 @@
     MappedByteBuffer.c \
     Inet6Address.c \
     Inet4Address.c \
-    linux_close.c \
+    linux_close.cpp \
     PlainSocketImpl.c \
     PlainDatagramSocketImpl.c \
     NetworkInterface.c \