Merge "OpenJDK 11: Merging in java.lang.*"
diff --git a/JavaLibrary.bp b/JavaLibrary.bp
index 087f7ce..e9f4ce8 100644
--- a/JavaLibrary.bp
+++ b/JavaLibrary.bp
@@ -103,7 +103,7 @@
     output_extension: "java",
 }
 
-// The source files that go into core-libart.
+// The source files that go into core-libart.l
 filegroup {
     name: "core_libart_java_files",
     visibility: [
@@ -684,6 +684,7 @@
         "luni/src/test/java/libcore/javax/crypto/**/*.java",
         "luni/src/test/java/libcore/javax/net/ssl/**/*.java",
         "luni/src/test/java/libcore/libcore/util/SerializationTester.java",
+        "luni/src/test/java/libcore/sun/security/**/*.java",
         "luni/src/test/java/org/apache/harmony/crypto/**/*.java",
     ],
 
diff --git a/luni/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java b/luni/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java
index a1982a1..ba3c72a 100644
--- a/luni/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java
+++ b/luni/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java
@@ -307,21 +307,10 @@
      * </p>
      *
      * <p>
-     * All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
-     * When the feature is:</p>
-     * <ul>
-     *   <li>
-     *     <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
-     *     Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.
-     *     If XML processing is limited for security reasons, it will be reported via a call to the registered
-     *    {@link org.xml.sax.ErrorHandler#fatalError(SAXParseException exception)}.
-     *     See {@link  DocumentBuilder#setErrorHandler(org.xml.sax.ErrorHandler errorHandler)}.
-     *   </li>
-     *   <li>
-     *     <code>false</code>: the implementation will processing XML according to the XML specifications without
-     *     regard to possible implementation limits.
-     *   </li>
-     * </ul>
+     * Earlier versions of this documentation have mandated support for the
+     * {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature, but this is not a
+     * supported feature on any version of Android.
+     * </p>
      *
      * @param name Feature name.
      * @param value Is feature state <code>true</code> or <code>false</code>.
diff --git a/luni/src/main/native/JniConstants.cpp b/luni/src/main/native/JniConstants.cpp
index 5127fa1..0992e55 100755
--- a/luni/src/main/native/JniConstants.cpp
+++ b/luni/src/main/native/JniConstants.cpp
@@ -43,98 +43,72 @@
 // Flag indicating whether cached constants are valid
 static bool g_constants_valid = false;
 
-// Constants
-jclass booleanClass;
-jclass byteBufferClass;
-jclass doubleClass;
-jclass errnoExceptionClass;
-jclass fileDescriptorClass;
-jclass gaiExceptionClass;
-jclass inet6AddressClass;
-jclass inet6AddressHolderClass;
-jclass inetAddressClass;
-jclass inetAddressHolderClass;
-jclass inetSocketAddressClass;
-jclass inetSocketAddressHolderClass;
-jclass integerClass;
-jclass localeDataClass;
-jclass longClass;
-jclass netlinkSocketAddressClass;
-jclass packetSocketAddressClass;
-jclass vmSocketAddressClass;
-jclass primitiveByteArrayClass;
-jclass stringClass;
-jclass structAddrinfoClass;
-jclass structCmsghdrClass;
-jclass structGroupReqClass;
-jclass structIfaddrsClass;
-jclass structLingerClass;
-jclass structMsghdrClass;
-jclass structPasswdClass;
-jclass structPollfdClass;
-jclass structStatClass;
-jclass structStatVfsClass;
-jclass structTimespecClass;
-jclass structTimevalClass;
-jclass structUcredClass;
-jclass structUtsnameClass;
-jclass unixSocketAddressClass;
+// Mapping between C++ names and java class descriptors.
+#define JCLASS_CONSTANTS_LIST(V)                                                            \
+    V(BooleanClass, "java/lang/Boolean")                                                    \
+    V(ByteBufferClass, "java/nio/ByteBuffer")                                               \
+    V(DoubleClass, "java/lang/Double")                                                      \
+    V(ErrnoExceptionClass, "android/system/ErrnoException")                                 \
+    V(FileDescriptorClass, "java/io/FileDescriptor")                                        \
+    V(GaiExceptionClass, "android/system/GaiException")                                     \
+    V(Inet6AddressClass, "java/net/Inet6Address")                                           \
+    V(Inet6AddressHolderClass, "java/net/Inet6Address$Inet6AddressHolder")                  \
+    V(InetAddressClass, "java/net/InetAddress")                                             \
+    V(InetAddressHolderClass, "java/net/InetAddress$InetAddressHolder")                     \
+    V(InetSocketAddressClass, "java/net/InetSocketAddress")                                 \
+    V(InetSocketAddressHolderClass, "java/net/InetSocketAddress$InetSocketAddressHolder")   \
+    V(IntegerClass, "java/lang/Integer")                                                    \
+    V(LocaleDataClass, "libcore/icu/LocaleData")                                            \
+    V(LongClass, "java/lang/Long")                                                          \
+    V(NetlinkSocketAddressClass, "android/system/NetlinkSocketAddress")                     \
+    V(PacketSocketAddressClass, "android/system/PacketSocketAddress")                       \
+    V(VmSocketAddressClass, "android/system/VmSocketAddress")                               \
+    V(PrimitiveByteArrayClass, "[B")                                                        \
+    V(StringClass, "java/lang/String")                                                      \
+    V(StructAddrinfoClass, "android/system/StructAddrinfo")                                 \
+    V(StructCmsghdrClass, "android/system/StructCmsghdr")                                   \
+    V(StructGroupReqClass, "android/system/StructGroupReq")                                 \
+    V(StructIfaddrsClass, "android/system/StructIfaddrs")                                   \
+    V(StructLingerClass, "android/system/StructLinger")                                     \
+    V(StructMsghdrClass, "android/system/StructMsghdr")                                     \
+    V(StructPasswdClass, "android/system/StructPasswd")                                     \
+    V(StructPollfdClass, "android/system/StructPollfd")                                     \
+    V(StructStatClass, "android/system/StructStat")                                         \
+    V(StructStatVfsClass, "android/system/StructStatVfs")                                   \
+    V(StructTimevalClass, "android/system/StructTimeval")                                   \
+    V(StructTimespecClass, "android/system/StructTimespec")                                 \
+    V(StructUcredClass, "android/system/StructUcred")                                       \
+    V(StructUtsnameClass, "android/system/StructUtsname")                                   \
+    V(UnixSocketAddressClass, "android/system/UnixSocketAddress")
+
+#define DECLARE_JCLASS_CONSTANT(cppname, _) jclass g_ ## cppname;
+JCLASS_CONSTANTS_LIST(DECLARE_JCLASS_CONSTANT)
 
 // EnsureJniConstantsInitialized initializes cached constants. It should be
 // called before returning a heap object from the cache to ensure cache is
 // initialized. This pattern is only necessary because if a process finishes one
 // runtime and starts another then JNI_OnLoad may not be called.
 void EnsureJniConstantsInitialized(JNIEnv* env) {
-    if (g_constants_valid) {
-        return;
-    }
-
     std::lock_guard guard(g_constants_mutex);
     if (g_constants_valid) {
         return;
     }
 
-    booleanClass = findClass(env, "java/lang/Boolean");
-    byteBufferClass = findClass(env, "java/nio/ByteBuffer");
-    doubleClass = findClass(env, "java/lang/Double");
-    errnoExceptionClass = findClass(env, "android/system/ErrnoException");
-    fileDescriptorClass = findClass(env, "java/io/FileDescriptor");
-    gaiExceptionClass = findClass(env, "android/system/GaiException");
-    inet6AddressClass = findClass(env, "java/net/Inet6Address");
-    inet6AddressHolderClass = findClass(env, "java/net/Inet6Address$Inet6AddressHolder");
-    inetAddressClass = findClass(env, "java/net/InetAddress");
-    inetAddressHolderClass = findClass(env, "java/net/InetAddress$InetAddressHolder");
-    inetSocketAddressClass = findClass(env, "java/net/InetSocketAddress");
-    inetSocketAddressHolderClass = findClass(env, "java/net/InetSocketAddress$InetSocketAddressHolder");
-    integerClass = findClass(env, "java/lang/Integer");
-    localeDataClass = findClass(env, "libcore/icu/LocaleData");
-    longClass = findClass(env, "java/lang/Long");
-    netlinkSocketAddressClass = findClass(env, "android/system/NetlinkSocketAddress");
-    packetSocketAddressClass = findClass(env, "android/system/PacketSocketAddress");
-    vmSocketAddressClass = findClass(env, "android/system/VmSocketAddress");
-    primitiveByteArrayClass = findClass(env, "[B");
-    stringClass = findClass(env, "java/lang/String");
-    structAddrinfoClass = findClass(env, "android/system/StructAddrinfo");
-    structCmsghdrClass = findClass(env, "android/system/StructCmsghdr");
-    structGroupReqClass = findClass(env, "android/system/StructGroupReq");
-    structIfaddrsClass = findClass(env, "android/system/StructIfaddrs");
-    structLingerClass = findClass(env, "android/system/StructLinger");
-    structMsghdrClass = findClass(env, "android/system/StructMsghdr");
-    structPasswdClass = findClass(env, "android/system/StructPasswd");
-    structPollfdClass = findClass(env, "android/system/StructPollfd");
-    structStatClass = findClass(env, "android/system/StructStat");
-    structStatVfsClass = findClass(env, "android/system/StructStatVfs");
-    structTimevalClass = findClass(env, "android/system/StructTimeval");
-    structTimespecClass = findClass(env, "android/system/StructTimespec");
-    structUcredClass = findClass(env, "android/system/StructUcred");
-    structUtsnameClass = findClass(env, "android/system/StructUtsname");
-    unixSocketAddressClass = findClass(env, "android/system/UnixSocketAddress");
+#define INITIALIZE_JCLASS_CONSTANT(cppname, javaname) g_ ## cppname = findClass(env, javaname);
+JCLASS_CONSTANTS_LIST(INITIALIZE_JCLASS_CONSTANT)
 
     g_constants_valid = true;
 }
 
 }  // namespace
 
+#define CONSTANT_GETTER(cppname, _)                                                         \
+jclass JniConstants::Get ## cppname(JNIEnv* env) {                                          \
+    EnsureJniConstantsInitialized(env);                                                     \
+    return g_ ## cppname;                                                                   \
+}
+JCLASS_CONSTANTS_LIST(CONSTANT_GETTER)
+
 void JniConstants::Initialize(JNIEnv* env) {
     EnsureJniConstantsInitialized(env);
 }
@@ -152,178 +126,3 @@
     std::lock_guard guard(g_constants_mutex);
     g_constants_valid = false;
 }
-
-jclass JniConstants::GetBooleanClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return booleanClass;
-}
-
-jclass JniConstants::GetByteBufferClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return byteBufferClass;
-}
-
-jclass JniConstants::GetDoubleClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return doubleClass;
-}
-
-jclass JniConstants::GetErrnoExceptionClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return errnoExceptionClass;
-}
-
-jclass JniConstants::GetFileDescriptorClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return fileDescriptorClass;
-}
-
-jclass JniConstants::GetGaiExceptionClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return gaiExceptionClass;
-}
-
-jclass JniConstants::GetInet6AddressClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return inet6AddressClass;
-}
-
-jclass JniConstants::GetInet6AddressHolderClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return inet6AddressHolderClass;
-}
-
-jclass JniConstants::GetInetAddressClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return inetAddressClass;
-}
-
-jclass JniConstants::GetInetAddressHolderClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return inetAddressHolderClass;
-}
-
-jclass JniConstants::GetInetSocketAddressClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return inetSocketAddressClass;
-}
-
-jclass JniConstants::GetInetSocketAddressHolderClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return inetSocketAddressHolderClass;
-}
-
-jclass JniConstants::GetIntegerClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return integerClass;
-}
-
-jclass JniConstants::GetLocaleDataClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return localeDataClass;
-}
-
-jclass JniConstants::GetLongClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return longClass;
-}
-
-jclass JniConstants::GetNetlinkSocketAddressClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return netlinkSocketAddressClass;
-}
-
-jclass JniConstants::GetPacketSocketAddressClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return packetSocketAddressClass;
-}
-
-jclass JniConstants::GetVmSocketAddressClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return vmSocketAddressClass;
-}
-
-jclass JniConstants::GetPrimitiveByteArrayClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return primitiveByteArrayClass;
-}
-
-jclass JniConstants::GetStringClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return stringClass;
-}
-
-jclass JniConstants::GetStructAddrinfoClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structAddrinfoClass;
-}
-
-jclass JniConstants::GetStructCmsghdrClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structCmsghdrClass;
-}
-
-jclass JniConstants::GetStructGroupReqClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structGroupReqClass;
-}
-
-jclass JniConstants::GetStructIfaddrsClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structIfaddrsClass;
-}
-
-jclass JniConstants::GetStructLingerClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structLingerClass;
-}
-
-jclass JniConstants::GetStructMsghdrClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structMsghdrClass;
-}
-
-jclass JniConstants::GetStructPasswdClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structPasswdClass;
-}
-
-jclass JniConstants::GetStructPollfdClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structPollfdClass;
-}
-
-jclass JniConstants::GetStructStatClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structStatClass;
-}
-
-jclass JniConstants::GetStructStatVfsClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structStatVfsClass;
-}
-
-jclass JniConstants::GetStructTimespecClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structTimespecClass;
-}
-
-jclass JniConstants::GetStructTimevalClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structTimevalClass;
-}
-
-jclass JniConstants::GetStructUcredClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structUcredClass;
-}
-
-jclass JniConstants::GetStructUtsnameClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return structUtsnameClass;
-}
-
-jclass JniConstants::GetUnixSocketAddressClass(JNIEnv* env) {
-    EnsureJniConstantsInitialized(env);
-    return unixSocketAddressClass;
-}
diff --git a/luni/src/main/native/NetworkUtilities.cpp b/luni/src/main/native/NetworkUtilities.cpp
index cd695b7..47ce055 100755
--- a/luni/src/main/native/NetworkUtilities.cpp
+++ b/luni/src/main/native/NetworkUtilities.cpp
@@ -26,6 +26,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
+#include <android-base/logging.h>
 #include <nativehelper/JNIHelp.h>
 #include <nativehelper/ScopedLocalRef.h>
 
@@ -79,19 +80,25 @@
     }
 
     ScopedLocalRef<jbyteArray> byteArray(env, env->NewByteArray(addressLength));
-    if (byteArray.get() == NULL) {
-        return NULL;
+    if (byteArray == nullptr) {
+        // NewByteArray aborts if the addressLength is negative, so the allocation must have failed.
+        DCHECK(env->ExceptionCheck());
+        return nullptr;
     }
+
     env->SetByteArrayRegion(byteArray.get(), 0, addressLength,
             reinterpret_cast<const jbyte*>(rawAddress));
 
-    static jmethodID getByAddressMethod = env->GetStaticMethodID(JniConstants::GetInetAddressClass(env),
-            "getByAddress", "(Ljava/lang/String;[BI)Ljava/net/InetAddress;");
-    if (getByAddressMethod == NULL) {
-        return NULL;
-    }
-    return env->CallStaticObjectMethod(JniConstants::GetInetAddressClass(env), getByAddressMethod,
-            NULL, byteArray.get(), scope_id);
+    jclass inetAddressClass = JniConstants::GetInetAddressClass(env);
+    jmethodID getByAddressMethod =
+        env->GetStaticMethodID(inetAddressClass,
+                               "getByAddress",
+                               "(Ljava/lang/String;[BI)Ljava/net/InetAddress;");
+    return env->CallStaticObjectMethod(inetAddressClass,
+                                       getByAddressMethod,
+                                       /*host*/ NULL,
+                                       /*addr*/ byteArray.get(),
+                                       /*scopeId*/ scope_id);
 }
 
 static bool inetAddressToSockaddr(JNIEnv* env, jobject inetAddress, int port, sockaddr_storage& ss, socklen_t& sa_len, bool map) {
diff --git a/luni/src/main/native/libcore_io_Linux.cpp b/luni/src/main/native/libcore_io_Linux.cpp
index a72de9b..e8ed90e 100755
--- a/luni/src/main/native/libcore_io_Linux.cpp
+++ b/luni/src/main/native/libcore_io_Linux.cpp
@@ -1639,11 +1639,9 @@
 }
 
 static jobjectArray Linux_getifaddrs(JNIEnv* env, jobject) {
-    static jmethodID ctor = env->GetMethodID(JniConstants::GetStructIfaddrsClass(env), "<init>",
+    jmethodID ctor = env->GetMethodID(JniConstants::GetStructIfaddrsClass(env), "<init>",
             "(Ljava/lang/String;ILjava/net/InetAddress;Ljava/net/InetAddress;Ljava/net/InetAddress;[B)V");
-    if (ctor == NULL) {
-        return NULL;
-    }
+    CHECK(ctor != NULL);
 
     ifaddrs* ifaddr;
     int rc = TEMP_FAILURE_RETRY(getifaddrs(&ifaddr));
@@ -1660,8 +1658,10 @@
     }
 
     // Prepare output array.
-    jobjectArray result = env->NewObjectArray(ifCount, JniConstants::GetStructIfaddrsClass(env), NULL);
+    jclass ifAddrsClass = JniConstants::GetStructIfaddrsClass(env);
+    jobjectArray result = env->NewObjectArray(ifCount, ifAddrsClass, NULL);
     if (result == NULL) {
+        DCHECK(env->ExceptionCheck());
         return NULL;
     }
 
@@ -1670,12 +1670,9 @@
     for (ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next, ++index) {
         TO_JAVA_STRING(name, ifa->ifa_name);
         jint flags = ifa->ifa_flags;
-        sockaddr_storage* interfaceAddr =
-            reinterpret_cast<sockaddr_storage*>(ifa->ifa_addr);
-        sockaddr_storage* netmaskAddr =
-            reinterpret_cast<sockaddr_storage*>(ifa->ifa_netmask);
-        sockaddr_storage* broadAddr =
-            reinterpret_cast<sockaddr_storage*>(ifa->ifa_broadaddr);
+        sockaddr_storage* interfaceAddr = reinterpret_cast<sockaddr_storage*>(ifa->ifa_addr);
+        sockaddr_storage* netmaskAddr = reinterpret_cast<sockaddr_storage*>(ifa->ifa_netmask);
+        sockaddr_storage* broadAddr = reinterpret_cast<sockaddr_storage*>(ifa->ifa_broadaddr);
 
         jobject addr, netmask, broad;
         jbyteArray hwaddr = NULL;
@@ -1685,14 +1682,18 @@
             case AF_INET6:
                 // IPv4 / IPv6.
                 // interfaceAddr and netmaskAddr are never null.
+                // sockaddrToInetAddress is not expected to return null.
                 if ((addr = sockaddrToInetAddress(env, *interfaceAddr, NULL)) == NULL) {
+                    DCHECK(env->ExceptionCheck());
                     return NULL;
                 }
                 if ((netmask = sockaddrToInetAddress(env, *netmaskAddr, NULL)) == NULL) {
+                    DCHECK(env->ExceptionCheck());
                     return NULL;
                 }
                 if (broadAddr != NULL && (ifa->ifa_flags & IFF_BROADCAST)) {
                     if ((broad = sockaddrToInetAddress(env, *broadAddr, NULL)) == NULL) {
+                        DCHECK(env->ExceptionCheck());
                         return NULL;
                     }
                 } else {
@@ -1714,6 +1715,7 @@
                 if (!allZero) {
                     hwaddr = env->NewByteArray(sll->sll_halen);
                     if (hwaddr == NULL) {
+                        DCHECK(env->ExceptionCheck());
                         return NULL;
                     }
                     env->SetByteArrayRegion(hwaddr, 0, sll->sll_halen,
@@ -1728,9 +1730,9 @@
             addr = netmask = broad = NULL;
         }
 
-        jobject o = env->NewObject(JniConstants::GetStructIfaddrsClass(env), ctor, name, flags,
-                                   addr, netmask, broad, hwaddr);
+        jobject o = env->NewObject(ifAddrsClass, ctor, name, flags, addr, netmask, broad, hwaddr);
         if (o == NULL) {
+            DCHECK(env->ExceptionCheck());
             return NULL;
         }
         env->SetObjectArrayElement(result, index, o);
diff --git a/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java b/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
index 69621cb..0f54b2a 100644
--- a/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
+++ b/luni/src/test/java/libcore/java/net/NetworkInterfaceTest.java
@@ -115,14 +115,6 @@
         }
     }
 
-    @EnableCompatChanges({NetworkInterface.RETURN_NULL_HARDWARE_ADDRESS})
-    public void testGetHardwareAddress_returnsNull() throws Exception {
-        // Hardware addresses should be unavailable to non-system apps.
-        for (NetworkInterface nif : Collections.list(getNetworkInterfaces())) {
-            assertNull(nif.getHardwareAddress());
-        }
-    }
-
     public void testLoopback() throws Exception {
         NetworkInterface lo = NetworkInterface.getByName("lo");
         assertNull(lo.getHardwareAddress());
diff --git a/luni/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java b/luni/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java
index 494ba65..d80965c 100644
--- a/luni/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java
+++ b/luni/src/test/java/org/apache/harmony/security/tests/java/security/KeyStoreSpiTest.java
@@ -220,6 +220,22 @@
         } catch (UnsupportedOperationException expected) {
         }
     }
+
+    public void test_engineProbe() throws IOException {
+        KeyStoreSpi ksSpi = new MyKeyStoreSpi();
+        try {
+            ksSpi.engineProbe(null);
+            fail();
+        } catch (NullPointerException expected) {
+        }
+        InputStream inputStream = new InputStream() {
+            @Override
+            public int read() throws IOException {
+                return 0;
+            }
+        };
+        assertFalse(ksSpi.engineProbe(inputStream));
+    }
 }
 
 // These are "Bad" because they are not expected inner subclasses of the KeyStore class.
diff --git a/ojluni/src/main/java/java/lang/System.java b/ojluni/src/main/java/java/lang/System.java
index 4abba4d..afbee7d 100644
--- a/ojluni/src/main/java/java/lang/System.java
+++ b/ojluni/src/main/java/java/lang/System.java
@@ -971,10 +971,11 @@
         p.put("java.boot.class.path", runtime.bootClassPath());
         p.put("java.class.path", runtime.classPath());
 
-        // TODO: does this make any sense? Should we just leave java.home unset?
-        String javaHome = getenv("JAVA_HOME");
+        // This is probably not useful, but it's documented as being present.
+        // ANDROID_ART_ROOT is defined in `system/core/rootdir/init.environ.rc.in`.
+        String javaHome = getenv("ANDROID_ART_ROOT");
         if (javaHome == null) {
-            javaHome = "/system";
+            javaHome = "/apex/com.android.art";
         }
         p.put("java.home", javaHome);
 
@@ -1006,7 +1007,6 @@
         // Note: it is not possible to override hardcoded values.
         parsePropertyAssignments(p, runtime.properties());
 
-
         // Set static hardcoded properties.
         // These come last, as they must be guaranteed to agree with what a backend compiler
         // may assume when compiling the boot image on Android.
@@ -1031,9 +1031,9 @@
     }
 
     private static Properties setDefaultChangeableProperties(Properties p) {
-        // On Android, each app gets its own temporary directory.
-        // (See android.app.ActivityThread.) This is just a fallback default,
-        // useful only on the host.
+        // On Android, "java.io.tmpdir" is set in android.app.ActivityThread. Each app gets its
+        // own location, a typical value would be "/data/user/0/com.android.deskclock/cache.
+        // The value set here is just a fallback default for host.
         // We check first if the property has not been set already: note that it
         // can only be set from the command line through the '-Djava.io.tmpdir=' option.
         if (!unchangeableProps.containsKey("java.io.tmpdir")) {
@@ -1106,8 +1106,8 @@
      * <tr><td>java.class.version</td> <td>(Not useful on Android)</td>           <td>{@code 50.0}</td></tr>
      * <tr><td>java.compiler</td>      <td>(Not useful on Android)</td>           <td>Empty</td></tr>
      * <tr><td>java.ext.dirs</td>      <td>(Not useful on Android)</td>           <td>Empty</td></tr>
-     * <tr><td>java.home</td>          <td>Location of the VM on the file system</td> <td>{@code /system}</td></tr>
-     * <tr><td>java.io.tmpdir</td>     <td>See {@link java.io.File#createTempFile}</td> <td>{@code /sdcard}</td></tr>
+     * <tr><td>java.home</td>          <td>Location of the VM on the file system</td> <td>{@code /apex/com.android.art/}</td></tr>
+     * <tr><td>java.io.tmpdir</td>     <td>Location of a temporary directory.<br>The location varies by application.<br>See {@link java.io.File#createTempFile}</td> <td>{@code /data/user/0/com.android.app/cache}</td></tr>
      * <tr><td>java.library.path</td>  <td>Search path for JNI libraries</td>     <td>{@code /vendor/lib:/system/lib}</td></tr>
      * <tr><td>java.vendor</td>        <td>Human-readable VM vendor</td>          <td>{@code The Android Project}</td></tr>
      * <tr><td>java.vendor.url</td>    <td>URL for VM vendor's web site</td>      <td>{@code http://www.android.com/}</td></tr>
@@ -1125,9 +1125,9 @@
      *
      * <tr><td>line.separator</td>     <td>The system line separator</td>         <td>{@code \n}</td></tr>
      *
-     * <tr><td>os.arch</td>            <td>OS architecture</td>                   <td>{@code armv7l}</td></tr>
+     * <tr><td>os.arch</td>            <td>OS architecture</td>                   <td>{@code aarch64}</td></tr>
      * <tr><td>os.name</td>            <td>OS (kernel) name</td>                  <td>{@code Linux}</td></tr>
-     * <tr><td>os.version</td>         <td>OS (kernel) version</td>               <td>{@code 2.6.32.9-g103d848}</td></tr>
+     * <tr><td>os.version</td>         <td>OS (kernel) version</td>               <td>{@code 5.10.98-g6ea688a79989}</td></tr>
      *
      * <tr><td>path.separator</td>     <td>See {@link java.io.File#pathSeparator}</td> <td>{@code :}</td></tr>
      *
diff --git a/ojluni/src/main/java/java/net/NetworkInterface.java b/ojluni/src/main/java/java/net/NetworkInterface.java
index f09c48b..c2b2e58 100644
--- a/ojluni/src/main/java/java/net/NetworkInterface.java
+++ b/ojluni/src/main/java/java/net/NetworkInterface.java
@@ -457,6 +457,10 @@
         StructIfaddrs[] ifaddrs;
         try {
             ifaddrs = Libcore.os.getifaddrs();
+            // Defensive check for b/217749090: ifaddrs should never be null.
+            if (ifaddrs == null) {
+                throw new SocketException("Failed to query network interfaces.");
+            }
         } catch (ErrnoException e) {
             throw e.rethrowAsSocketException();
         }
diff --git a/ojluni/src/main/java/java/security/DigestException.java b/ojluni/src/main/java/java/security/DigestException.java
index 2327c98..f275530 100644
--- a/ojluni/src/main/java/java/security/DigestException.java
+++ b/ojluni/src/main/java/java/security/DigestException.java
@@ -29,6 +29,7 @@
  * This is the generic Message Digest exception.
  *
  * @author Benjamin Renaud
+ * @since 1.1
  */
 public class DigestException extends GeneralSecurityException {
 
diff --git a/ojluni/src/main/java/java/security/cert/Certificate.java b/ojluni/src/main/java/java/security/cert/Certificate.java
index e9b2d75..ad72e63 100644
--- a/ojluni/src/main/java/java/security/cert/Certificate.java
+++ b/ojluni/src/main/java/java/security/cert/Certificate.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
diff --git a/ojluni/src/main/java/java/security/cert/CertificateFactorySpi.java b/ojluni/src/main/java/java/security/cert/CertificateFactorySpi.java
index f507c4b..0b1bb33 100644
--- a/ojluni/src/main/java/java/security/cert/CertificateFactorySpi.java
+++ b/ojluni/src/main/java/java/security/cert/CertificateFactorySpi.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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
diff --git a/ojluni/src/main/java/java/security/spec/InvalidKeySpecException.java b/ojluni/src/main/java/java/security/spec/InvalidKeySpecException.java
index 4655c4a..4439e00 100644
--- a/ojluni/src/main/java/java/security/spec/InvalidKeySpecException.java
+++ b/ojluni/src/main/java/java/security/spec/InvalidKeySpecException.java
@@ -63,7 +63,7 @@
     }
 
     /**
-     * Creates a {@code InvalidKeySpecException} with the specified
+     * Creates an {@code InvalidKeySpecException} with the specified
      * detail message and cause.
      *
      * @param message the detail message (which is saved for later retrieval
@@ -78,7 +78,7 @@
     }
 
     /**
-     * Creates a {@code InvalidKeySpecException} with the specified cause
+     * Creates an {@code InvalidKeySpecException} with the specified cause
      * and a detail message of {@code (cause==null ? null : cause.toString())}
      * (which typically contains the class and detail message of
      * {@code cause}).
diff --git a/ojluni/src/main/java/java/time/chrono/Era.java b/ojluni/src/main/java/java/time/chrono/Era.java
index 0e3c533..019050c 100644
--- a/ojluni/src/main/java/java/time/chrono/Era.java
+++ b/ojluni/src/main/java/java/time/chrono/Era.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
diff --git a/ojluni/src/main/java/java/time/chrono/package-info.java b/ojluni/src/main/java/java/time/chrono/package-info.java
index 9273a77..c382fb1 100644
--- a/ojluni/src/main/java/java/time/chrono/package-info.java
+++ b/ojluni/src/main/java/java/time/chrono/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -95,7 +95,7 @@
  * <li>{@link java.time.chrono.ThaiBuddhistChronology Thai Buddhist calendar}</li>
  * </ul>
  *
- * <h3>Example</h3>
+ * <h2>Example</h2>
  * <p>
  * This example lists todays date for all of the available calendars.
  * </p>
@@ -155,7 +155,7 @@
  *                 first, last);
  *  </pre>
  *
- * <h3>Package specification</h3>
+ * <h2>Package specification</h2>
  * <p>
  * Unless otherwise noted, passing a null argument to a constructor or method in any class or interface
  * in this package will cause a {@link java.lang.NullPointerException NullPointerException} to be thrown.
@@ -166,6 +166,6 @@
  * All calculations should check for numeric overflow and throw either an {@link java.lang.ArithmeticException}
  * or a {@link java.time.DateTimeException}.
  * </p>
- * @since JDK1.8
+ * @since 1.8
  */
 package java.time.chrono;
diff --git a/ojluni/src/main/java/java/time/format/package-info.java b/ojluni/src/main/java/java/time/format/package-info.java
index 140bb6d..d4f1ce7 100644
--- a/ojluni/src/main/java/java/time/format/package-info.java
+++ b/ojluni/src/main/java/java/time/format/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -79,7 +79,7 @@
  * {@link java.time.format.DecimalStyle DecimalStyle}.
  * </p>
  *
- * <h3>Package specification</h3>
+ * <h2>Package specification</h2>
  * <p>
  * Unless otherwise noted, passing a null argument to a constructor or method in any class or interface
  * in this package will cause a {@link java.lang.NullPointerException NullPointerException} to be thrown.
@@ -90,6 +90,6 @@
  * All calculations should check for numeric overflow and throw either an {@link java.lang.ArithmeticException}
  * or a {@link java.time.DateTimeException}.
  * </p>
- * @since JDK1.8
+ * @since 1.8
  */
 package java.time.format;
diff --git a/ojluni/src/main/java/java/time/package-info.java b/ojluni/src/main/java/java/time/package-info.java
index ea160ff..be783ba 100644
--- a/ojluni/src/main/java/java/time/package-info.java
+++ b/ojluni/src/main/java/java/time/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -90,7 +90,7 @@
  * The calendar neutral API should be reserved for interactions with users.
  * </p>
  *
- * <h3>Dates and Times</h3>
+ * <h2>Dates and Times</h2>
  * <p>
  * {@link java.time.Instant} is essentially a numeric timestamp.
  * The current Instant can be retrieved from a {@link java.time.Clock}.
@@ -118,7 +118,7 @@
  * The widespread use of time-zones tends to add considerable complexity to an application.
  * </p>
  *
- * <h3>Duration and Period</h3>
+ * <h2>Duration and Period</h2>
  * <p>
  * Beyond dates and times, the API also allows the storage of periods and durations of time.
  * A {@link java.time.Duration} is a simple measure of time along the time-line in nanoseconds.
@@ -126,7 +126,7 @@
  * to humans, such as years or days.
  * </p>
  *
- * <h3>Additional value types</h3>
+ * <h2>Additional value types</h2>
  * <p>
  * {@link java.time.Month} stores a month on its own.
  * This stores a single month-of-year in isolation, such as 'DECEMBER'.
@@ -160,7 +160,7 @@
  * but contains less information than a full time-zone.
  * </p>
  *
- * <h3>Package specification</h3>
+ * <h2>Package specification</h2>
  * <p>
  * Unless otherwise noted, passing a null argument to a constructor or method in any class or interface
  * in this package will cause a {@link java.lang.NullPointerException NullPointerException} to be thrown.
@@ -172,7 +172,7 @@
  * or a {@link java.time.DateTimeException}.
  * </p>
  *
- * <h3>Design notes (non normative)</h3>
+ * <h2>Design notes (non normative)</h2>
  * <p>
  * The API has been designed to reject null early and to be clear about this behavior.
  * A key exception is any method that takes an object and returns a boolean, for the purpose
@@ -283,6 +283,6 @@
  *
  * </pre>
  *
- * @since JDK1.8
+ * @since 1.8
  */
 package java.time;
diff --git a/ojluni/src/main/java/java/util/concurrent/ArrayBlockingQueue.java b/ojluni/src/main/java/java/util/concurrent/ArrayBlockingQueue.java
index dced5a4..13fc3ce 100644
--- a/ojluni/src/main/java/java/util/concurrent/ArrayBlockingQueue.java
+++ b/ojluni/src/main/java/java/util/concurrent/ArrayBlockingQueue.java
@@ -79,6 +79,7 @@
  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
+ * @since 1.5
  * @author Doug Lea
  * @param <E> the type of elements held in this queue
  */
diff --git a/ojluni/src/main/java/java/util/concurrent/BlockingQueue.java b/ojluni/src/main/java/java/util/concurrent/BlockingQueue.java
index 6fecc27..ec7593d 100644
--- a/ojluni/src/main/java/java/util/concurrent/BlockingQueue.java
+++ b/ojluni/src/main/java/java/util/concurrent/BlockingQueue.java
@@ -172,6 +172,7 @@
  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  * Java Collections Framework</a>.
  *
+ * @since 1.5
  * @author Doug Lea
  * @param <E> the type of elements held in this queue
  */
diff --git a/ojluni/src/main/native/JniConstants.cpp b/ojluni/src/main/native/JniConstants.cpp
index 0eb499d..287bc54 100644
--- a/ojluni/src/main/native/JniConstants.cpp
+++ b/ojluni/src/main/native/JniConstants.cpp
@@ -55,10 +55,6 @@
 // initialized. This pattern is only necessary because if a process finishes one
 // runtime and starts another then JNI_OnLoad may not be called.
 void EnsureJniConstantsInitialized(JNIEnv* env) {
-    if (g_constants_valid) {
-        return;
-    }
-
     std::lock_guard guard(g_constants_mutex);
     if (g_constants_valid) {
         return;
diff --git a/ojluni/src/test/java/security/KeyStore/ProbeKeystores.java b/ojluni/src/test/java/security/KeyStore/ProbeKeystores.java
new file mode 100644
index 0000000..3cbfca0
--- /dev/null
+++ b/ojluni/src/test/java/security/KeyStore/ProbeKeystores.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2014, 2018, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8044445 8194307 8207318
+ * @summary test new methods from JEP-229: Create PKCS12 Keystores by Default
+ */
+package test.java.security.KeyStore;
+
+import java.io.*;
+import java.security.*;
+import java.security.KeyStore.*;
+import java.security.cert.*;
+import javax.crypto.*;
+import javax.security.auth.callback.*;
+import org.testng.annotations.Test;
+import static org.junit.Assert.fail;
+
+public class ProbeKeystores {
+    // BEGIN Android-changed: adjusted tests to account for multiple implementation details.
+
+    private static final char[] PASSWORD = "changeit".toCharArray();
+    private static final LoadStoreParameter LOAD_STORE_PARAM =
+            new MyLoadStoreParameter(new PasswordProtection(PASSWORD));
+
+    private static class MyLoadStoreParameter implements LoadStoreParameter {
+
+        private ProtectionParameter protection;
+
+        MyLoadStoreParameter(ProtectionParameter protection) {
+            this.protection = protection;
+        }
+
+        public ProtectionParameter getProtectionParameter() {
+            return protection;
+        }
+    }
+
+    @Test
+    public void testKeystores() throws Exception {
+        File bcFile = File.createTempFile("empty", "bc");
+        File p12File = File.createTempFile("empty", "p12");
+
+        // Testing empty keystores
+
+        init(bcFile, "BouncyCastle");
+        init(p12File, "PKCS12");
+
+
+        load(bcFile, "BouncyCastle");
+        load(p12File, "PKCS12");
+        loadNonCompat(bcFile, "PKCS12"); // test compatibility mode
+        loadNonCompat(p12File, "BouncyCastle"); // test compatibility mode
+
+        probe(bcFile);
+        probe(p12File);
+
+        build(bcFile, true);
+        build(bcFile, false);
+        build(p12File, true);
+        build(p12File, false);
+
+        File onekeyBcFile = File.createTempFile("onekey", "bc");
+        SecretKey key = generateSecretKey("AES", 128);
+        init(onekeyBcFile, "BouncyCastle", key);
+
+        load(onekeyBcFile, "BouncyCastle");
+
+        probe(onekeyBcFile);
+
+        build(onekeyBcFile, true);
+        build(onekeyBcFile, false);
+    }
+
+    // Instantiate an empty keystore using the supplied keystore type
+    private static void init(File file, String type) throws Exception {
+        KeyStore ks = KeyStore.getInstance(type);
+        ks.load(null, null);
+        try (OutputStream stream = new FileOutputStream(file)) {
+            ks.store(stream, PASSWORD);
+        }
+    }
+
+    // Instantiate a keystore using the supplied keystore type & create an entry
+    private static void init(File file, String type, SecretKey key)
+            throws Exception {
+        KeyStore ks = KeyStore.getInstance(type);
+        ks.load(null, null);
+        ks.setEntry("mykey", new KeyStore.SecretKeyEntry(key),
+                new PasswordProtection(PASSWORD));
+        try (OutputStream stream = new FileOutputStream(file)) {
+            ks.store(stream, PASSWORD);
+        }
+    }
+
+    // Instantiate a keystore by probing the supplied file for the keystore type
+    private static void probe(File file) throws Exception {
+        KeyStore ks;
+        try {
+            ks = KeyStore.getInstance(file, PASSWORD);
+            fail("ERROR: expected an exception but got success");
+        } catch (KeyStoreException e) {
+            // Expected
+        }
+
+        try {
+            ks = KeyStore.getInstance(file, LOAD_STORE_PARAM);
+            fail("ERROR: expected an exception but got success");
+        } catch (KeyStoreException e) {
+            // Expected
+        }
+    }
+    // Instantiate a keystore by probing the supplied file for the keystore type
+    private static void build(File file, boolean usePassword) throws Exception {
+        Builder builder;
+        if (usePassword) {
+            builder = Builder.newInstance(file,
+                    new PasswordProtection(PASSWORD));
+        } else {
+            builder = Builder.newInstance(file,
+                    new CallbackHandlerProtection(new DummyHandler()));
+        }
+        try {
+            KeyStore ks = builder.getKeyStore();
+        } catch (KeyStoreException e) {
+            // Expected
+        }
+    }
+
+    // Load the keystore entries
+    private static void load(File file, String type) throws Exception {
+        Security.setProperty("keystore.type.compat", "true");
+        KeyStore ks = KeyStore.getInstance(type);
+        try (InputStream stream = new FileInputStream(file)) {
+            ks.load(stream, PASSWORD);
+        }
+    }
+
+    // Load the keystore entries (with compatibility mode disabled)
+    private static void loadNonCompat(File file, String type)
+            throws Exception {
+        try {
+            load(file, type);
+            fail("ERROR: expected load to fail but it didn't");
+        } catch (IOException e) {
+            // Expected
+        }
+    }
+
+    // END Android-changed:  adjusted tests to account for multiple implementation details.
+
+    // Generate a secret key using the supplied algorithm name and key size
+    private static SecretKey generateSecretKey(String algorithm, int size)
+            throws NoSuchAlgorithmException {
+        KeyGenerator generator = KeyGenerator.getInstance(algorithm);
+        generator.init(size);
+        return generator.generateKey();
+    }
+
+    private static class DummyHandler implements CallbackHandler {
+        public void handle(Callback[] callbacks)
+                throws IOException, UnsupportedCallbackException {
+            System.out.println("** Callbackhandler invoked");
+            for (int i = 0; i < callbacks.length; i++) {
+                Callback cb = callbacks[i];
+                if (cb instanceof PasswordCallback) {
+                    PasswordCallback pcb = (PasswordCallback)cb;
+                    pcb.setPassword(PASSWORD);
+                    break;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/luni/src/test/java/libcore/sun/security/jca/ProvidersTest.java b/ojluni/src/test/java/security/Provider/ProvidersTest.java
similarity index 98%
rename from luni/src/test/java/libcore/sun/security/jca/ProvidersTest.java
rename to ojluni/src/test/java/security/Provider/ProvidersTest.java
index 45c857f..44d2714 100644
--- a/luni/src/test/java/libcore/sun/security/jca/ProvidersTest.java
+++ b/ojluni/src/test/java/security/Provider/ProvidersTest.java
@@ -14,12 +14,9 @@
  * limitations under the License.
  */
 
-package libcore.sun.security.jca;
+package test.java.security.Provider;
 
 import com.android.org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
 
 import dalvik.system.VMRuntime;
 
@@ -52,6 +49,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
+import org.testng.annotations.Test;
 
 /**
  * Tests that the deprecation of algorithms from the BC provider works as expected.  Requests
@@ -59,7 +57,6 @@
  * but those targeting an API level after the deprecation should cause an exception.  Tests
  * a representative sample of services and algorithms and various ways of naming them.
  */
-@RunWith(JUnit4.class)
 public class ProvidersTest {
 
     /**