Merge "Update ResourceBundle related classes from java.util to OpenJDK8u60"
diff --git a/JavaLibrary.mk b/JavaLibrary.mk
index 470484e..ef7703e 100644
--- a/JavaLibrary.mk
+++ b/JavaLibrary.mk
@@ -188,7 +188,7 @@
 LOCAL_SRC_FILES := $(test_src_files)
 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
 LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES := core-oj core-libart core-lambda-stubs okhttp core-junit junit4-target bouncycastle mockito-target
+LOCAL_JAVA_LIBRARIES := core-oj core-libart okhttp core-junit junit4-target bouncycastle mockito-target
 LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests
 LOCAL_JAVACFLAGS := $(local_javac_flags)
 LOCAL_JAVA_LANGUAGE_VERSION := 1.8
@@ -217,7 +217,7 @@
 LOCAL_SRC_FILES :=  $(call all-test-java-files-under, jsr166-tests)
 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
 LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES := core-oj core-libart core-lambda-stubs core-junit junit4-target
+LOCAL_JAVA_LIBRARIES := core-oj core-libart core-junit junit4-target
 LOCAL_JAVACFLAGS := $(local_javac_flags)
 LOCAL_MODULE := jsr166-tests
 LOCAL_JAVA_LANGUAGE_VERSION := 1.8
@@ -229,7 +229,7 @@
 ifeq ($(LIBCORE_SKIP_TESTS),)
     include $(CLEAR_VARS)
     LOCAL_NO_STANDARD_LIBRARIES := true
-    LOCAL_JAVA_LIBRARIES := core-oj core-libart core-lambda-stubs okhttp bouncycastle
+    LOCAL_JAVA_LIBRARIES := core-oj core-libart okhttp bouncycastle
     LOCAL_STATIC_JAVA_LIBRARIES := testng
     LOCAL_JAVACFLAGS := $(local_javac_flags)
     LOCAL_MODULE_TAGS := optional
@@ -249,7 +249,7 @@
     # Include source code as part of JAR
     LOCAL_JAVA_RESOURCE_DIRS := ojluni/src/test/dist
     LOCAL_NO_STANDARD_LIBRARIES := true
-    LOCAL_JAVA_LIBRARIES := core-oj core-libart core-lambda-stubs okhttp bouncycastle testng
+    LOCAL_JAVA_LIBRARIES := core-oj core-libart okhttp bouncycastle testng
     LOCAL_JAVACFLAGS := $(local_javac_flags)
     LOCAL_MODULE_TAGS := optional
     LOCAL_JAVA_LANGUAGE_VERSION := 1.8
@@ -335,7 +335,7 @@
     LOCAL_SRC_FILES := $(test_src_files)
     LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
     LOCAL_NO_STANDARD_LIBRARIES := true
-    LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex core-lambda-stubs-hostdex okhttp-hostdex bouncycastle-hostdex core-junit-hostdex junit4-target-hostdex core-tests-support-hostdex mockito-api-hostdex
+    LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex okhttp-hostdex bouncycastle-hostdex core-junit-hostdex junit4-target-hostdex core-tests-support-hostdex mockito-api-hostdex
     LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
     LOCAL_JAVACFLAGS := $(local_javac_flags)
     LOCAL_MODULE_TAGS := optional
@@ -365,7 +365,7 @@
     include $(CLEAR_VARS)
     LOCAL_SRC_FILES := $(ojtest_src_files)
     LOCAL_NO_STANDARD_LIBRARIES := true
-    LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex core-lambda-stubs-hostdex okhttp-hostdex bouncycastle-hostdex
+    LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex okhttp-hostdex bouncycastle-hostdex
     LOCAL_STATIC_JAVA_LIBRARIES := testng-hostdex
     LOCAL_JAVACFLAGS := $(local_javac_flags)
     LOCAL_MODULE_TAGS := optional
diff --git a/benchmarks/src/benchmarks/regression/NativeMethodBenchmark.java b/benchmarks/src/benchmarks/regression/NativeMethodBenchmark.java
index c30ea08..dbb6308 100644
--- a/benchmarks/src/benchmarks/regression/NativeMethodBenchmark.java
+++ b/benchmarks/src/benchmarks/regression/NativeMethodBenchmark.java
@@ -32,11 +32,6 @@
         }
     }
 
-    public void time_emptyJniStaticMethod0(int reps) throws Exception {
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod0();
-        }
-    }
 
     public void time_emptyJniMethod0(int reps) throws Exception {
         NativeTestTarget n = new NativeTestTarget();
@@ -45,14 +40,6 @@
         }
     }
 
-    public void time_emptyJniStaticMethod6(int reps) throws Exception {
-        int a = -1;
-        int b = 0;
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod6(a, b, 1, 2, 3, i);
-        }
-    }
-
     public void time_emptyJniMethod6(int reps) throws Exception {
         int a = -1;
         int b = 0;
@@ -62,12 +49,6 @@
         }
     }
 
-    public void time_emptyJniStaticMethod6L(int reps) throws Exception {
-        for (int i = 0; i < reps; ++i) {
-            NativeTestTarget.emptyJniStaticMethod6L(null, null, null, null, null, null);
-        }
-    }
-
     public void time_emptyJniMethod6L(int reps) throws Exception {
         NativeTestTarget n = new NativeTestTarget();
         for (int i = 0; i < reps; ++i) {
@@ -75,4 +56,78 @@
         }
     }
 
+    public void time_emptyJniStaticMethod6L(int reps) throws Exception {
+        for (int i = 0; i < reps; ++i) {
+            NativeTestTarget.emptyJniStaticMethod6L(null, null, null, null, null, null);
+        }
+    }
+    public void time_emptyJniStaticMethod0(int reps) throws Exception {
+        for (int i = 0; i < reps; ++i) {
+            NativeTestTarget.emptyJniStaticMethod0();
+        }
+    }
+
+    public void time_emptyJniStaticMethod6(int reps) throws Exception {
+        int a = -1;
+        int b = 0;
+        for (int i = 0; i < reps; ++i) {
+            NativeTestTarget.emptyJniStaticMethod6(a, b, 1, 2, 3, i);
+        }
+    }
+
+    public void time_emptyJniMethod0_Fast(int reps) throws Exception {
+        NativeTestTarget n = new NativeTestTarget();
+        for (int i = 0; i < reps; ++i) {
+            n.emptyJniMethod0_Fast();
+        }
+    }
+
+    public void time_emptyJniMethod6_Fast(int reps) throws Exception {
+        int a = -1;
+        int b = 0;
+        NativeTestTarget n = new NativeTestTarget();
+        for (int i = 0; i < reps; ++i) {
+            n.emptyJniMethod6_Fast(a, b, 1, 2, 3, i);
+        }
+    }
+
+    public void time_emptyJniMethod6L_Fast(int reps) throws Exception {
+        NativeTestTarget n = new NativeTestTarget();
+        for (int i = 0; i < reps; ++i) {
+            n.emptyJniMethod6L_Fast(null, null, null, null, null, null);
+        }
+    }
+
+    public void time_emptyJniStaticMethod6L_Fast(int reps) throws Exception {
+        for (int i = 0; i < reps; ++i) {
+            NativeTestTarget.emptyJniStaticMethod6L_Fast(null, null, null, null, null, null);
+        }
+    }
+    public void time_emptyJniStaticMethod0_Fast(int reps) throws Exception {
+        for (int i = 0; i < reps; ++i) {
+            NativeTestTarget.emptyJniStaticMethod0_Fast();
+        }
+    }
+
+    public void time_emptyJniStaticMethod6_Fast(int reps) throws Exception {
+        int a = -1;
+        int b = 0;
+        for (int i = 0; i < reps; ++i) {
+            NativeTestTarget.emptyJniStaticMethod6_Fast(a, b, 1, 2, 3, i);
+        }
+    }
+
+    public void time_emptyJniStaticMethod0_Critical(int reps) throws Exception {
+        for (int i = 0; i < reps; ++i) {
+            NativeTestTarget.emptyJniStaticMethod0_Critical();
+        }
+    }
+
+    public void time_emptyJniStaticMethod6_Critical(int reps) throws Exception {
+        int a = -1;
+        int b = 0;
+        for (int i = 0; i < reps; ++i) {
+            NativeTestTarget.emptyJniStaticMethod6_Critical(a, b, 1, 2, 3, i);
+        }
+    }
 }
diff --git a/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java b/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java
index 5daf6a0..a9efabe 100644
--- a/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java
+++ b/dalvik/src/main/java/org/apache/harmony/dalvik/NativeTestTarget.java
@@ -16,6 +16,9 @@
 
 package org.apache.harmony.dalvik;
 
+import dalvik.annotation.optimization.CriticalNative;
+import dalvik.annotation.optimization.FastNative;
+
 /**
  * Methods used to test calling into native code. The methods in this
  * class are all effectively no-ops and may be used to test the mechanisms
@@ -25,30 +28,6 @@
     public NativeTestTarget() {
     }
 
-    public static native synchronized void emptyJniStaticSynchronizedMethod0();
-
-    public native synchronized void emptyJniSynchronizedMethod0();
-
-    public static native void emptyJniStaticMethod0();
-
-    public native void emptyJniMethod0();
-
-    public static native void emptyJniStaticMethod6(int a, int b, int c, int d, int e, int f);
-
-    public native void emptyJniMethod6(int a, int b, int c, int d, int e, int f);
-
-    /**
-     * This is an empty native static method with six args, hooked up
-     * using JNI. These have more complex args to show the cost of
-     * parsing the signature. All six values should be null
-     * references.
-     */
-    public static native void emptyJniStaticMethod6L(String a, String[] b,
-        int[][] c, Object d, Object[] e, Object[][][][] f);
-
-    public native void emptyJniMethod6L(String a, String[] b,
-        int[][] c, Object d, Object[] e, Object[][][][] f);
-
     /**
      * This is used to benchmark dalvik's inline natives.
      */
@@ -59,4 +38,64 @@
      * This is used to benchmark dalvik's inline natives.
      */
     public static native void emptyInternalStaticMethod();
+
+    // Synchronized methods. Test normal JNI only.
+    public static native synchronized void emptyJniStaticSynchronizedMethod0();
+    public native synchronized void emptyJniSynchronizedMethod0();
+
+    // Static methods without object parameters. Test all optimization combinations.
+
+    // Normal native.
+    public static native void emptyJniStaticMethod0();
+    // Normal native.
+    public static native void emptyJniStaticMethod6(int a, int b, int c, int d, int e, int f);
+
+    @FastNative
+    public static native void emptyJniStaticMethod0_Fast();
+    @FastNative
+    public static native void emptyJniStaticMethod6_Fast(int a, int b, int c, int d, int e, int f);
+
+    @CriticalNative
+    public static native void emptyJniStaticMethod0_Critical();
+    @CriticalNative
+    public static native void emptyJniStaticMethod6_Critical(int a, int b, int c, int d, int e, int f);
+    // Instance methods or methods with object parameters. Test {Normal, @FastNative} combinations.
+
+    // Normal native.
+    public native void emptyJniMethod0();
+    // Normal native.
+    public native void emptyJniMethod6(int a, int b, int c, int d, int e, int f);
+
+    /**
+     * This is an empty native static method with six args, hooked up
+     * using JNI. These have more complex args to show the cost of
+     * parsing the signature. All six values should be null
+     * references.
+     */
+    // Normal native.
+    public static native void emptyJniStaticMethod6L(String a, String[] b,
+        int[][] c, Object d, Object[] e, Object[][][][] f);
+
+    // Normal native.
+    public native void emptyJniMethod6L(String a, String[] b,
+        int[][] c, Object d, Object[] e, Object[][][][] f);
+
+    @FastNative
+    public native void emptyJniMethod0_Fast();
+    @FastNative
+    public native void emptyJniMethod6_Fast(int a, int b, int c, int d, int e, int f);
+
+    /**
+     * This is an empty native static method with six args, hooked up
+     * using JNI. These have more complex args to show the cost of
+     * parsing the signature. All six values should be null
+     * references.
+     */
+    @FastNative
+    public static native void emptyJniStaticMethod6L_Fast(String a, String[] b,
+        int[][] c, Object d, Object[] e, Object[][][][] f);
+
+    @FastNative
+    public native void emptyJniMethod6L_Fast(String a, String[] b,
+        int[][] c, Object d, Object[] e, Object[][][][] f);
 }
diff --git a/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp b/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
index 52f22a8..9a934f6 100644
--- a/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
+++ b/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.cpp
@@ -19,25 +19,62 @@
 #include "JNIHelp.h"
 #include "JniConstants.h"
 
-static void NativeTestTarget_emptyJniMethod0(JNIEnv*, jobject) { }
-static void NativeTestTarget_emptyJniMethod6(JNIEnv*, jclass, int, int, int, int, int, int) { }
-static void NativeTestTarget_emptyJniMethod6L(JNIEnv*, jclass, jobject, jarray, jarray, jobject, jarray, jarray) { }
-static void NativeTestTarget_emptyJniStaticMethod0(JNIEnv*, jclass) { }
-static void NativeTestTarget_emptyJniStaticMethod6(JNIEnv*, jclass, int, int, int, int, int, int) { }
-static void NativeTestTarget_emptyJniStaticMethod6L(JNIEnv*, jclass, jobject, jarray, jarray, jobject, jarray, jarray) { }
 static void NativeTestTarget_emptyJniStaticSynchronizedMethod0(JNIEnv*, jclass) { }
 static void NativeTestTarget_emptyJniSynchronizedMethod0(JNIEnv*, jclass) { }
 
+static JNINativeMethod gMethods_NormalOnly[] = {
+    NATIVE_METHOD(NativeTestTarget, emptyJniStaticSynchronizedMethod0, "()V"),
+    NATIVE_METHOD(NativeTestTarget, emptyJniSynchronizedMethod0, "()V"),
+};
+
+
+static void NativeTestTarget_emptyJniMethod0(JNIEnv*, jobject) { }
+static void NativeTestTarget_emptyJniMethod6(JNIEnv*, jobject, int, int, int, int, int, int) { }
+static void NativeTestTarget_emptyJniMethod6L(JNIEnv*, jobject, jobject, jarray, jarray, jobject, jarray, jarray) { }
+static void NativeTestTarget_emptyJniStaticMethod6L(JNIEnv*, jclass, jobject, jarray, jarray, jobject, jarray, jarray) { }
+
+static void NativeTestTarget_emptyJniStaticMethod0(JNIEnv*, jclass) { }
+static void NativeTestTarget_emptyJniStaticMethod6(JNIEnv*, jclass, int, int, int, int, int, int) { }
+
 static JNINativeMethod gMethods[] = {
     NATIVE_METHOD(NativeTestTarget, emptyJniMethod0, "()V"),
     NATIVE_METHOD(NativeTestTarget, emptyJniMethod6, "(IIIIII)V"),
     NATIVE_METHOD(NativeTestTarget, emptyJniMethod6L, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
+    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6L, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
     NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod0, "()V"),
     NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6, "(IIIIII)V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6L, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniStaticSynchronizedMethod0, "()V"),
-    NATIVE_METHOD(NativeTestTarget, emptyJniSynchronizedMethod0, "()V"),
+};
+
+static void NativeTestTarget_emptyJniMethod0_Fast(JNIEnv*, jobject) { }
+static void NativeTestTarget_emptyJniMethod6_Fast(JNIEnv*, jobject, int, int, int, int, int, int) { }
+static void NativeTestTarget_emptyJniMethod6L_Fast(JNIEnv*, jobject, jobject, jarray, jarray, jobject, jarray, jarray) { }
+static void NativeTestTarget_emptyJniStaticMethod6L_Fast(JNIEnv*, jclass, jobject, jarray, jarray, jobject, jarray, jarray) { }
+
+static void NativeTestTarget_emptyJniStaticMethod0_Fast(JNIEnv*, jclass) { }
+static void NativeTestTarget_emptyJniStaticMethod6_Fast(JNIEnv*, jclass, int, int, int, int, int, int) { }
+
+static JNINativeMethod gMethods_Fast[] = {
+    NATIVE_METHOD(NativeTestTarget, emptyJniMethod0_Fast, "()V"),
+    NATIVE_METHOD(NativeTestTarget, emptyJniMethod6_Fast, "(IIIIII)V"),
+    NATIVE_METHOD(NativeTestTarget, emptyJniMethod6L_Fast, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
+    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6L_Fast, "(Ljava/lang/String;[Ljava/lang/String;[[ILjava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V"),
+    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod0_Fast, "()V"),
+    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6_Fast, "(IIIIII)V"),
+};
+
+
+static void NativeTestTarget_emptyJniStaticMethod0_Critical() { }
+static void NativeTestTarget_emptyJniStaticMethod6_Critical( int, int, int, int, int, int) { }
+
+static JNINativeMethod gMethods_Critical[] = {
+    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod0_Critical, "()V"),
+    NATIVE_METHOD(NativeTestTarget, emptyJniStaticMethod6_Critical, "(IIIIII)V"),
 };
 int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env) {
-    return jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods, NELEM(gMethods));
+    jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods_NormalOnly, NELEM(gMethods_NormalOnly));
+    jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods, NELEM(gMethods));
+    jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods_Fast, NELEM(gMethods_Fast));
+    jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods_Critical, NELEM(gMethods_Critical));
+
+    return 0;
 }
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index 1cf37c9..a2ff4ee 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -1548,5 +1548,13 @@
   names: [
     "com.android.org.apache.harmony.luni.tests.java.net.URLClassLoaderImplTest#test_Constructor$Ljava_net_URLLjava_lang_ClassLoaderLjava_net_URLStreamHandlerFactory"
   ]
+},
+{
+  description: "Waiting for ICU 58 to be merged",
+  bug: 31516121,
+  result: EXEC_FAILED,
+  names: [
+    "libcore.java.text.OldBidiTest#testUnicode9EmojisAreLtrNeutral"
+  ]
 }
 ]
diff --git a/expectations/virtualdeviceknownfailures.txt b/expectations/virtualdeviceknownfailures.txt
new file mode 100644
index 0000000..f427a71
--- /dev/null
+++ b/expectations/virtualdeviceknownfailures.txt
@@ -0,0 +1,11 @@
+/*
+ * This file contains expectations for tests known to fail on virtual device
+ */
+[
+{
+  description: "IPv6 connectivity not yet supported in virtual device testing infra",
+  result: EXEC_FAILED,
+  name: "libcore.java.net.SocketTest#testSocketTestAllAddresses",
+  bug: 30965313
+}
+]
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/PropertiesTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/PropertiesTest.java
index 27cae4e..038cc7b 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/PropertiesTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/PropertiesTest.java
@@ -20,15 +20,18 @@
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.CharArrayReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.PrintStream;
 import java.io.PrintWriter;
+import java.io.Reader;
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.InvalidPropertiesFormatException;
@@ -389,21 +392,21 @@
 
         prop = new Properties();
         Properties expected = new Properties();
-        expected.put("a", "\u0000");
+        expected.put("a", "");
         prop.load(new ByteArrayInputStream("a=\\".getBytes()));
-        assertEquals("Failed to read trailing slash value", expected, prop);
+        assertEquals("Failed to trim trailing slash value", expected, prop);
 
         prop = new Properties();
         expected = new Properties();
-        expected.put("a", "\u1234\u0000");
+        expected.put("a", "\u1234");
         prop.load(new ByteArrayInputStream("a=\\u1234\\".getBytes()));
-        assertEquals("Failed to read trailing slash value #2", expected, prop);
+        assertEquals("Failed to trim trailing slash value #2", expected, prop);
 
         prop = new Properties();
         expected = new Properties();
         expected.put("a", "q");
         prop.load(new ByteArrayInputStream("a=\\q".getBytes()));
-        assertEquals("Failed to read slash value #3", expected, prop);
+        assertEquals("Failed to skip slash value #3", expected, prop);
     }
 
     /**
@@ -1087,6 +1090,47 @@
     }
 
     /**
+     * Checks the example given in the documentation of a single property split over
+     * multiple lines separated by a backslash and newline character.
+     */
+    public void testSingleProperty_multipleLinesJoinedByBackslash() throws Exception {
+        String propertyString = "fruits                           apple, banana, pear, \\\n"
+                + "                                  cantaloupe, watermelon, \\\n"
+                + "                                  kiwi, mango";
+        checkSingleProperty("fruits", "apple, banana, pear, cantaloupe, watermelon, kiwi, mango",
+                propertyString);
+    }
+
+    /**
+     * Checks that a trailing backslash at the end of the single line of input is ignored.
+     * This is similar to a check in {@link #test_loadLjava_io_Reader()} that uses an
+     * InputStream and {@link Properties#equals(Object)} .
+     */
+    public void testSingleProperty_oneLineWithTrailingBackslash() throws Exception {
+        checkSingleProperty("key", "value", "key=value\\");
+    }
+
+    /**
+     * Checks that a trailing backslash at the end of the single line of input is ignored,
+     * even when that line has a newline.
+     */
+    public void testSingleProperty_oneLineWithTrailingBackslash_newline() throws Exception {
+        checkSingleProperty("key", "value", "key=value\\\r");
+        checkSingleProperty("key", "value", "key=value\\\n");
+        checkSingleProperty("key", "value", "key=value\\\r\n");
+    }
+
+    private static void checkSingleProperty(String key, String value, String serialized)
+            throws IOException {
+        Properties properties = new Properties();
+        try (Reader reader = new CharArrayReader(serialized.toCharArray())) {
+            properties.load(reader);
+            assertEquals(Collections.singleton(key), properties.keySet());
+            assertEquals(value, properties.getProperty(key));
+        }
+    }
+
+    /**
      * Sets up the fixture, for example, open a network connection. This method
      * is called before a test is executed.
      */
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java
index 8fae7b8..aa50676 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java
@@ -894,8 +894,8 @@
         SSLEngine sse = getEngine(host, port);
 
         try {
-            // TODO: decide whether OpenSSLEngineImpl should throw ISE (it doesn't) b/31301555
             SSLEngineResult result = sse.wrap(bbs, bbd);
+            fail();
         } catch (IllegalStateException expected) {
         }
     }
@@ -993,8 +993,11 @@
         ByteBuffer[] bbA = { ByteBuffer.allocate(5), ByteBuffer.allocate(10), ByteBuffer.allocate(5) };
         SSLEngine sse = getEngine(host, port);
 
-        SSLEngineResult result = sse.wrap(bbA, bb);
-        assertEquals(Status.BUFFER_OVERFLOW, result.getStatus());
+        try {
+            SSLEngineResult result = sse.wrap(bbA, bb);
+            fail();
+        } catch (IllegalStateException expected) {
+        }
     }
 
     /**
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/security/auth/SubjectTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/security/auth/SubjectTest.java
index f2ef564..6d775ec 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/security/auth/SubjectTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/security/auth/SubjectTest.java
@@ -19,12 +19,18 @@
 
 import junit.framework.TestCase;
 import javax.security.auth.Subject;
+import javax.security.auth.x500.X500Principal;
+
 import java.security.AccessControlContext;
 import java.security.AccessController;
+import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.security.ProtectionDomain;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.harmony.testframework.serialization.SerializationTest;
 
 /**
@@ -48,6 +54,29 @@
         }
     }
 
+    public void test_Constructor_failsWithNullArguments() {
+        try {
+            new Subject(false /* readOnly */,
+                    null /* principals */,
+                    new HashSet<Object>() /* pubCredentials */,
+                    new HashSet<Object>() /* privCredentials */);
+            fail();
+        } catch (NullPointerException expected) {
+        }
+
+        try {
+            new Subject(false , new HashSet<Principal>(), null, new HashSet<Object>());
+            fail();
+        } catch (NullPointerException expected) {
+        }
+
+        try {
+            new Subject(false , new HashSet<Principal>(), new HashSet<Object>(), null);
+            fail();
+        } catch (NullPointerException expected) {
+        }
+    }
+
     /**
      * javax.security.auth.Subject#doAs(Subject subject, PrivilegedAction action)
      */
@@ -234,6 +263,36 @@
         SerializationTest.verifyGolden(this, getSerializationData());
     }
 
+    public void testSerialization_nullPrincipalsAllowed() throws Exception {
+        Set<Principal> principalsSet = new HashSet<>();
+        principalsSet.add(new X500Principal("CN=SomePrincipal"));
+        principalsSet.add(null);
+        principalsSet.add(new X500Principal("CN=SomeOtherPrincipal"));
+        Subject subject = new Subject(
+                false /* readOnly */, principalsSet, new HashSet<Object>(), new HashSet<Object>());
+        SerializationTest.verifySelf(subject);
+    }
+
+    public void testSecureTest_removeAllNull_throwsException() throws Exception {
+        Subject subject = new Subject(
+                false, new HashSet<Principal>(), new HashSet<Object>(), new HashSet<Object>());
+        try {
+            subject.getPrincipals().removeAll(null);
+            fail();
+        } catch (NullPointerException expected) {
+        }
+    }
+
+    public void testSecureTest_retainAllNull_throwsException() throws Exception {
+        Subject subject = new Subject(
+                false, new HashSet<Principal>(), new HashSet<Object>(), new HashSet<Object>());
+        try {
+            subject.getPrincipals().retainAll(null);
+            fail();
+        } catch (NullPointerException expected) {
+        }
+    }
+
     private Object[] getSerializationData() {
         Subject subject = new Subject();
         return new Object[] { subject, subject.getPrincipals(),
diff --git a/libart/src/main/java/java/lang/reflect/AbstractMethod.java b/libart/src/main/java/java/lang/reflect/AbstractMethod.java
deleted file mode 100644
index 73cc60b..0000000
--- a/libart/src/main/java/java/lang/reflect/AbstractMethod.java
+++ /dev/null
@@ -1,310 +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.
- */
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.lang.reflect;
-
-import com.android.dex.Dex;
-
-import java.lang.annotation.Annotation;
-import libcore.reflect.GenericSignatureParser;
-import libcore.reflect.ListOfTypes;
-import libcore.reflect.Types;
-import libcore.util.EmptyArray;
-
-/**
- * This class represents an abstract method. Abstract methods are either methods or constructors.
- * @hide
- */
-public abstract class AbstractMethod extends Executable {
-    /** Bits encoding access (e.g. public, private) as well as other runtime specific flags */
-    @SuppressWarnings("unused") // set by runtime
-    private int accessFlags;
-
-    /**
-     * The ArtMethod associated with this Method, required for dispatching due to entrypoints
-     * Classloader is held live by the declaring class.
-     * Hidden to workaround b/16828157.
-     * @hide
-     */
-    @SuppressWarnings("unused") // set by runtime
-    private long artMethod;
-
-    /** Method's declaring class */
-    @SuppressWarnings("unused") // set by runtime
-    private Class<?> declaringClass;
-
-    /** Overriden method's declaring class (same as declaringClass unless declaringClass
-     * is a proxy class)
-     */
-    @SuppressWarnings("unused") // set by runtime
-    private Class<?> declaringClassOfOverriddenMethod;
-
-    /** The method index of this method within its defining dex file */
-    @SuppressWarnings("unused") // set by runtime
-    private int dexMethodIndex;
-
-    /**
-     * Hidden to workaround b/16828157.
-     * @hide
-     */
-    protected AbstractMethod() {
-    }
-
-    /**
-     * We insert native method stubs for abstract methods so we don't have to
-     * check the access flags at the time of the method call.  This results in
-     * "native abstract" methods, which can't exist.  If we see the "abstract"
-     * flag set, clear the "native" flag.
-     *
-     * We also move the DECLARED_SYNCHRONIZED flag into the SYNCHRONIZED
-     * position, because the callers of this function are trying to convey
-     * the "traditional" meaning of the flags to their callers.
-     */
-    private static int fixMethodFlags(int flags) {
-        if ((flags & Modifier.ABSTRACT) != 0) {
-            flags &= ~Modifier.NATIVE;
-        }
-        flags &= ~Modifier.SYNCHRONIZED;
-        int ACC_DECLARED_SYNCHRONIZED = 0x00020000;
-        if ((flags & ACC_DECLARED_SYNCHRONIZED) != 0) {
-            flags |= Modifier.SYNCHRONIZED;
-        }
-        return flags & 0xffff;  // mask out bits not used by Java
-    }
-
-    // Overrides {@link Executable#getModifiers()} - for ART behavior see fixMethodFlags().
-    @Override
-    public int getModifiers() {
-        return fixMethodFlags(accessFlags);
-    }
-
-    // Overrides {@link Executable#isSynthetic()} - we can do it cheaply here.
-    @Override
-    public boolean isSynthetic() {
-        return (accessFlags & Modifier.SYNTHETIC) != 0;
-    }
-
-    // Overrides {@link Executable#isVarArgs()} - we can do it cheaply here.
-    @Override
-    public boolean isVarArgs() {
-        return (accessFlags & Modifier.VARARGS) != 0;
-    }
-
-    @Override
-    public Class<?> getDeclaringClass() {
-        return declaringClass;
-    }
-
-    /**
-     * Returns an array of {@code Class} objects associated with the parameter types of this
-     * abstract method. If the method was declared with no parameters, an
-     * empty array will be returned.
-     *
-     * @return the parameter types
-     */
-    @Override
-    public Class<?>[] getParameterTypes() {
-        Dex dex = declaringClassOfOverriddenMethod.getDex();
-        short[] types = dex.parameterTypeIndicesFromMethodIndex(dexMethodIndex);
-        if (types.length == 0) {
-            return EmptyArray.CLASS;
-        }
-        Class<?>[] parametersArray = new Class[types.length];
-        for (int i = 0; i < types.length; i++) {
-            // Note, in the case of a Proxy the dex cache types are equal.
-            parametersArray[i] = declaringClassOfOverriddenMethod.getDexCacheType(dex, types[i]);
-        }
-        return parametersArray;
-    }
-
-    @Override
-    public int getParameterCount() {
-        Dex dex = declaringClassOfOverriddenMethod.getDex();
-        short[] types = dex.parameterTypeIndicesFromMethodIndex(dexMethodIndex);
-        return types.length;
-    }
-
-    @Override
-    public Type[] getGenericParameterTypes() {
-        return Types.getTypeArray(
-                getMethodOrConstructorGenericInfoInternal().genericParameterTypes, false);
-    }
-
-    @Override
-    public Type[] getGenericExceptionTypes() {
-        return Types.getTypeArray(
-                getMethodOrConstructorGenericInfoInternal().genericExceptionTypes, false);
-    }
-
-    @Override public native Annotation[] getDeclaredAnnotations();
-
-    @Override public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
-        if (annotationType == null) {
-            throw new NullPointerException("annotationType == null");
-        }
-        return isAnnotationPresentNative(annotationType);
-    }
-    private native boolean isAnnotationPresentNative(Class<? extends Annotation> annotationType);
-
-    @Override
-    public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
-        if (annotationClass == null) {
-            throw new NullPointerException("annotationClass == null");
-        }
-        return getAnnotationNative(annotationClass);
-    }
-    private native <T extends Annotation> T getAnnotationNative(Class<T> annotationClass);
-
-    @Override
-    public Annotation[][] getParameterAnnotations() {
-        Annotation[][] parameterAnnotations = getParameterAnnotationsNative();
-        if (parameterAnnotations == null) {
-            parameterAnnotations = new Annotation[getParameterTypes().length][0];
-        }
-        return parameterAnnotations;
-    }
-    private native Annotation[][] getParameterAnnotationsNative();
-
-    /**
-     * @hide
-     */
-    public final int getAccessFlags() {
-        return accessFlags;
-    }
-
-    static final class GenericInfo {
-        final ListOfTypes genericExceptionTypes;
-        final ListOfTypes genericParameterTypes;
-        final Type genericReturnType;
-        final TypeVariable<?>[] formalTypeParameters;
-
-        GenericInfo(ListOfTypes exceptions, ListOfTypes parameters, Type ret,
-                    TypeVariable<?>[] formal) {
-            genericExceptionTypes = exceptions;
-            genericParameterTypes = parameters;
-            genericReturnType = ret;
-            formalTypeParameters = formal;
-        }
-    }
-
-    boolean hasGenericInformationInternal() {
-        return getSignatureAnnotation() != null;
-    }
-
-    /**
-     * Returns generic information associated with this method/constructor member.
-     */
-    final GenericInfo getMethodOrConstructorGenericInfoInternal() {
-        String signatureAttribute = getSignatureAttribute();
-        Class<?>[] exceptionTypes = this.getExceptionTypes();
-        GenericSignatureParser parser =
-            new GenericSignatureParser(this.getDeclaringClass().getClassLoader());
-        if (this instanceof Method) {
-            parser.parseForMethod(this, signatureAttribute, exceptionTypes);
-        } else {
-            parser.parseForConstructor(this, signatureAttribute, exceptionTypes);
-        }
-        return new GenericInfo(parser.exceptionTypes, parser.parameterTypes,
-                               parser.returnType, parser.formalTypeParameters);
-    }
-
-    private String getSignatureAttribute() {
-        String[] annotation = getSignatureAnnotation();
-        if (annotation == null) {
-            return null;
-        }
-        StringBuilder result = new StringBuilder();
-        for (String s : annotation) {
-            result.append(s);
-        }
-        return result.toString();
-    }
-    private native String[] getSignatureAnnotation();
-
-    final boolean equalNameAndParametersInternal(Method m) {
-        return getName().equals(m.getName()) && equalMethodParameters(m.getParameterTypes());
-    }
-
-    private boolean equalMethodParameters(Class<?>[] params) {
-        Dex dex = declaringClassOfOverriddenMethod.getDex();
-        short[] types = dex.parameterTypeIndicesFromMethodIndex(dexMethodIndex);
-        if (types.length != params.length) {
-            return false;
-        }
-        for (int i = 0; i < types.length; i++) {
-            if (declaringClassOfOverriddenMethod.getDexCacheType(dex, types[i]) != params[i]) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    final int compareMethodParametersInternal(Class<?>[] params) {
-        Dex dex = declaringClassOfOverriddenMethod.getDex();
-        short[] types = dex.parameterTypeIndicesFromMethodIndex(dexMethodIndex);
-        int length = Math.min(types.length, params.length);
-        for (int i = 0; i < length; i++) {
-            Class<?> aType = declaringClassOfOverriddenMethod.getDexCacheType(dex, types[i]);
-            Class<?> bType = params[i];
-            if (aType != bType) {
-                int comparison = aType.getName().compareTo(bType.getName());
-                if (comparison != 0) {
-                    return comparison;
-                }
-            }
-        }
-        return types.length - params.length;
-    }
-
-    final String getMethodNameInternal() {
-        Dex dex = declaringClassOfOverriddenMethod.getDex();
-        int nameIndex = dex.nameIndexFromMethodIndex(dexMethodIndex);
-        return declaringClassOfOverriddenMethod.getDexCacheString(dex, nameIndex);
-    }
-
-    final Class<?> getMethodReturnTypeInternal() {
-        Dex dex = declaringClassOfOverriddenMethod.getDex();
-        int returnTypeIndex = dex.returnTypeIndexFromMethodIndex(dexMethodIndex);
-        // Note, in the case of a Proxy the dex cache types are equal.
-        return declaringClassOfOverriddenMethod.getDexCacheType(dex, returnTypeIndex);
-    }
-
-    /** A cheap implementation for {@link Method#isDefault()}. */
-    final boolean isDefaultMethodInternal() {
-        return (accessFlags & Modifier.DEFAULT) != 0;
-    }
-
-    /** A cheap implementation for {@link Method#isBridge()}. */
-    final boolean isBridgeMethodInternal() {
-        return (accessFlags & Modifier.BRIDGE) != 0;
-    }
-}
diff --git a/luni/src/test/java/libcore/java/io/OldBufferedReaderTest.java b/luni/src/test/java/libcore/java/io/OldBufferedReaderTest.java
index 00c5389..71b9517 100644
--- a/luni/src/test/java/libcore/java/io/OldBufferedReaderTest.java
+++ b/luni/src/test/java/libcore/java/io/OldBufferedReaderTest.java
@@ -393,4 +393,37 @@
         BufferedReader br = new BufferedReader(new InputStreamReader(pis));
         assertEquals("hello, world", br.readLine());
     }
+
+    public void test_closeException() throws Exception {
+        final IOException testException = new IOException("kaboom!");
+        Reader thrower = new Reader() {
+            @Override
+            public int read(char cbuf[], int off, int len) throws IOException {
+                // Not used
+                return 0;
+            }
+
+            @Override
+            public void close() throws IOException {
+                throw testException;
+            }
+        };
+        BufferedReader br = new BufferedReader(thrower);
+
+        try {
+            br.close();
+            fail();
+        } catch(IOException expected) {
+            assertSame(testException, expected);
+        }
+
+        try {
+            // Pre-openJdk8 BufferedReader#close() with exception wouldn't
+            // reset the input reader to null. This would still allow ready()
+            // to succeed.
+            br.ready();
+            fail();
+        } catch(IOException expected) {
+        }
+    }
 }
diff --git a/luni/src/test/java/libcore/java/io/OldBufferedWriterTest.java b/luni/src/test/java/libcore/java/io/OldBufferedWriterTest.java
index ed5b862..5e157d2 100644
--- a/luni/src/test/java/libcore/java/io/OldBufferedWriterTest.java
+++ b/luni/src/test/java/libcore/java/io/OldBufferedWriterTest.java
@@ -17,6 +17,7 @@
 
 package libcore.java.io;
 
+import java.io.Writer;
 import java.io.BufferedWriter;
 import java.io.IOException;
 import tests.support.Support_ASimpleWriter;
@@ -300,6 +301,43 @@
         }
     }
 
+    public void test_closeException() throws Exception {
+        final IOException testException = new IOException("kaboom!");
+        Writer thrower = new Writer() {
+            @Override
+            public void write(char cbuf[], int off, int len) throws IOException {
+                // Not used
+            }
+
+            @Override
+            public void flush() throws IOException {
+                // Not used
+            }
+
+            @Override
+            public void close() throws IOException {
+                throw testException;
+            }
+        };
+        BufferedWriter bw = new BufferedWriter(thrower);
+
+        try {
+            bw.close();
+            fail();
+        } catch(IOException expected) {
+            assertSame(testException, expected);
+        }
+
+        try {
+            // Pre-openJdk8 BufferedWriter#close() with exception wouldn't
+            // reset the output writer to null. This would still allow write()
+            // to succeed.
+            bw.write(1);
+            fail();
+        } catch(IOException expected) {
+        }
+    }
+
     protected void setUp() {
         sw = new Support_StringWriter();
         ssw = new Support_ASimpleWriter(true);
diff --git a/luni/src/test/java/libcore/java/lang/invoke/MethodHandlesTest.java b/luni/src/test/java/libcore/java/lang/invoke/MethodHandlesTest.java
new file mode 100644
index 0000000..33555f7
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/invoke/MethodHandlesTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package libcore.java.lang.invoke;
+
+import junit.framework.TestCase;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.util.Vector;
+
+import static java.lang.invoke.MethodHandles.Lookup.*;
+
+public class MethodHandlesTest extends TestCase {
+    private static final int ALL_LOOKUP_MODES = (PUBLIC | PRIVATE | PACKAGE | PROTECTED);
+
+    public void test_publicLookupClassAndModes() {
+        MethodHandles.Lookup publicLookup = MethodHandles.publicLookup();
+        assertSame(Object.class, publicLookup.lookupClass());
+        assertEquals(PUBLIC, publicLookup.lookupModes());
+    }
+
+    public void test_defaultLookupClassAndModes() {
+        MethodHandles.Lookup defaultLookup = MethodHandles.lookup();
+        assertSame(MethodHandlesTest.class, defaultLookup.lookupClass());
+        assertEquals(ALL_LOOKUP_MODES, defaultLookup.lookupModes());
+    }
+
+    public void test_LookupIn() {
+        MethodHandles.Lookup defaultLookup = MethodHandles.lookup();
+
+        // A class in the same package loses the privilege to lookup protected and private
+        // members.
+        MethodHandles.Lookup siblingLookup = defaultLookup.in(PackageSibling.class);
+        assertEquals(ALL_LOOKUP_MODES & ~(PROTECTED | PRIVATE),  siblingLookup.lookupModes());
+
+        // The new lookup isn't in the same package, so it loses all its privileges except
+        // for public.
+        MethodHandles.Lookup nonSibling = defaultLookup.in(Vector.class);
+        assertEquals(PUBLIC, nonSibling.lookupModes());
+
+        // Special case, sibling inner classes in the same parent class
+        MethodHandles.Lookup inner2 = Inner1.lookup.in(Inner2.class);
+        assertEquals(PUBLIC | PRIVATE | PACKAGE, inner2.lookupModes());
+
+        try {
+            MethodHandles.lookup().in(null);
+            fail();
+        } catch (NullPointerException expected) {
+        }
+
+        // Callers cannot change the lookup context to anything within the java.lang.invoke package.
+        try {
+            MethodHandles.lookup().in(MethodHandle.class);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public static class Inner1 {
+        public static MethodHandles.Lookup lookup = MethodHandles.lookup();
+    }
+
+    public static class Inner2 {
+    }
+}
+
+class PackageSibling {
+}
+
diff --git a/luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java b/luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java
index 3093bbd..8d7ed71 100644
--- a/luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java
+++ b/luni/src/test/java/libcore/java/lang/reflect/ConstructorTest.java
@@ -17,6 +17,8 @@
 package libcore.java.lang.reflect;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Parameter;
+
 import junit.framework.TestCase;
 
 public final class ConstructorTest extends TestCase {
@@ -33,8 +35,12 @@
     }
 
     public void test_getParameterTypes() throws Exception {
-        Class[] expectedParameters = new Class[] { Object.class };
+        Class[] expectedParameters = new Class[0];
         Constructor<?> constructor = ConstructorTestHelper.class.getConstructor(expectedParameters);
+        assertEquals(0, constructor.getParameterTypes().length);
+
+        expectedParameters = new Class[] { Object.class };
+        constructor = ConstructorTestHelper.class.getConstructor(expectedParameters);
         Class[] parameters = constructor.getParameterTypes();
         assertEquals(1, parameters.length);
         assertEquals(expectedParameters[0], parameters[0]);
@@ -46,12 +52,37 @@
     }
 
     public void test_getParameterCount() throws Exception {
-        Class[] expectedParameters = new Class[] { Object.class };
+        Class[] expectedParameters = new Class[0];
         Constructor<?> constructor = ConstructorTestHelper.class.getConstructor(expectedParameters);
+        assertEquals(0, constructor.getParameterCount());
+
+        expectedParameters = new Class[] { Object.class };
+        constructor = ConstructorTestHelper.class.getConstructor(expectedParameters);
         int count = constructor.getParameterCount();
         assertEquals(1, count);
     }
 
+    public void test_getParameters() throws Exception {
+        Class[] expectedParameters = new Class[0];
+        Constructor<?> constructor = ConstructorTestHelper.class.getConstructor(expectedParameters);
+        assertEquals(0, constructor.getParameters().length);
+
+        expectedParameters = new Class[] { Object.class };
+        constructor = ConstructorTestHelper.class.getConstructor(expectedParameters);
+
+        // Test the information available via other Constructor methods. See ParameterTest and
+        // annotations.ParameterTest for more in-depth Parameter testing.
+        Parameter[] parameters = constructor.getParameters();
+        assertEquals(1, parameters.length);
+        assertEquals(Object.class, parameters[0].getType());
+
+        // Check that corrupting our array doesn't affect other callers.
+        parameters[0] = null;
+        parameters = constructor.getParameters();
+        assertEquals(1, parameters.length);
+        assertEquals(Object.class, parameters[0].getType());
+    }
+
     public void testGetConstructorWithNullArgumentsArray() throws Exception {
         Constructor<?> constructor = ConstructorTestHelper.class.getConstructor((Class[]) null);
         assertEquals(0, constructor.getParameterTypes().length);
diff --git a/luni/src/test/java/libcore/java/lang/reflect/MethodTest.java b/luni/src/test/java/libcore/java/lang/reflect/MethodTest.java
index 5cb88d6..315a885 100644
--- a/luni/src/test/java/libcore/java/lang/reflect/MethodTest.java
+++ b/luni/src/test/java/libcore/java/lang/reflect/MethodTest.java
@@ -19,6 +19,7 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.Parameter;
 import java.lang.reflect.Proxy;
 import java.util.Collections;
 import java.util.Comparator;
@@ -41,8 +42,12 @@
     }
 
     public void test_getParameterTypes() throws Exception {
-        Class[] expectedParameters = new Class[] { Object.class };
-        Method method = MethodTestHelper.class.getMethod("m2", expectedParameters);
+        Class[] expectedParameters = new Class[0];
+        Method method = MethodTestHelper.class.getMethod("m1", expectedParameters);
+        assertEquals(0, method.getParameterTypes().length);
+
+        expectedParameters = new Class[] { Object.class };
+        method = MethodTestHelper.class.getMethod("m2", expectedParameters);
         Class[] parameters = method.getParameterTypes();
         assertEquals(1, parameters.length);
         assertEquals(expectedParameters[0], parameters[0]);
@@ -54,12 +59,37 @@
     }
 
     public void test_getParameterCount() throws Exception {
-        Class[] expectedParameters = new Class[] { Object.class };
-        Method method = MethodTestHelper.class.getMethod("m2", expectedParameters);
+        Class[] expectedParameters = new Class[0];
+        Method method = MethodTestHelper.class.getMethod("m1", expectedParameters);
+        assertEquals(0, method.getParameterCount());
+
+        expectedParameters = new Class[] { Object.class };
+        method = MethodTestHelper.class.getMethod("m2", expectedParameters);
         int count = method.getParameterCount();
         assertEquals(1, count);
     }
 
+    public void test_getParameters() throws Exception {
+        Class[] expectedParameters = new Class[0];
+        Method method = MethodTestHelper.class.getMethod("m1", expectedParameters);
+        assertEquals(0, method.getParameters().length);
+
+        expectedParameters = new Class[] { Object.class };
+        method = MethodTestHelper.class.getMethod("m2", expectedParameters);
+
+        // Test the information available via other Method methods. See ParameterTest and
+        // annotations.ParameterTest for more in-depth Parameter testing.
+        Parameter[] parameters = method.getParameters();
+        assertEquals(1, parameters.length);
+        assertEquals(Object.class, parameters[0].getType());
+
+        // Check that corrupting our array doesn't affect other callers.
+        parameters[0] = null;
+        parameters = method.getParameters();
+        assertEquals(1, parameters.length);
+        assertEquals(Object.class, parameters[0].getType());
+    }
+
     public void testGetMethodWithPrivateMethodAndInterfaceMethod() throws Exception {
         assertEquals(InterfaceA.class, Sub.class.getMethod("a").getDeclaringClass());
     }
diff --git a/luni/src/test/java/libcore/java/lang/reflect/ParameterTest.java b/luni/src/test/java/libcore/java/lang/reflect/ParameterTest.java
new file mode 100644
index 0000000..d5ff5b5
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/reflect/ParameterTest.java
@@ -0,0 +1,671 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang.reflect;
+
+import junit.framework.TestCase;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+import java.util.function.Function;
+
+/**
+ * Tests for {@link Parameter}. For annotation-related tests see
+ * {@link libcore.java.lang.reflect.annotations.AnnotatedElementParameterTest} and
+ * {@link libcore.java.lang.reflect.annotations.ExecutableParameterTest}.
+ */
+public class ParameterTest extends TestCase {
+
+    /**
+     * A source annotation used to mark tests below with behavior that is highly dependent on
+     * parameter metadata. It is intended to bring readers here for the following:
+     *
+     * <p>Unless the compiler supports (and is configured to enable) storage of metadata
+     * for parameters, the runtime does not have access to the parameter name from the source and
+     * some modifier information like "implicit" (AKA "mandated"), "synthetic" and "final".
+     * These tests are currently expected to be compiled without requesting the metadata and can
+     * only test the negative case without the metadata present (the expected, common case).
+     */
+    @Retention(RetentionPolicy.SOURCE)
+    @Target(ElementType.METHOD)
+    private @interface DependsOnParameterMetadata {}
+
+    private static class SingleParameter {
+        @SuppressWarnings("unused")
+        SingleParameter(String p0) {}
+
+        @SuppressWarnings("unused")
+        void oneParameter(String p0) {}
+    }
+
+    public void testSingleParameterConstructor() throws Exception {
+        Constructor<?> constructor = SingleParameter.class.getDeclaredConstructor(String.class);
+        checkSingleStringParameter(constructor);
+    }
+
+    public void testSingleParameterMethod() throws Exception {
+        Method method = SingleParameter.class.getDeclaredMethod("oneParameter", String.class);
+        checkSingleStringParameter(method);
+    }
+
+    private static void checkSingleStringParameter(Executable executable) {
+        ExecutableTestHelper helper = new ExecutableTestHelper(executable);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[java.lang.String arg0]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(String.class)
+                .checkGetParameterizedType("class java.lang.String");
+    }
+
+    private static class GenericParameter {
+        @SuppressWarnings("unused")
+        GenericParameter(Function<String, Integer> p0) {}
+
+        @SuppressWarnings("unused")
+        void genericParameter(Function<String, Integer> p0) {}
+    }
+
+    public void testGenericParameterConstructor() throws Exception {
+        Constructor<?> constructor = GenericParameter.class.getDeclaredConstructor(Function.class);
+        checkGenericParameter(constructor);
+    }
+
+    public void testGenericParameterMethod() throws Exception {
+        Method method = GenericParameter.class.getDeclaredMethod(
+                "genericParameter", Function.class);
+        checkGenericParameter(method);
+    }
+
+    private static void checkGenericParameter(Executable executable) {
+        ExecutableTestHelper helper = new ExecutableTestHelper(executable);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString(
+                        "[java.util.function.Function<java.lang.String, java.lang.Integer> arg0]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(Function.class)
+                .checkGetParameterizedType(
+                        "java.util.function.Function<java.lang.String, java.lang.Integer>");
+    }
+
+    private static class TwoParameters {
+        @SuppressWarnings("unused")
+        TwoParameters(String p0, Integer p1) {}
+        @SuppressWarnings("unused")
+        void twoParameters(String p0, Integer p1) {}
+    }
+
+    public void testTwoParameterConstructor() throws Exception {
+        Constructor<?> constructor =
+                TwoParameters.class.getDeclaredConstructor(String.class, Integer.class);
+        checkTwoParameters(constructor);
+    }
+
+    public void testTwoParameterMethod() throws Exception {
+        Method method = TwoParameters.class.getDeclaredMethod(
+                "twoParameters", String.class, Integer.class);
+        checkTwoParameters(method);
+    }
+
+    private static void checkTwoParameters(Executable executable) {
+        ExecutableTestHelper helper = new ExecutableTestHelper(executable);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[java.lang.String arg0, java.lang.Integer arg1]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(String.class)
+                .checkGetParameterizedType("class java.lang.String");
+
+        helper.getParameterTestHelper(1)
+                .checkGetType(Integer.class)
+                .checkGetParameterizedType("class java.lang.Integer");
+    }
+
+    private static class FinalParameter {
+        @SuppressWarnings("unused")
+        FinalParameter(final String p0) {}
+        @SuppressWarnings("unused")
+        void finalParameter(final String p0) {}
+    }
+
+    public void testFinalParameterConstructor() throws Exception {
+        Constructor<?> constructor = FinalParameter.class.getDeclaredConstructor(String.class);
+        checkFinalParameter(constructor);
+    }
+
+    public void testFinalParameterMethod() throws Exception {
+        Method method = FinalParameter.class.getDeclaredMethod("finalParameter", String.class);
+        checkFinalParameter(method);
+    }
+
+    private static void checkFinalParameter(Executable executable) {
+        ExecutableTestHelper helper = new ExecutableTestHelper(executable);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[java.lang.String arg0]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(String.class)
+                .checkGetParameterizedType("class java.lang.String");
+
+        // If parameter metadata were included, this would be the expected:
+        // helper.getParameterTestHelper(0).checkModifiers(Modifier.FINAL);
+    }
+
+    /**
+     * An inner class, used for checking compiler-inserted parameters: The first parameter is an
+     * instance of the surrounding class.
+     */
+    private class InnerClass {
+        @SuppressWarnings("unused")
+        public InnerClass() {}
+        @SuppressWarnings("unused")
+        public InnerClass(String p1) {}
+        @SuppressWarnings("unused")
+        public InnerClass(Function<String, Integer> p1) {}
+    }
+
+    public void testInnerClassSingleParameter() throws Exception {
+        Constructor<?> constructor =
+                InnerClass.class.getDeclaredConstructor(ParameterTest.class);
+
+        ExecutableTestHelper helper = new ExecutableTestHelper(constructor);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[libcore.java.lang.reflect.ParameterTest arg0]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(ParameterTest.class)
+                .checkGetParameterizedType("class libcore.java.lang.reflect.ParameterTest");
+
+        // If parameter metadata were included, this would be the expected:
+        // helper.getParameterTestHelper(0)
+        //         .checkModifiers(32784)
+        //         .checkImplicitAndSynthetic(true, false);
+        // i.e. 32784 == Modifier.MANDATED & Modifier.FINAL
+    }
+
+    public void testInnerClassTwoParameters() throws Exception {
+        Constructor<?> constructor =
+                InnerClass.class.getDeclaredConstructor(ParameterTest.class, String.class);
+
+        ExecutableTestHelper helper = new ExecutableTestHelper(constructor);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString(
+                        "[libcore.java.lang.reflect.ParameterTest arg0, java.lang.String arg1]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(ParameterTest.class)
+                .checkGetParameterizedType("class libcore.java.lang.reflect.ParameterTest");
+
+        // If parameter metadata were included, this would be the expected:
+        // helper.getParameterTestHelper(0)
+        //         .checkModifiers(32784)
+        //         .checkImplicitAndSynthetic(true, false);
+        // i.e. 32784 == Modifier.MANDATED & Modifier.FINAL
+
+
+        helper.getParameterTestHelper(1)
+                .checkGetType(String.class)
+                .checkGetParameterizedType("class java.lang.String");
+    }
+
+    public void testInnerClassGenericParameter() throws Exception {
+        Constructor<?> constructor =
+                InnerClass.class.getDeclaredConstructor(
+                        ParameterTest.class, Function.class);
+
+        ExecutableTestHelper helper = new ExecutableTestHelper(constructor);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString(
+                        "[libcore.java.lang.reflect.ParameterTest arg0, "
+                                + "java.util.function.Function arg1]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(ParameterTest.class)
+                .checkGetParameterizedType("class libcore.java.lang.reflect.ParameterTest");
+
+        // If parameter metadata were included, this would be the expected:
+        // helper.getParameterTestHelper(0)
+        //         .checkModifiers(32784)
+        //         .checkImplicitAndSynthetic(true, false);
+        // i.e. 32784 == Modifier.MANDATED & Modifier.FINAL
+
+        helper.getParameterTestHelper(1)
+                .checkGetType(Function.class)
+                .checkGetParameterizedType("interface java.util.function.Function");
+
+        // The non-genericised string above is probably the result of a bug due to a mismatch
+        // between the generic signature for the constructor (which suggests a single parameter)
+        // and the actual parameters (which suggests two).
+    }
+
+    @SuppressWarnings("unused")
+    enum TestEnum { ONE, TWO }
+
+    /**
+     * Enums are a documented example of a type of class with synthetic constructor parameters and
+     * generated methods. This test may be brittle as it may rely on the compiler's implementation
+     * of enums.
+     */
+    @DependsOnParameterMetadata
+    public void testEnumConstructor() throws Exception {
+        Constructor<?> constructor = TestEnum.class.getDeclaredConstructor(String.class, int.class);
+
+        ExecutableTestHelper helper = new ExecutableTestHelper(constructor);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[java.lang.String arg0, int arg1]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(String.class)
+                .checkGetParameterizedType("class java.lang.String");
+
+        // If parameter metadata were included, this would be the expected:
+        // helper.getParameterTestHelper(0)
+        //         .checkModifiers(4096)
+        //         .checkImplicitAndSynthetic(false, true);
+        // i.e. 4096 == Modifier.SYNTHETIC
+
+        helper.getParameterTestHelper(1)
+                .checkGetType(int.class)
+                .checkGetParameterizedType("int");
+    }
+
+    public void testEnumValueOf() throws Exception {
+        Method method = TestEnum.class.getDeclaredMethod("valueOf", String.class);
+
+        ExecutableTestHelper helper = new ExecutableTestHelper(method);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[java.lang.String arg0]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(String.class)
+                .checkGetParameterizedType("class java.lang.String");
+
+        // If parameter metadata were included, this would be the expected:
+        // helper.getParameterTestHelper(0)
+        //         .checkModifiers(32768)
+        //         .checkImplicitAndSynthetic(true, false);
+        // i.e. 32768 == Modifier.MANDATED
+    }
+
+    private static class SingleVarArgs {
+        @SuppressWarnings("unused")
+        SingleVarArgs(String... p0) {}
+
+        @SuppressWarnings("unused")
+        void varArgs(String... p0) {}
+    }
+
+    public void testSingleVarArgsConstructor() throws Exception {
+        Constructor<?> constructor = SingleVarArgs.class.getDeclaredConstructor(String[].class);
+        checkSingleVarArgsParameter(constructor);
+    }
+
+    public void testSingleVarArgsMethod() throws Exception {
+        Method method = SingleVarArgs.class.getDeclaredMethod("varArgs", String[].class);
+        checkSingleVarArgsParameter(method);
+    }
+
+    private static void checkSingleVarArgsParameter(Executable executable) {
+        ExecutableTestHelper helper = new ExecutableTestHelper(executable);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[java.lang.String... arg0]")
+                .checkParametersMetadataNotAvailable();
+
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(String[].class)
+                .checkIsVarArg(true)
+                .checkGetParameterizedType("class [Ljava.lang.String;");
+    }
+
+    private static class MixedVarArgs {
+        @SuppressWarnings("unused")
+        MixedVarArgs(Integer[] p0, String... p1) {}
+        @SuppressWarnings("unused")
+        void both(Integer[] p0, String... p1) {}
+    }
+
+    public void testMixedVarArgsConstructor() throws Exception {
+        Constructor<?> constructor =
+                MixedVarArgs.class.getDeclaredConstructor(Integer[].class, String[].class);
+        checkMixedVarArgsParameter(constructor);
+    }
+
+    public void testMixedVarArgsMethod() throws Exception {
+        Method method = MixedVarArgs.class.getDeclaredMethod("both", Integer[].class, String[].class);
+        checkMixedVarArgsParameter(method);
+    }
+
+    private static void checkMixedVarArgsParameter(Executable executable) {
+        ExecutableTestHelper helper = new ExecutableTestHelper(executable);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[java.lang.Integer[] arg0, java.lang.String... arg1]")
+                .checkParametersMetadataNotAvailable();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(Integer[].class)
+                .checkIsVarArg(false)
+                .checkGetParameterizedType("class [Ljava.lang.Integer;");
+
+        helper.getParameterTestHelper(1)
+                .checkGetType(String[].class)
+                .checkIsVarArg(true)
+                .checkGetParameterizedType("class [Ljava.lang.String;");
+    }
+
+    private static class NonVarArgs {
+        @SuppressWarnings("unused")
+        NonVarArgs(Integer[] p0) {}
+        @SuppressWarnings("unused")
+        void notVarArgs(Integer[] p0) {}
+    }
+
+    public void testNonVarsArgsConstructor() throws Exception {
+        Constructor<?> constructor = NonVarArgs.class.getDeclaredConstructor(Integer[].class);
+        checkNonVarsArgsParameter(constructor);
+    }
+
+    public void testNonVarsArgsMethod() throws Exception {
+        Method method = NonVarArgs.class.getDeclaredMethod("notVarArgs", Integer[].class);
+        checkNonVarsArgsParameter(method);
+    }
+
+    private static void checkNonVarsArgsParameter(Executable executable) {
+        ExecutableTestHelper helper = new ExecutableTestHelper(executable);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[java.lang.Integer[] arg0]")
+                .checkParametersMetadataNotAvailable();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(Integer[].class)
+                .checkIsVarArg(false)
+                .checkGetParameterizedType("class [Ljava.lang.Integer;");
+    }
+
+    public void testAnonymousClassConstructor() throws Exception {
+        Class<?> clazz = getAnonymousClassWith1ParameterConstructor();
+        Constructor<?> constructor = clazz.getDeclaredConstructor(ParameterTest.class);
+
+        ExecutableTestHelper helper = new ExecutableTestHelper(constructor);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[libcore.java.lang.reflect.ParameterTest arg0]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(ParameterTest.class)
+                .checkGetParameterizedType("class libcore.java.lang.reflect.ParameterTest");
+
+        // If parameter metadata were included, this would be the expected:
+        // helper.getParameterTestHelper(0)
+        //         .checkModifiers(32784)
+        //         .checkImplicitAndSynthetic(true, false);
+        // i.e. 32784 == Modifier.MANDATED & Modifier.FINAL
+    }
+
+    private Class<?> getAnonymousClassWith1ParameterConstructor() {
+        // Deliberately not implemented with a lambda. Do not refactor.
+        Callable<String> anonymousClassObject = new Callable<String>() {
+            @Override
+            public String call() throws Exception {
+                return ParameterTest.this.outerClassMethod();
+            }
+        };
+        return anonymousClassObject.getClass();
+    }
+
+    public void testMethodClassConstructor() throws Exception {
+        Class<?> clazz = getMethodClassWith1ImplicitParameterConstructor();
+        Constructor<?> constructor = clazz.getDeclaredConstructor(ParameterTest.class);
+
+        ExecutableTestHelper helper = new ExecutableTestHelper(constructor);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[libcore.java.lang.reflect.ParameterTest arg0]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(ParameterTest.class)
+                .checkGetParameterizedType("class libcore.java.lang.reflect.ParameterTest");
+
+        // If parameter metadata were included, this would be the expected:
+        // helper.getParameterTestHelper(0)
+        //         .checkModifiers(32784)
+        //         .checkImplicitAndSynthetic(true, false);
+        // i.e. 32784 == Modifier.MANDATED & Modifier.FINAL
+    }
+
+    private Class<?> getMethodClassWith1ImplicitParameterConstructor() {
+        class MethodClass {
+            MethodClass() {
+                ParameterTest.this.outerClassMethod();
+            }
+        }
+        return MethodClass.class;
+    }
+
+    // This behavior is likely to be quite brittle and may not be specified.
+    public void testLambdaClassConstructor() throws Exception {
+        Class<?> anonymousClass = getLambdaClassWith1ParameterConstructor();
+        Constructor<?> constructor = anonymousClass.getDeclaredConstructor(ParameterTest.class);
+
+        ExecutableTestHelper helper = new ExecutableTestHelper(constructor);
+        helper.checkStandardParametersBehavior()
+                .checkParametersToString("[libcore.java.lang.reflect.ParameterTest arg0]")
+                .checkParametersMetadataNotAvailable()
+                .checkParametersNoVarArgs();
+
+        helper.getParameterTestHelper(0)
+                .checkGetType(ParameterTest.class)
+                .checkGetParameterizedType("class libcore.java.lang.reflect.ParameterTest");
+
+        // Unclear what the implicit / synthetic parameter behavior should be.
+    }
+
+    private Class<?> getLambdaClassWith1ParameterConstructor() {
+        return ((Callable<String>) ParameterTest.this::outerClassMethod).getClass();
+    }
+
+    private static class NonIdenticalParameters {
+        void method0(String p1) {}
+        void method1(String p1) {}
+    }
+
+    public void testEquals_checksExecutable() throws Exception {
+        Method method0 = NonIdenticalParameters.class.getDeclaredMethod("method0", String.class);
+        Method method1 = NonIdenticalParameters.class.getDeclaredMethod("method1", String.class);
+        Parameter method0P0 = method0.getParameters()[0];
+        Parameter method1P0 = method1.getParameters()[0];
+        assertFalse(method0P0.equals(method1P0));
+        assertFalse(method1P0.equals(method0P0));
+        assertTrue(method0P0.equals(method0P0));
+    }
+
+    /** A non-static method that exists to be called by inner classes, lambdas, etc. */
+    private String outerClassMethod() {
+        return "Howdy";
+    }
+
+    private static class ExecutableTestHelper {
+        private final Executable executable;
+
+        ExecutableTestHelper(Executable executable) {
+            this.executable = executable;
+        }
+
+        ExecutableTestHelper checkParametersToString(String expectedString) {
+            assertEquals(expectedString, Arrays.toString(executable.getParameters()));
+            return this;
+        }
+
+        /**
+         * Combines checks that should be true of any result from
+         * {@link Executable#getParameters()}
+         */
+        ExecutableTestHelper checkStandardParametersBehavior() {
+            return checkGetParametersClonesArray()
+                    .checkParametersGetDeclaringExecutable()
+                    .checkParametersEquals()
+                    .checkParametersHashcode();
+        }
+
+        ExecutableTestHelper checkParametersGetDeclaringExecutable() {
+            for (Parameter p : executable.getParameters()) {
+                assertSame(executable, p.getDeclaringExecutable());
+            }
+            return this;
+        }
+
+        ExecutableTestHelper checkGetParametersClonesArray() {
+            Parameter[] parameters1 = executable.getParameters();
+            Parameter[] parameters2 = executable.getParameters();
+            assertNotSame(parameters1, parameters2);
+
+            assertEquals(parameters1.length, parameters2.length);
+            for (int i = 0; i < parameters1.length; i++) {
+                assertSame(parameters1[i], parameters2[i]);
+            }
+            return this;
+        }
+
+        ExecutableTestHelper checkParametersEquals() {
+            Parameter[] parameters = executable.getParameters();
+            for (int i = 0; i < parameters.length; i++) {
+                assertEquals(parameters[i], parameters[i]);
+                if (i > 0) {
+                    assertFalse(parameters[0].equals(parameters[i]));
+                    assertFalse(parameters[i].equals(parameters[0]));
+                }
+            }
+            return this;
+        }
+
+        ExecutableTestHelper checkParametersHashcode() {
+            for (Parameter parameter : executable.getParameters()) {
+                // Not much to assert. Just call the method and check it is consistent.
+                assertEquals(parameter.hashCode(), parameter.hashCode());
+            }
+            return this;
+        }
+
+        @DependsOnParameterMetadata
+        ExecutableTestHelper checkParametersMetadataNotAvailable() {
+            ParameterTestHelper[] parameterTestHelpers = getParameterTestHelpers();
+            for (int i = 0; i < parameterTestHelpers.length; i++) {
+                ParameterTestHelper parameterTestHelper = parameterTestHelpers[i];
+                parameterTestHelper.checkName(false, "arg" + i)
+                        .checkImplicitAndSynthetic(false, false)
+                        .checkModifiers(0);
+            }
+            return this;
+        }
+
+        /**
+         * Checks that non of the parameters return {@code true} for {@link Parameter#isVarArgs()}.
+         */
+        ExecutableTestHelper checkParametersNoVarArgs() {
+            for (ParameterTestHelper parameterTestHelper : getParameterTestHelpers()) {
+                parameterTestHelper.checkIsVarArg(false);
+            }
+            return this;
+        }
+
+        ParameterTestHelper getParameterTestHelper(int index) {
+            return new ParameterTestHelper(executable.getParameters()[index]);
+        }
+
+        private ParameterTestHelper[] getParameterTestHelpers() {
+            final int parameterCount = executable.getParameterCount();
+            ParameterTestHelper[] parameterTestHelpers = new ParameterTestHelper[parameterCount];
+            for (int i = 0; i < parameterCount; i++) {
+                parameterTestHelpers[i] = getParameterTestHelper(i);
+            }
+            return parameterTestHelpers;
+        }
+
+        private static class ParameterTestHelper {
+            private final Parameter parameter;
+
+            ParameterTestHelper(Parameter parameter) {
+                this.parameter = parameter;
+            }
+
+            ParameterTestHelper checkGetType(Class<?> expectedType) {
+                assertEquals(expectedType, parameter.getType());
+                return this;
+            }
+
+            @DependsOnParameterMetadata
+            ParameterTestHelper checkName(boolean expectedIsNamePresent, String expectedName) {
+                assertEquals(expectedIsNamePresent, parameter.isNamePresent());
+                assertEquals(expectedName, parameter.getName());
+                return this;
+            }
+
+            @DependsOnParameterMetadata
+            ParameterTestHelper checkModifiers(int expectedModifiers) {
+                assertEquals(expectedModifiers, parameter.getModifiers());
+                return this;
+            }
+
+            ParameterTestHelper checkGetParameterizedType(String expectedParameterizedTypeString) {
+                assertEquals(
+                        expectedParameterizedTypeString,
+                        parameter.getParameterizedType().toString());
+                return this;
+            }
+
+            ParameterTestHelper checkImplicitAndSynthetic(
+                    boolean expectedIsImplicit, boolean expectedIsSynthetic) {
+                assertEquals(expectedIsImplicit, parameter.isImplicit());
+                assertEquals(expectedIsSynthetic, parameter.isSynthetic());
+                return this;
+            }
+
+            ParameterTestHelper checkIsVarArg(boolean expectedIsVarArg) {
+                assertEquals(expectedIsVarArg, parameter.isVarArgs());
+                return this;
+            }
+        }
+    }
+}
diff --git a/luni/src/test/java/libcore/java/lang/reflect/annotations/AnnotatedElementParameterTest.java b/luni/src/test/java/libcore/java/lang/reflect/annotations/AnnotatedElementParameterTest.java
new file mode 100644
index 0000000..aa14bd3
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/reflect/annotations/AnnotatedElementParameterTest.java
@@ -0,0 +1,456 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang.reflect.annotations;
+
+import junit.framework.TestCase;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationB;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationC;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationD;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.Container;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.Repeated;
+
+import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.EXPECT_EMPTY;
+import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.assertGetDeclaredAnnotation;
+import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.assertIsAnnotationPresent;
+import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.checkAnnotatedElementPresentMethods;
+
+/**
+ * Tests for the {@link java.lang.reflect.AnnotatedElement} methods from the {@link Parameter}
+ * objects obtained from both {@link Constructor} and {@link Method}.
+ */
+public class AnnotatedElementParameterTest extends TestCase {
+
+    private static class MethodClass {
+        public void methodWithoutAnnotatedParameters(String parameter1, String parameter2) {}
+
+        public void methodWithAnnotatedParameters(@AnnotationB @AnnotationD String parameter1,
+                @AnnotationC @AnnotationD String parameter2) {}
+    }
+
+    public void testMethodParameterAnnotations() throws Exception {
+        Class<?> c = MethodClass.class;
+        {
+            Parameter[] parameters = c.getDeclaredMethod(
+                    "methodWithoutAnnotatedParameters", String.class, String.class).getParameters();
+            Parameter parameter0 = parameters[0];
+            checkAnnotatedElementPresentMethods(parameter0);
+
+            Parameter parameter1 = parameters[1];
+            checkAnnotatedElementPresentMethods(parameter1);
+        }
+        {
+            Parameter[] parameters = c.getDeclaredMethod(
+                    "methodWithAnnotatedParameters", String.class, String.class).getParameters();
+
+            Parameter parameter0 = parameters[0];
+            checkAnnotatedElementPresentMethods(parameter0, AnnotationB.class, AnnotationD.class);
+
+            Parameter parameter1 = parameters[1];
+            checkAnnotatedElementPresentMethods(parameter1, AnnotationC.class, AnnotationD.class);
+        }
+    }
+
+    private static class ConstructorClass {
+        // No annotations.
+        public ConstructorClass(Integer parameter1, Integer parameter2) {}
+
+        // Annotations.
+        public ConstructorClass(@AnnotationB @AnnotationD String parameter1,
+                @AnnotationC @AnnotationD String parameter2) {}
+    }
+
+    public void testConstructorParameterAnnotations() throws Exception {
+        Class<?> c = ConstructorClass.class;
+        {
+            Parameter[] parameters =
+                    c.getDeclaredConstructor(Integer.class, Integer.class).getParameters();
+            Parameter parameter0 = parameters[0];
+            checkAnnotatedElementPresentMethods(parameter0);
+
+            Parameter parameter1 = parameters[1];
+            checkAnnotatedElementPresentMethods(parameter1);
+        }
+        {
+            Parameter[] parameters =
+                    c.getDeclaredConstructor(String.class, String.class).getParameters();
+
+            Parameter parameter0 = parameters[0];
+            checkAnnotatedElementPresentMethods(parameter0, AnnotationB.class, AnnotationD.class);
+
+            Parameter parameter1 = parameters[1];
+            checkAnnotatedElementPresentMethods(parameter1, AnnotationC.class, AnnotationD.class);
+        }
+    }
+
+    private static class AnnotatedMethodClass {
+        void noAnnotation(String p0) {}
+
+        void multipleAnnotationOddity(
+                @Repeated(1) @Container({@Repeated(2), @Repeated(3)}) String p0) {}
+
+        void multipleAnnotationExplicitSingle(@Container({@Repeated(1)}) String p0) {}
+
+        void multipleAnnotation(@Repeated(1) @Repeated(2) String p0) {}
+
+        void singleAnnotation(@Repeated(1) String p0) {}
+
+        static Method getMethodWithoutAnnotations() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod("noAnnotation", String.class);
+        }
+
+        static Method getMethodMultipleAnnotationOddity() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod(
+                    "multipleAnnotationOddity", String.class);
+        }
+
+        static Method getMethodMultipleAnnotationExplicitSingle() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod(
+                    "multipleAnnotationExplicitSingle", String.class);
+        }
+
+        static Method getMethodMultipleAnnotation() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod("multipleAnnotation", String.class);
+        }
+
+        static Method getMethodSingleAnnotation() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod("singleAnnotation", String.class);
+        }
+    }
+
+    // Tests for isAnnotationPresent and getDeclaredAnnotation.
+    public void testMethodDeclaredAnnotation() throws Exception {
+        Class<? extends Annotation> repeated = Repeated.class;
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodWithoutAnnotations(),
+                repeated, null);
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodMultipleAnnotationOddity(),
+                repeated, "@Repeated(1)");
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodMultipleAnnotationExplicitSingle(),
+                repeated, null);
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodMultipleAnnotation(),
+                repeated, null);
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodSingleAnnotation(),
+                repeated, "@Repeated(1)");
+
+        Class<? extends Annotation> container = Container.class;
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodWithoutAnnotations(),
+                container, null);
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodMultipleAnnotationOddity(),
+                container, "@Container({@Repeated(2), @Repeated(3)})");
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodMultipleAnnotationExplicitSingle(),
+                container, "@Container({@Repeated(1)})");
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodMultipleAnnotation(),
+                container, "@Container({@Repeated(1), @Repeated(2)})");
+        checkParameter0DeclaredAnnotation(
+                AnnotatedMethodClass.getMethodSingleAnnotation(),
+                container, null);
+    }
+
+    private static class AnnotatedConstructorClass {
+        public AnnotatedConstructorClass(Boolean p0) {}
+
+        public AnnotatedConstructorClass(
+                @Repeated(1) @Container({@Repeated(2), @Repeated(3)}) Long p0) {}
+
+        public AnnotatedConstructorClass(@Container({@Repeated(1)}) Double p0) {}
+
+        public AnnotatedConstructorClass(@Repeated(1) @Repeated(2) Integer p0) {}
+
+        public AnnotatedConstructorClass(@Repeated(1) String p0) {}
+
+        static Constructor<?> getConstructorWithoutAnnotations() throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(Boolean.class);
+        }
+
+        static Constructor<?> getConstructorMultipleAnnotationOddity() throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(Long.class);
+        }
+
+        static Constructor<?> getConstructorMultipleAnnotationExplicitSingle()
+                throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(Double.class);
+        }
+
+        static Constructor<?> getConstructorSingleAnnotation() throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(String.class);
+        }
+
+        static Constructor<?> getConstructorMultipleAnnotation() throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(Integer.class);
+        }
+    }
+
+    // Tests for isAnnotationPresent and getDeclaredAnnotation.
+    public void testConstructorDeclaredAnnotation() throws Exception {
+        Class<? extends Annotation> repeated = Repeated.class;
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorWithoutAnnotations(),
+                repeated, null);
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationOddity(),
+                repeated, "@Repeated(1)");
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationExplicitSingle(),
+                repeated, null);
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotation(),
+                repeated, null);
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorSingleAnnotation(),
+                repeated, "@Repeated(1)");
+
+        Class<? extends Annotation> container = Container.class;
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorWithoutAnnotations(),
+                container, null);
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationOddity(),
+                container, "@Container({@Repeated(2), @Repeated(3)})");
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationExplicitSingle(),
+                container, "@Container({@Repeated(1)})");
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotation(),
+                container, "@Container({@Repeated(1), @Repeated(2)})");
+        checkParameter0DeclaredAnnotation(
+                AnnotatedConstructorClass.getConstructorSingleAnnotation(),
+                container, null);
+    }
+
+    private static void checkParameter0DeclaredAnnotation(
+            Executable executable, Class<? extends Annotation> annotationType,
+            String expectedAnnotationString) throws Exception {
+        Parameter parameter = executable.getParameters()[0];
+
+        // isAnnotationPresent
+        assertIsAnnotationPresent(parameter, annotationType, expectedAnnotationString != null);
+
+        // getDeclaredAnnotation
+        assertGetDeclaredAnnotation(parameter, annotationType, expectedAnnotationString);
+    }
+
+    public void testMethodGetDeclaredAnnotationsByType() throws Exception {
+        Class<? extends Annotation> repeated = Repeated.class;
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodWithoutAnnotations(),
+                repeated, EXPECT_EMPTY);
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotationOddity(),
+                repeated, "@Repeated(1)", "@Repeated(2)", "@Repeated(3)");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotationExplicitSingle(),
+                repeated, "@Repeated(1)");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotation(),
+                repeated, "@Repeated(1)", "@Repeated(2)");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodSingleAnnotation(),
+                repeated, "@Repeated(1)");
+
+        Class<? extends Annotation> container = Container.class;
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodWithoutAnnotations(),
+                container, EXPECT_EMPTY);
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotationOddity(),
+                container, "@Container({@Repeated(2), @Repeated(3)})");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotationExplicitSingle(),
+                container, "@Container({@Repeated(1)})");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotation(),
+                container, "@Container({@Repeated(1), @Repeated(2)})");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedMethodClass.getMethodSingleAnnotation(),
+                container, EXPECT_EMPTY);
+    }
+
+    public void testConstructorGetDeclaredAnnotationsByType() throws Exception {
+        Class<? extends Annotation> repeated = Repeated.class;
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorWithoutAnnotations(),
+                repeated, EXPECT_EMPTY);
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationOddity(),
+                repeated, "@Repeated(1)", "@Repeated(2)", "@Repeated(3)");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationExplicitSingle(),
+                repeated, "@Repeated(1)");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotation(),
+                repeated, "@Repeated(1)", "@Repeated(2)");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorSingleAnnotation(),
+                repeated, "@Repeated(1)");
+
+        Class<? extends Annotation> container = Container.class;
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorWithoutAnnotations(),
+                container, EXPECT_EMPTY);
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationOddity(),
+                container, "@Container({@Repeated(2), @Repeated(3)})");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationExplicitSingle(),
+                container, "@Container({@Repeated(1)})");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotation(),
+                container, "@Container({@Repeated(1), @Repeated(2)})");
+        checkParameter0GetDeclaredAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorSingleAnnotation(),
+                container, EXPECT_EMPTY);
+    }
+
+    private static void checkParameter0GetDeclaredAnnotationsByType(
+            Executable executable, Class<? extends Annotation> annotationType,
+            String... expectedAnnotationStrings) throws Exception {
+        Parameter parameter = executable.getParameters()[0];
+        AnnotatedElementTestSupport.assertGetDeclaredAnnotationsByType(
+                parameter, annotationType, expectedAnnotationStrings);
+    }
+
+    public void testMethodGetAnnotationsByType() throws Exception {
+        Class<? extends Annotation> repeated = Repeated.class;
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodWithoutAnnotations(),
+                repeated, EXPECT_EMPTY);
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotationOddity(),
+                repeated, "@Repeated(1)", "@Repeated(2)", "@Repeated(3)");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotationExplicitSingle(),
+                repeated, "@Repeated(1)");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotation(),
+                repeated, "@Repeated(1)", "@Repeated(2)");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodSingleAnnotation(),
+                repeated, "@Repeated(1)");
+
+        Class<? extends Annotation> container = Container.class;
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodWithoutAnnotations(),
+                container, EXPECT_EMPTY);
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotationOddity(),
+                container, "@Container({@Repeated(2), @Repeated(3)})");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotationExplicitSingle(),
+                container, "@Container({@Repeated(1)})");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodMultipleAnnotation(),
+                container, "@Container({@Repeated(1), @Repeated(2)})");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedMethodClass.getMethodSingleAnnotation(),
+                container, EXPECT_EMPTY);
+    }
+
+    public void testConstructorGetAnnotationsByType() throws Exception {
+        Class<? extends Annotation> repeated = Repeated.class;
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorWithoutAnnotations(),
+                repeated, EXPECT_EMPTY);
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationOddity(),
+                repeated, "@Repeated(1)", "@Repeated(2)", "@Repeated(3)");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationExplicitSingle(),
+                repeated, "@Repeated(1)");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotation(),
+                repeated, "@Repeated(1)", "@Repeated(2)");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorSingleAnnotation(),
+                repeated, "@Repeated(1)");
+
+        Class<? extends Annotation> container = Container.class;
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorWithoutAnnotations(),
+                container, EXPECT_EMPTY);
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationOddity(),
+                container, "@Container({@Repeated(2), @Repeated(3)})");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationExplicitSingle(),
+                container, "@Container({@Repeated(1)})");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotation(),
+                container, "@Container({@Repeated(1), @Repeated(2)})");
+        checkParameter0GetAnnotationsByType(
+                AnnotatedConstructorClass.getConstructorSingleAnnotation(),
+                container, EXPECT_EMPTY);
+    }
+
+    private static void checkParameter0GetAnnotationsByType(
+            Executable executable, Class<? extends Annotation> annotationType,
+            String... expectedAnnotationStrings) throws Exception {
+        Parameter parameter = executable.getParameters()[0];
+        AnnotatedElementTestSupport.assertGetAnnotationsByType(
+                parameter, annotationType, expectedAnnotationStrings);
+    }
+
+    /**
+     * As an inner class the constructor will actually have two parameters: the first, referencing
+     * the enclosing object, is inserted by the compiler.
+     */
+    class InnerClass {
+        InnerClass(@Repeated(1) String p1) {}
+    }
+
+    /** Special case testing for a compiler-generated constructor parameter. */
+    public void testImplicitConstructorParameters_singleAnnotation() throws Exception {
+        Constructor<InnerClass> constructor =
+                InnerClass.class.getDeclaredConstructor(
+                        AnnotatedElementParameterTest.class, String.class);
+        Parameter[] parameters = constructor.getParameters();
+
+        // The compiler-generated constructor should have no annotations.
+        Parameter parameter0 = parameters[0];
+        AnnotatedElementTestSupport.assertGetAnnotationsByType(
+                parameter0, Repeated.class, new String[0]);
+        AnnotatedElementTestSupport.assertGetDeclaredAnnotationsByType(
+                parameter0, Repeated.class, new String[0]);
+        AnnotatedElementTestSupport.assertGetDeclaredAnnotation(
+                parameter0, Repeated.class, null);
+        AnnotatedElementTestSupport.assertIsAnnotationPresent(parameter0, Repeated.class, false);
+
+        // The annotation should remain on the correct parameter.
+        Parameter parameter1 = parameters[1];
+        AnnotatedElementTestSupport.assertGetAnnotationsByType(
+                parameter1, Repeated.class, new String[] {"@Repeated(1)"});
+        AnnotatedElementTestSupport.assertGetDeclaredAnnotationsByType(
+                parameter1, Repeated.class, new String[] {"@Repeated(1)"});
+        AnnotatedElementTestSupport.assertGetDeclaredAnnotation(
+                parameter1, Repeated.class, "@Repeated(1)");
+        AnnotatedElementTestSupport.assertIsAnnotationPresent(
+                parameter1, Repeated.class, true);
+    }
+}
diff --git a/luni/src/test/java/libcore/java/lang/reflect/annotations/AnnotatedElementTestSupport.java b/luni/src/test/java/libcore/java/lang/reflect/annotations/AnnotatedElementTestSupport.java
index ec57469..b17fbff 100644
--- a/luni/src/test/java/libcore/java/lang/reflect/annotations/AnnotatedElementTestSupport.java
+++ b/luni/src/test/java/libcore/java/lang/reflect/annotations/AnnotatedElementTestSupport.java
@@ -95,8 +95,8 @@
      * returns annotations of the supplied expected classes.
      *
      * <p>Where the expected classes contains some subset from
-     * {@link AnnotationA}, {@link AnnotationB} and {@link AnnotationC}, this method also asserts
-     * that {@link AnnotatedElement#isAnnotationPresent(Class)} and
+     * {@link AnnotationA}, {@link AnnotationB}, {@link AnnotationC}, {@link AnnotationD} this
+     * method also asserts that {@link AnnotatedElement#isAnnotationPresent(Class)} and
      * {@link AnnotatedElement#getAnnotation(Class)} works as expected.
      *
      * <p>This method also confirms that {@link AnnotatedElement#isAnnotationPresent(Class)} and
@@ -112,6 +112,7 @@
         assertPresent(expectedTypes.contains(AnnotationA.class), element, AnnotationA.class);
         assertPresent(expectedTypes.contains(AnnotationB.class), element, AnnotationB.class);
         assertPresent(expectedTypes.contains(AnnotationC.class), element, AnnotationC.class);
+        assertPresent(expectedTypes.contains(AnnotationD.class), element, AnnotationD.class);
 
         try {
             element.isAnnotationPresent(null);
diff --git a/luni/src/test/java/libcore/java/lang/reflect/annotations/ExecutableParameterTest.java b/luni/src/test/java/libcore/java/lang/reflect/annotations/ExecutableParameterTest.java
new file mode 100644
index 0000000..a07f2b3
--- /dev/null
+++ b/luni/src/test/java/libcore/java/lang/reflect/annotations/ExecutableParameterTest.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.java.lang.reflect.annotations;
+
+import junit.framework.TestCase;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
+
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationB;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationC;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationD;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.Container;
+import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.Repeated;
+
+import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.EXPECT_EMPTY;
+import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.annotationsToTypes;
+import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.assertAnnotationsMatch;
+import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.set;
+
+/**
+ * Tests for {@link Executable#getParameterAnnotations()} via the {@link Constructor} and
+ * {@link Method} classes. See {@link AnnotatedElementParameterTest} for testing of the
+ * {@link java.lang.reflect.AnnotatedElement} methods.
+ */
+public class ExecutableParameterTest extends TestCase {
+    private static class MethodClass {
+        public void methodWithoutAnnotatedParameters(String parameter1, String parameter2) {}
+
+        public void methodWithAnnotatedParameters(@AnnotationB @AnnotationD String parameter1,
+                @AnnotationC @AnnotationD String parameter2) {}
+    }
+
+    public void testMethodGetParameterAnnotations() throws Exception {
+        Method methodWithoutAnnotatedParameters = MethodClass.class.getMethod(
+                "methodWithoutAnnotatedParameters", String.class, String.class);
+        Annotation[][] noParameterAnnotations =
+                methodWithoutAnnotatedParameters.getParameterAnnotations();
+        assertEquals(2, noParameterAnnotations.length);
+        assertEquals(set(), annotationsToTypes(noParameterAnnotations[0]));
+        assertEquals(set(), annotationsToTypes(noParameterAnnotations[1]));
+
+        Method methodWithAnnotatedParameters = MethodClass.class.getMethod(
+                "methodWithAnnotatedParameters", String.class, String.class);
+        Annotation[][] parameterAnnotations =
+                methodWithAnnotatedParameters.getParameterAnnotations();
+        assertEquals(2, parameterAnnotations.length);
+        assertEquals(set(AnnotationB.class, AnnotationD.class),
+                annotationsToTypes(parameterAnnotations[0]));
+        assertEquals(set(AnnotationC.class, AnnotationD.class),
+                annotationsToTypes(parameterAnnotations[1]));
+    }
+
+    private static class ConstructorClass {
+        // No annotations.
+        public ConstructorClass(Integer parameter1, Integer parameter2) {}
+
+        // Annotations.
+        public ConstructorClass(@AnnotationB @AnnotationD String parameter1,
+                @AnnotationC @AnnotationD String parameter2) {}
+    }
+
+    public void testConstructorGetParameterAnnotations() throws Exception {
+        Constructor constructorWithoutAnnotatedParameters =
+                ConstructorClass.class.getDeclaredConstructor(Integer.class, Integer.class);
+        Annotation[][] noParameterAnnotations =
+                constructorWithoutAnnotatedParameters.getParameterAnnotations();
+        assertEquals(2, noParameterAnnotations.length);
+        assertEquals(set(), annotationsToTypes(noParameterAnnotations[0]));
+        assertEquals(set(), annotationsToTypes(noParameterAnnotations[1]));
+
+        Constructor constructorWithAnnotatedParameters =
+                ConstructorClass.class.getDeclaredConstructor(String.class, String.class);
+        Annotation[][] parameterAnnotations =
+                constructorWithAnnotatedParameters.getParameterAnnotations();
+        assertEquals(2, parameterAnnotations.length);
+        assertEquals(set(AnnotationB.class, AnnotationD.class),
+                annotationsToTypes(parameterAnnotations[0]));
+        assertEquals(set(AnnotationC.class, AnnotationD.class),
+                annotationsToTypes(parameterAnnotations[1]));
+    }
+
+    private static class AnnotatedMethodClass {
+        void noAnnotation(String p0) {}
+
+        void multipleAnnotationOddity(
+                @Repeated(1) @Container({@Repeated(2), @Repeated(3)}) String p0) {}
+
+        void multipleAnnotationExplicitSingle(@Container({@Repeated(1)}) String p0) {}
+
+        void multipleAnnotation(@Repeated(1) @Repeated(2) String p0) {}
+
+        void singleAnnotation(@Repeated(1) String p0) {}
+
+        static Method getMethodWithoutAnnotations() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod("noAnnotation", String.class);
+        }
+
+        static Method getMethodMultipleAnnotationOddity() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod(
+                    "multipleAnnotationOddity", String.class);
+        }
+
+        static Method getMethodMultipleAnnotationExplicitSingle() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod(
+                    "multipleAnnotationExplicitSingle", String.class);
+        }
+
+        static Method getMethodMultipleAnnotation() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod("multipleAnnotation", String.class);
+        }
+
+        static Method getMethodSingleAnnotation() throws Exception {
+            return AnnotatedMethodClass.class.getDeclaredMethod("singleAnnotation", String.class);
+        }
+    }
+
+    public void testMethodGetParameterAnnotations_repeated() throws Exception {
+        assertParameter0Annotations(
+                AnnotatedMethodClass.getMethodWithoutAnnotations(), EXPECT_EMPTY);
+        assertParameter0Annotations(
+                AnnotatedMethodClass.getMethodMultipleAnnotationOddity(),
+                "@Repeated(1)", "@Container({@Repeated(2), @Repeated(3)})");
+        assertParameter0Annotations(
+                AnnotatedMethodClass.getMethodMultipleAnnotationExplicitSingle(),
+                "@Container({@Repeated(1)})");
+        assertParameter0Annotations(
+                AnnotatedMethodClass.getMethodMultipleAnnotation(),
+                "@Container({@Repeated(1), @Repeated(2)})");
+        assertParameter0Annotations(
+                AnnotatedMethodClass.getMethodSingleAnnotation(),
+                "@Repeated(1)");
+    }
+
+    private static class AnnotatedConstructorClass {
+        public AnnotatedConstructorClass(Boolean p0) {}
+
+        public AnnotatedConstructorClass(
+                @Repeated(1) @Container({@Repeated(2), @Repeated(3)}) Long p0) {}
+
+        public AnnotatedConstructorClass(@Container({@Repeated(1)}) Double p0) {}
+
+        public AnnotatedConstructorClass(@Repeated(1) @Repeated(2) Integer p0) {}
+
+        public AnnotatedConstructorClass(@Repeated(1) String p0) {}
+
+        static Constructor<?> getConstructorWithoutAnnotations() throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(Boolean.class);
+        }
+
+        static Constructor<?> getConstructorMultipleAnnotationOddity() throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(Long.class);
+        }
+
+        static Constructor<?> getConstructorMultipleAnnotationExplicitSingle()
+                throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(Double.class);
+        }
+
+        static Constructor<?> getConstructorMultipleAnnotation() throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(Integer.class);
+        }
+
+        static Constructor<?> getConstructorSingleAnnotation() throws Exception {
+            return AnnotatedConstructorClass.class.getDeclaredConstructor(String.class);
+        }
+    }
+
+    public void testConstructorGetParameterAnnotations_repeated() throws Exception {
+        assertParameter0Annotations(
+                AnnotatedConstructorClass.getConstructorWithoutAnnotations(),
+                EXPECT_EMPTY);
+        assertParameter0Annotations(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationOddity(),
+                "@Repeated(1)", "@Container({@Repeated(2), @Repeated(3)})");
+        assertParameter0Annotations(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotationExplicitSingle(),
+                "@Container({@Repeated(1)})");
+        assertParameter0Annotations(
+                AnnotatedConstructorClass.getConstructorMultipleAnnotation(),
+                "@Container({@Repeated(1), @Repeated(2)})");
+        assertParameter0Annotations(
+                AnnotatedConstructorClass.getConstructorSingleAnnotation(),
+                "@Repeated(1)");
+    }
+
+    private static void assertParameter0Annotations(
+            Executable executable, String... expectedAnnotationStrings) throws Exception {
+        Annotation[][] allAnnotations = executable.getParameterAnnotations();
+        final int expectedParameterCount = 1;
+        assertEquals(expectedParameterCount, allAnnotations.length);
+
+        Annotation[] p0Annotations = allAnnotations[0];
+        assertAnnotationsMatch(p0Annotations, expectedAnnotationStrings);
+    }
+}
diff --git a/luni/src/test/java/libcore/java/lang/reflect/annotations/ParameterTest.java b/luni/src/test/java/libcore/java/lang/reflect/annotations/ParameterTest.java
deleted file mode 100644
index f40ac9f..0000000
--- a/luni/src/test/java/libcore/java/lang/reflect/annotations/ParameterTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package libcore.java.lang.reflect.annotations;
-
-import junit.framework.TestCase;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationB;
-import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationC;
-import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.AnnotationD;
-import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.Container;
-import libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.Repeated;
-
-import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.EXPECT_EMPTY;
-import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.annotationsToTypes;
-import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.assertAnnotationsMatch;
-import static libcore.java.lang.reflect.annotations.AnnotatedElementTestSupport.set;
-
-public class ParameterTest extends TestCase {
-    private static class Type {
-        @AnnotationB
-        @AnnotationC
-        public void method(String parameter1, String parameter2) {}
-
-        @AnnotationB
-        @AnnotationC
-        public void parameters(@AnnotationB @AnnotationD String parameter1,
-                @AnnotationC @AnnotationD String parameter2) {}
-    }
-
-    public void testParameterAnnotations() throws Exception {
-        Method method = Type.class.getMethod("method", String.class, String.class);
-        Annotation[][] noParameterAnnotations = method.getParameterAnnotations();
-        assertEquals(2, noParameterAnnotations.length);
-        assertEquals(set(), annotationsToTypes(noParameterAnnotations[0]));
-        assertEquals(set(), annotationsToTypes(noParameterAnnotations[1]));
-
-        Method parameters = Type.class.getMethod("parameters", String.class, String.class);
-        Annotation[][] parameterAnnotations = parameters.getParameterAnnotations();
-        assertEquals(2, parameterAnnotations.length);
-        assertEquals(set(AnnotationB.class, AnnotationD.class),
-                annotationsToTypes(parameterAnnotations[0]));
-        assertEquals(set(AnnotationC.class, AnnotationD.class),
-                annotationsToTypes(parameterAnnotations[1]));
-    }
-
-    private static class AnnotatedClass {
-        public void singleAnnotation(@Repeated(1) String p0) {}
-
-        public void multipleAnnotation(@Repeated(1) @Repeated(2) String p0) {}
-
-        public void multipleAnnotationExplicitSingle(@Container({@Repeated(1)}) String p0) {}
-
-        public void multipleAnnotationOddity(
-                @Repeated(1) @Container({@Repeated(2), @Repeated(3)}) String p0) {}
-
-        public void noAnnotation(String p0) {}
-    }
-
-    public void testGetParameterAnnotations() throws Exception {
-        Class<?> c = AnnotatedClass.class;
-
-        assertParameter0Annotations(c, "noAnnotation", EXPECT_EMPTY);
-        assertParameter0Annotations(c, "multipleAnnotationOddity",
-                "@Repeated(1)", "@Container({@Repeated(2), @Repeated(3)})");
-        assertParameter0Annotations(c, "multipleAnnotationExplicitSingle",
-                "@Container({@Repeated(1)})");
-        assertParameter0Annotations(c, "multipleAnnotation",
-                "@Container({@Repeated(1), @Repeated(2)})");
-        assertParameter0Annotations(c, "singleAnnotation",
-                "@Repeated(1)");
-    }
-
-    private static void assertParameter0Annotations(
-            Class<?> c, String methodName, String... expectedAnnotationStrings) throws Exception {
-        Annotation[][] allAnnotations =
-                c.getDeclaredMethod(methodName, String.class).getParameterAnnotations();
-        final int expectedParameterCount = 1;
-        assertEquals(expectedParameterCount, allAnnotations.length);
-
-        Annotation[] p0Annotations = allAnnotations[0];
-        assertAnnotationsMatch(p0Annotations, expectedAnnotationStrings);
-    }
-}
diff --git a/luni/src/test/java/libcore/java/net/URLConnectionTest.java b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
index d1d26a8..3f750e4 100644
--- a/luni/src/test/java/libcore/java/net/URLConnectionTest.java
+++ b/luni/src/test/java/libcore/java/net/URLConnectionTest.java
@@ -2723,7 +2723,7 @@
     public void testSslFallback_allSupportedProtocols() throws Exception {
         TestSSLContext testSSLContext = createDefaultTestSSLContext();
 
-        String[] allSupportedProtocols = { "TLSv1.2", "TLSv1.1", "TLSv1", "SSLv3" };
+        String[] allSupportedProtocols = { "TLSv1.2", "TLSv1.1", "TLSv1" };
         SSLSocketFactory serverSocketFactory =
                 new LimitedProtocolsSocketFactory(
                         testSSLContext.serverContext.getSocketFactory(),
@@ -2731,7 +2731,6 @@
         server.useHttps(serverSocketFactory, false);
         server.enqueue(new MockResponse().setSocketPolicy(FAIL_HANDSHAKE));
         server.enqueue(new MockResponse().setSocketPolicy(FAIL_HANDSHAKE));
-        server.enqueue(new MockResponse().setSocketPolicy(FAIL_HANDSHAKE));
         server.enqueue(new MockResponse().setBody("This required fallbacks"));
         server.play();
 
@@ -2749,28 +2748,24 @@
         // Confirm the server accepted a single connection.
         RecordedRequest retry = server.takeRequest();
         assertEquals(0, retry.getSequenceNumber());
-        assertEquals("SSLv3", retry.getSslProtocol());
+        assertEquals("TLSv1", retry.getSslProtocol());
 
         // Confirm the client fallback looks ok.
         List<SSLSocket> createdSockets = clientSocketFactory.getCreatedSockets();
-        assertEquals(4, createdSockets.size());
+        assertEquals(3, createdSockets.size());
         TlsFallbackDisabledScsvSSLSocket clientSocket1 =
                 (TlsFallbackDisabledScsvSSLSocket) createdSockets.get(0);
         assertSslSocket(clientSocket1,
-                false /* expectedWasFallbackScsvSet */, "TLSv1.2", "TLSv1.1", "TLSv1", "SSLv3");
+                false /* expectedWasFallbackScsvSet */, "TLSv1.2", "TLSv1.1", "TLSv1");
 
         TlsFallbackDisabledScsvSSLSocket clientSocket2 =
                 (TlsFallbackDisabledScsvSSLSocket) createdSockets.get(1);
         assertSslSocket(clientSocket2,
-                true /* expectedWasFallbackScsvSet */, "TLSv1.1", "TLSv1", "SSLv3");
+                true /* expectedWasFallbackScsvSet */, "TLSv1.1", "TLSv1");
 
         TlsFallbackDisabledScsvSSLSocket clientSocket3 =
                 (TlsFallbackDisabledScsvSSLSocket) createdSockets.get(2);
-        assertSslSocket(clientSocket3, true /* expectedWasFallbackScsvSet */, "TLSv1", "SSLv3");
-
-        TlsFallbackDisabledScsvSSLSocket clientSocket4 =
-                (TlsFallbackDisabledScsvSSLSocket) createdSockets.get(3);
-        assertSslSocket(clientSocket4, true /* expectedWasFallbackScsvSet */, "SSLv3");
+        assertSslSocket(clientSocket3, true /* expectedWasFallbackScsvSet */, "TLSv1");
     }
 
     public void testSslFallback_defaultProtocols() throws Exception {
diff --git a/luni/src/test/java/libcore/java/security/SignatureTest.java b/luni/src/test/java/libcore/java/security/SignatureTest.java
index 35712e0..8d1af37 100644
--- a/luni/src/test/java/libcore/java/security/SignatureTest.java
+++ b/luni/src/test/java/libcore/java/security/SignatureTest.java
@@ -238,32 +238,28 @@
 
         @Override
         protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
-            throw new UnsupportedOperationException();
         }
 
         @Override
         protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
-            throw new UnsupportedOperationException();
         }
 
         @Override
         protected void engineUpdate(byte b) throws SignatureException {
-            throw new UnsupportedOperationException();
         }
 
         @Override
         protected void engineUpdate(byte[] b, int off, int len) throws SignatureException {
-            throw new UnsupportedOperationException();
         }
 
         @Override
         protected byte[] engineSign() throws SignatureException {
-            throw new UnsupportedOperationException();
+            return new byte[10];
         }
 
         @Override
         protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
-            throw new UnsupportedOperationException();
+            return true;
         }
 
         @Override
@@ -277,6 +273,153 @@
         }
     }
 
+    public void testSignature_signArray_nullArray_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.sign(null /* outbuf */, 1 /* offset */, 1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_signArray_negativeOffset_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.sign(new byte[4], -1 /* offset */, 1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_signArray_negativeLength_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.sign(new byte[4], 1 /* offset */ , -1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_signArray_invalidLengths_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            // Start at offset 3 with length 2, thus attempting to overread from an array of size 4.
+            s.sign(new byte[4], 3 /* offset */ , 2 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    private static PublicKey createPublicKey() throws Exception {
+        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(PK_BYTES);
+        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+        return keyFactory.generatePublic(keySpec);
+    }
+
+    public void testSignature_verifyArray_nullArray_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.initVerify(createPublicKey());
+            s.verify(null /* outbuf */, 1 /* offset */, 1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_verifyArray_negativeOffset_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.initVerify(createPublicKey());
+            s.verify(new byte[4], -1 /* offset */, 1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_verifyArray_negativeLength_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.initVerify(createPublicKey());
+            s.verify(new byte[4], 1 /* offset */ , -1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_verifyArray_invalidLengths_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.initVerify(createPublicKey());
+            // Start at offset 3 with length 2, thus attempting to overread from an array of size 4.
+            s.verify(new byte[4], 3 /* offset */ , 2 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_verifyArray_correctParameters_ok() throws Exception {
+        Signature s = new MySignature("FOO");
+        s.initVerify(createPublicKey());
+        // Start at offset 3 with length 2, thus attempting to overread from an array of size 4.
+        s.verify(new byte[4], 1 /* offset */, 2 /* length */);
+    }
+
+    public void testSignature_updateArray_nullArray_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.initVerify(createPublicKey());
+            s.update(null /* outbuf */, 1 /* offset */, 1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_updateArray_negativeOffset_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.initVerify(createPublicKey());
+            s.update(new byte[4], -1 /* offset */, 1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_updateArray_negativeLength_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.initVerify(createPublicKey());
+            s.update(new byte[4], 1 /* offset */ , -1 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_updateArray_invalidLengths_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.initVerify(createPublicKey());
+            // Start at offset 3 with length 2, thus attempting to overread from an array of size 4.
+            s.update(new byte[4], 3 /* offset */ , 2 /* length */);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
+    public void testSignature_updateArray_wrongState_throws() throws Exception {
+        try {
+            Signature s = new MySignature("FOO");
+            s.update(new byte[4], 0 /* offset */ , 1 /* length */);
+            fail();
+        } catch (SignatureException expected) {
+        }
+    }
+
+    public void testSignature_updateArray_correctStateAndParameters_ok() throws Exception {
+        Signature s = new MySignature("FOO");
+        s.initVerify(createPublicKey());
+        s.update(new byte[4], 0 /* offset */ , 1 /* length */);
+    }
+
     public void testSignature_getProvider_Subclass() throws Exception {
         Provider mockProviderNonSpi = new MockProvider("MockProviderNonSpi") {
             public void setup() {
diff --git a/luni/src/test/java/libcore/java/text/OldBidiTest.java b/luni/src/test/java/libcore/java/text/OldBidiTest.java
index fbf68ea..fe8b6cb 100644
--- a/luni/src/test/java/libcore/java/text/OldBidiTest.java
+++ b/luni/src/test/java/libcore/java/text/OldBidiTest.java
@@ -17,6 +17,7 @@
 
 package libcore.java.text;
 
+import java.text.AttributedCharacterIterator;
 import java.text.Bidi;
 import junit.framework.TestCase;
 
@@ -192,4 +193,16 @@
         }
     }
 
+    // http://b/30652865
+    public void testUnicode9EmojisAreLtrNeutral() {
+        String callMeHand = "\uD83E\uDD19"; // U+1F919 in UTF-16
+        String hebrewAndEmoji = "\u05e9\u05dc" + callMeHand + "\u05d5\u05dd";
+        String latinAndEmoji = "Hel" + callMeHand + "lo";
+        Bidi hebrew = new Bidi(hebrewAndEmoji, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+        assertFalse("Hebrew bidi is mixed: " + hebrew, hebrew.isMixed());
+        assertTrue("Hebrew bidi is not right to left: " + hebrew, hebrew.isRightToLeft());
+        Bidi latin = new Bidi(latinAndEmoji, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+        assertFalse("Latin bidi is mixed: " + latin, latin.isMixed());
+        assertTrue("latin bidi is not left to right: " + latin, latin.isLeftToRight());
+    }
 }
diff --git a/luni/src/test/java/libcore/java/text/SimpleDateFormatTest.java b/luni/src/test/java/libcore/java/text/SimpleDateFormatTest.java
index d9656a0..5e208a7 100644
--- a/luni/src/test/java/libcore/java/text/SimpleDateFormatTest.java
+++ b/luni/src/test/java/libcore/java/text/SimpleDateFormatTest.java
@@ -513,4 +513,18 @@
         assertEquals("torstai", formatDate(fi, "cccc"));
         assertEquals("torstaina", formatDate(fi, "EEEE"));
     }
+
+    public void testDayNumberOfWeek() throws Exception {
+        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+        Locale en = Locale.ENGLISH;
+        Locale pl = new Locale("pl");
+
+        assertEquals("4", formatDate(en, "u"));
+        assertEquals("04", formatDate(en, "uu"));
+        assertEquals("4", formatDate(pl, "u"));
+        assertEquals("04", formatDate(pl, "uu"));
+
+        assertEquals(Calendar.THURSDAY, parseDate(en, "u", "4").get(Calendar.DAY_OF_WEEK));
+        assertEquals(Calendar.MONDAY, parseDate(en, "uu", "1").get(Calendar.DAY_OF_WEEK));
+    }
 }
diff --git a/luni/src/test/java/libcore/javax/crypto/CipherTest.java b/luni/src/test/java/libcore/javax/crypto/CipherTest.java
index 7299c00..ede4d77 100644
--- a/luni/src/test/java/libcore/javax/crypto/CipherTest.java
+++ b/luni/src/test/java/libcore/javax/crypto/CipherTest.java
@@ -1506,10 +1506,7 @@
                 c.updateAAD(new byte[24]);
             }
             byte[] cipherText = c.doFinal(getActualPlainText(algorithm));
-            if (!isRandomizedEncryption(algorithm)) {
-                if (isAEAD(algorithm)) {
-                    c.updateAAD(new byte[24]);
-                }
+            if (!isRandomizedEncryption(algorithm) && !isAEAD(algorithm)) {
                 byte[] cipherText2 = c.doFinal(getActualPlainText(algorithm));
                 assertEquals(cipherID, Arrays.toString(cipherText), Arrays.toString(cipherText2));
             }
@@ -3243,15 +3240,31 @@
         ByteArrayOutputStream errBuffer = new ByteArrayOutputStream();
         PrintStream out = new PrintStream(errBuffer);
         for (CipherTestParam testVector : testVectors) {
-            Provider[] providers = Security.getProviders("Cipher." + testVector.transformation);
-            if ((providers == null) || (providers.length == 0)) {
+            ArrayList<Provider> providers = new ArrayList<>();
+
+            Provider[] providerArray = Security.getProviders("Cipher." + testVector.transformation);
+            if (providerArray != null) {
+                Collections.addAll(providers, providerArray);
+            }
+
+            if (testVector.transformation.indexOf('/') > 0) {
+                Provider[] baseTransformProviderArray = Security.getProviders("Cipher."
+                        + testVector.transformation.substring(
+                                  0, testVector.transformation.indexOf('/')));
+                if (baseTransformProviderArray != null) {
+                    Collections.addAll(providers, baseTransformProviderArray);
+                }
+            }
+
+            if (providers.isEmpty()) {
                 out.append("No providers offer " + testVector.transformation + "\n");
                 continue;
             }
+
             for (Provider provider : providers) {
                 try {
                     checkCipher(testVector, provider.getName());
-                } catch (Exception e) {
+                } catch (Throwable e) {
                     logTestFailure(out, provider.getName(), testVector, e);
                 }
             }
@@ -3268,7 +3281,7 @@
         for (CipherTestParam p : CIPHER_TEST_PARAMS) {
             try {
                 checkCipher(p, provider);
-            } catch (Exception e) {
+            } catch (Throwable e) {
                 logTestFailure(out, provider, p, e);
             }
         }
@@ -3279,10 +3292,14 @@
     }
 
     private void logTestFailure(PrintStream logStream, String provider, CipherTestParam params,
-            Exception e) {
-        logStream.append("Error encountered checking " + params.transformation + ", keySize="
-                + (params.encryptKey.getEncoded().length * 8) + " with provider " + provider
-                + "\n");
+            Throwable e) {
+        logStream.append("Error encountered checking " + params.transformation);
+
+        if (params.encryptKey instanceof SecretKey) {
+            logStream.append(", keySize=" + (params.encryptKey.getEncoded().length * 8));
+        }
+
+        logStream.append(" with provider " + provider + "\n");
         e.printStackTrace(logStream);
     }
 
@@ -4139,17 +4156,27 @@
 
         assertEquals(Arrays.toString(c1.doFinal()), Arrays.toString(c2.doFinal()));
 
-        // .doFinal should also reset the state, so check that as well.
+        // .doFinal should also not allow reuse without re-initialization
         byte[] aad2 = new byte[] {
                 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11,
         };
+        try {
+            c1.updateAAD(aad2);
+            fail("Should not allow updateAAD without re-initialization");
+        } catch (IllegalStateException expected) {
+        }
 
-        Cipher c3 = Cipher.getInstance("AES/GCM/NoPadding");
-        c3.init(Cipher.ENCRYPT_MODE, key, spec);
+        try {
+            c1.update(new byte[8]);
+            fail("Should not allow update without re-initialization");
+        } catch (IllegalStateException expected) {
+        }
 
-        c1.updateAAD(aad2);
-        c3.updateAAD(aad2);
-        assertEquals(Arrays.toString(c1.doFinal()), Arrays.toString(c3.doFinal()));
+        try {
+            c1.doFinal();
+            fail("Should not allow doFinal without re-initialization");
+        } catch (IllegalStateException expected) {
+        }
     }
 
     /**
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLContextTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLContextTest.java
index 603baa1..f23c48b 100644
--- a/luni/src/test/java/libcore/javax/net/ssl/SSLContextTest.java
+++ b/luni/src/test/java/libcore/javax/net/ssl/SSLContextTest.java
@@ -582,6 +582,20 @@
         testContext.close();
     }
 
+    public void test_SSLContext_SSLv3Unsupported() throws Exception {
+        try {
+            SSLContext context = SSLContext.getInstance("SSLv3");
+            fail("SSLv3 should not be supported");
+        } catch (NoSuchAlgorithmException expected) {
+        }
+
+        try {
+            SSLContext context = SSLContext.getInstance("SSL");
+            fail("SSL should not be supported");
+        } catch (NoSuchAlgorithmException expected) {
+        }
+    }
+
     private static void assertContentsInOrder(List<String> expected, String... actual) {
         if (expected.size() != actual.length) {
             fail("Unexpected length. Expected len <" + expected.size()
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
index 8990f62..1628260 100644
--- a/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
+++ b/luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
@@ -220,8 +220,7 @@
                 assertConnected(pair);
 
                 boolean needsRecordSplit =
-                        ("TLS".equalsIgnoreCase(c.clientContext.getProtocol())
-                                || "SSLv3".equalsIgnoreCase(c.clientContext.getProtocol()))
+                        "TLS".equalsIgnoreCase(c.clientContext.getProtocol())
                                 && cipherSuite.contains("_CBC_");
 
                 assertSendsCorrectly("This is the client. Hello!".getBytes(),
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
index 5e94b21..d2ad9fd 100644
--- a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
+++ b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
@@ -1992,14 +1992,14 @@
         ExecutorService executor = Executors.newFixedThreadPool(2);
         Future<Void> s = executor.submit(new Callable<Void>() {
                 public Void call() throws Exception {
-                    server.setEnabledProtocols(new String[] { "TLSv1", "SSLv3" });
+                    server.setEnabledProtocols(new String[] { "TLSv1.2", "TLSv1.1" });
                     server.startHandshake();
                     return null;
                 }
             });
         Future<Void> c = executor.submit(new Callable<Void>() {
                 public Void call() throws Exception {
-                    client.setEnabledProtocols(new String[] { "SSLv3" });
+                    client.setEnabledProtocols(new String[] { "TLSv1.1" });
                     client.startHandshake();
                     return null;
                 }
@@ -2035,7 +2035,7 @@
         ExecutorService executor = Executors.newFixedThreadPool(2);
         Future<Void> s = executor.submit(new Callable<Void>() {
                 public Void call() throws Exception {
-                    server.setEnabledProtocols(new String[] { "TLSv1", "SSLv3" });
+                    server.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1" });
                     server.setEnabledCipherSuites(serverCipherSuites);
                     try {
                         server.startHandshake();
@@ -2050,7 +2050,7 @@
             });
         Future<Void> c = executor.submit(new Callable<Void>() {
                 public Void call() throws Exception {
-                    client.setEnabledProtocols(new String[] { "SSLv3" });
+                    client.setEnabledProtocols(new String[] { "TLSv1" });
                     client.setEnabledCipherSuites(clientCipherSuites);
                     try {
                         client.startHandshake();
@@ -2219,6 +2219,25 @@
         context.close();
     }
 
+    public void test_SSLSocket_SSLv3Unsupported() throws Exception {
+        TestSSLContext context = TestSSLContext.create();
+
+        final SSLSocket client = (SSLSocket)
+            context.clientContext.getSocketFactory().createSocket();
+
+        try {
+            client.setEnabledProtocols(new String[] {"SSLv3"});
+            fail("SSLSocket should not support SSLv3 protocol");
+        } catch (IllegalArgumentException expected) {
+        }
+
+        try {
+            client.setEnabledProtocols(new String[] {"SSL"});
+            fail("SSLSocket should not support SSL protocol");
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+
     /**
      * Not run by default by JUnit, but can be run by Vogar by
      * specifying it explicitly (or with main method below)
diff --git a/luni/src/test/java/libcore/sun/invoke/util/VerifyAccessTest.java b/luni/src/test/java/libcore/sun/invoke/util/VerifyAccessTest.java
new file mode 100644
index 0000000..0c02754
--- /dev/null
+++ b/luni/src/test/java/libcore/sun/invoke/util/VerifyAccessTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package libcore.sun.invoke.util;
+
+
+import junit.framework.TestCase;
+import sun.invoke.util.VerifyAccess;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.util.List;
+import java.util.Locale;
+import java.util.Vector;
+
+
+public class VerifyAccessTest extends TestCase {
+    public void testIsClassAccessible() {
+        // Always returns false when allowedModes == 0. Note that the "modes" allowed here
+        // are different from the ones used in MethodHandles.
+        assertFalse(VerifyAccess.isClassAccessible(Inner1.class, Inner2.class, 0));
+
+        // Classes in the same package are accessible when Lookup.PACKAGE is specified.
+        assertTrue(VerifyAccess.isClassAccessible(Inner1.class, Inner2.class,
+                MethodHandles.Lookup.PACKAGE));
+        assertTrue(VerifyAccess.isClassAccessible(Inner1.class, Sibling.class,
+                MethodHandles.Lookup.PACKAGE));
+
+        // Public classes are always accessible.
+        assertTrue(VerifyAccess.isClassAccessible(String.class, Inner1.class,
+                MethodHandles.Lookup.PACKAGE));
+    }
+
+    public static class Inner1 {
+    }
+
+    public static class Inner2 {
+    }
+
+    public void testIsSamePackageMember() {
+        assertTrue(VerifyAccess.isSamePackageMember(Inner1.class, Inner2.class));
+        assertTrue(VerifyAccess.isSamePackageMember(Inner1.class, VerifyAccessTest.class));
+
+        assertFalse(VerifyAccess.isSamePackageMember(Sibling.class, Inner1.class));
+    }
+
+    public void testIsSamePackage() {
+        // Both classes are in package java.util.
+        assertTrue(VerifyAccess.isSamePackage(Vector.class, List.class));
+        // Make sure this works for inner classes.
+        assertTrue(VerifyAccess.isSamePackage(Vector.class, Locale.Builder.class));
+        // Differing packages: java.lang vs java.util.
+        assertFalse(VerifyAccess.isSamePackage(Vector.class, String.class));
+
+        try {
+            VerifyAccess.isSamePackage(String[].class, List.class);
+            fail();
+        } catch (IllegalArgumentException expected) {
+        }
+    }
+}
+
+class Sibling {
+}
diff --git a/non_openjdk_java_files.mk b/non_openjdk_java_files.mk
index 9a3ef03..a559619 100644
--- a/non_openjdk_java_files.mk
+++ b/non_openjdk_java_files.mk
@@ -66,7 +66,6 @@
   luni/src/main/java/java/lang/FindBugsSuppressWarnings.java \
   libart/src/main/java/java/lang/VMClassLoader.java \
   luni/src/main/java/java/lang/ref/FinalizerReference.java \
-  libart/src/main/java/java/lang/reflect/AbstractMethod.java \
   luni/src/main/java/java/math/BigDecimal.java \
   luni/src/main/java/java/math/BigInt.java \
   luni/src/main/java/java/math/BigInteger.java \
diff --git a/ojluni/src/main/java/java/io/BufferedInputStream.java b/ojluni/src/main/java/java/io/BufferedInputStream.java
index fcc7e70..e39c20c 100644
--- a/ojluni/src/main/java/java/io/BufferedInputStream.java
+++ b/ojluni/src/main/java/java/io/BufferedInputStream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,17 @@
 public
 class BufferedInputStream extends FilterInputStream {
 
-    private static int defaultBufferSize = 8192;
+    // Android-changed: made final
+    private static final int DEFAULT_BUFFER_SIZE = 8192;
+
+    /**
+     * The maximum size of array to allocate.
+     * Some VMs reserve some header words in an array.
+     * Attempts to allocate larger arrays may result in
+     * OutOfMemoryError: Requested array size exceeds VM limit
+     */
+    // Android-changed: made final
+    private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8;
 
     /**
      * The internal buffer array where the data is stored. When necessary,
@@ -172,7 +182,7 @@
      * @param   in   the underlying input stream.
      */
     public BufferedInputStream(InputStream in) {
-        this(in, defaultBufferSize);
+        this(in, DEFAULT_BUFFER_SIZE);
     }
 
     /**
@@ -185,7 +195,7 @@
      *
      * @param   in     the underlying input stream.
      * @param   size   the buffer size.
-     * @exception IllegalArgumentException if size <= 0.
+     * @exception IllegalArgumentException if {@code size <= 0}.
      */
     public BufferedInputStream(InputStream in, int size) {
         super(in);
@@ -215,8 +225,11 @@
             } else if (buffer.length >= marklimit) {
                 markpos = -1;   /* buffer got too big, invalidate mark */
                 pos = 0;        /* drop buffer contents */
+            } else if (buffer.length >= MAX_BUFFER_SIZE) {
+                throw new OutOfMemoryError("Required array size too large");
             } else {            /* grow buffer */
-                int nsz = pos * 2;
+                int nsz = (pos <= MAX_BUFFER_SIZE - pos) ?
+                        pos * 2 : MAX_BUFFER_SIZE;
                 if (nsz > marklimit)
                     nsz = marklimit;
                 byte nbuf[] = new byte[nsz];
diff --git a/ojluni/src/main/java/java/io/BufferedReader.java b/ojluni/src/main/java/java/io/BufferedReader.java
index 5a45f4b..d00209e 100644
--- a/ojluni/src/main/java/java/io/BufferedReader.java
+++ b/ojluni/src/main/java/java/io/BufferedReader.java
@@ -96,7 +96,7 @@
      * @param  in   A Reader
      * @param  sz   Input-buffer size
      *
-     * @exception  IllegalArgumentException  If sz is <= 0
+     * @exception  IllegalArgumentException  If {@code sz <= 0}
      */
     public BufferedReader(Reader in, int sz) {
         super(in);
@@ -495,7 +495,7 @@
      *                         whose size is no smaller than limit.
      *                         Therefore large values should be used with care.
      *
-     * @exception  IllegalArgumentException  If readAheadLimit is < 0
+     * @exception  IllegalArgumentException  If {@code readAheadLimit < 0}
      * @exception  IOException  If an I/O error occurs
      */
     public void mark(int readAheadLimit) throws IOException {
@@ -532,9 +532,12 @@
         synchronized (lock) {
             if (in == null)
                 return;
-            in.close();
-            in = null;
-            cb = null;
+            try {
+                in.close();
+            } finally {
+                in = null;
+                cb = null;
+            }
         }
     }
 
diff --git a/ojluni/src/main/java/java/io/BufferedWriter.java b/ojluni/src/main/java/java/io/BufferedWriter.java
index 220a47e..a5d810a 100644
--- a/ojluni/src/main/java/java/io/BufferedWriter.java
+++ b/ojluni/src/main/java/java/io/BufferedWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@
      * @param  out  A Writer
      * @param  sz   Output-buffer size, a positive integer
      *
-     * @exception  IllegalArgumentException  If sz is <= 0
+     * @exception  IllegalArgumentException  If {@code sz <= 0}
      */
     public BufferedWriter(Writer out, int sz) {
         super(out);
@@ -255,15 +255,15 @@
         }
     }
 
+    @SuppressWarnings("try")
     public void close() throws IOException {
         synchronized (lock) {
             if (out == null) {
                 return;
             }
-            try {
+            try (Writer w = out) {
                 flushBuffer();
             } finally {
-                out.close();
                 out = null;
                 cb = null;
             }
diff --git a/ojluni/src/main/java/java/io/ByteArrayInputStream.java b/ojluni/src/main/java/java/io/ByteArrayInputStream.java
index e58c6e6..d07f074 100644
--- a/ojluni/src/main/java/java/io/ByteArrayInputStream.java
+++ b/ojluni/src/main/java/java/io/ByteArrayInputStream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -275,7 +275,6 @@
      * Closing a <tt>ByteArrayInputStream</tt> has no effect. The methods in
      * this class can be called after the stream has been closed without
      * generating an <tt>IOException</tt>.
-     * <p>
      */
     public void close() throws IOException {
     }
diff --git a/ojluni/src/main/java/java/io/ByteArrayOutputStream.java b/ojluni/src/main/java/java/io/ByteArrayOutputStream.java
index c4df675..f1d429b 100644
--- a/ojluni/src/main/java/java/io/ByteArrayOutputStream.java
+++ b/ojluni/src/main/java/java/io/ByteArrayOutputStream.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -94,6 +94,14 @@
     }
 
     /**
+     * The maximum size of array to allocate.
+     * Some VMs reserve some header words in an array.
+     * Attempts to allocate larger arrays may result in
+     * OutOfMemoryError: Requested array size exceeds VM limit
+     */
+    private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
+
+    /**
      * Increases the capacity to ensure that it can hold at least the
      * number of elements specified by the minimum capacity argument.
      *
@@ -105,14 +113,19 @@
         int newCapacity = oldCapacity << 1;
         if (newCapacity - minCapacity < 0)
             newCapacity = minCapacity;
-        if (newCapacity < 0) {
-            if (minCapacity < 0) // overflow
-                throw new OutOfMemoryError();
-            newCapacity = Integer.MAX_VALUE;
-        }
+        if (newCapacity - MAX_ARRAY_SIZE > 0)
+            newCapacity = hugeCapacity(minCapacity);
         buf = Arrays.copyOf(buf, newCapacity);
     }
 
+    private static int hugeCapacity(int minCapacity) {
+        if (minCapacity < 0) // overflow
+            throw new OutOfMemoryError();
+        return (minCapacity > MAX_ARRAY_SIZE) ?
+            Integer.MAX_VALUE :
+            MAX_ARRAY_SIZE;
+    }
+
     /**
      * Writes the specified byte to this byte array output stream.
      *
@@ -210,21 +223,21 @@
 
     /**
      * Converts the buffer's contents into a string by decoding the bytes using
-     * the specified {@link java.nio.charset.Charset charsetName}. The length of
-     * the new <tt>String</tt> is a function of the charset, and hence may not be
-     * equal to the length of the byte array.
+     * the named {@link java.nio.charset.Charset charset}. The length of the new
+     * <tt>String</tt> is a function of the charset, and hence may not be equal
+     * to the length of the byte array.
      *
      * <p> This method always replaces malformed-input and unmappable-character
      * sequences with this charset's default replacement string. The {@link
      * java.nio.charset.CharsetDecoder} class should be used when more control
      * over the decoding process is required.
      *
-     * @param  charsetName  the name of a supported
-     *              {@linkplain java.nio.charset.Charset </code>charset<code>}
-     * @return String decoded from the buffer's contents.
+     * @param      charsetName  the name of a supported
+     *             {@link java.nio.charset.Charset charset}
+     * @return     String decoded from the buffer's contents.
      * @exception  UnsupportedEncodingException
      *             If the named charset is not supported
-     * @since   JDK1.1
+     * @since      JDK1.1
      */
     public synchronized String toString(String charsetName)
         throws UnsupportedEncodingException
@@ -263,8 +276,6 @@
      * Closing a <tt>ByteArrayOutputStream</tt> has no effect. The methods in
      * this class can be called after the stream has been closed without
      * generating an <tt>IOException</tt>.
-     * <p>
-     *
      */
     public void close() throws IOException {
     }
diff --git a/ojluni/src/main/java/java/io/Closeable.java b/ojluni/src/main/java/java/io/Closeable.java
index 7f3cc8d..b4a1c81 100644
--- a/ojluni/src/main/java/java/io/Closeable.java
+++ b/ojluni/src/main/java/java/io/Closeable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
  *
  * @since 1.5
  */
-
 public interface Closeable extends AutoCloseable {
 
     /**
@@ -42,6 +41,12 @@
      * with it. If the stream is already closed then invoking this
      * method has no effect.
      *
+     * <p> As noted in {@link AutoCloseable#close()}, cases where the
+     * close may fail require careful attention. It is strongly advised
+     * to relinquish the underlying resources and to internally
+     * <em>mark</em> the {@code Closeable} as closed, prior to throwing
+     * the {@code IOException}.
+     *
      * @throws IOException if an I/O error occurs
      */
     public void close() throws IOException;
diff --git a/ojluni/src/main/java/java/io/Console.java b/ojluni/src/main/java/java/io/Console.java
index 4eca41c..3cab03e 100644
--- a/ojluni/src/main/java/java/io/Console.java
+++ b/ojluni/src/main/java/java/io/Console.java
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2014 The Android Open Source Project
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,7 @@
  * manually zero the returned character array after processing to minimize the
  * lifetime of sensitive data in memory.
  *
- * <blockquote><pre>
+ * <blockquote><pre>{@code
  * Console cons;
  * char[] passwd;
  * if ((cons = System.console()) != null &&
@@ -84,7 +84,7 @@
  *     ...
  *     java.util.Arrays.fill(passwd, ' ');
  * }
- * </pre></blockquote>
+ * }</pre></blockquote>
  *
  * @author  Xueming Shen
  * @since   1.6
@@ -125,9 +125,11 @@
     * {@link java.io.Reader#read(java.nio.CharBuffer) read(java.nio.CharBuffer)}
     * on the returned object will not read in characters beyond the line
     * bound for each invocation, even if the destination buffer has space for
-    * more characters. A line bound is considered to be any one of a line feed
-    * (<tt>'\n'</tt>), a carriage return (<tt>'\r'</tt>), a carriage return
-    * followed immediately by a linefeed, or an end of stream.
+    * more characters. The {@code Reader}'s {@code read} methods may block if a
+    * line bound has not been entered or reached on the console's input device.
+    * A line bound is considered to be any one of a line feed (<tt>'\n'</tt>),
+    * a carriage return (<tt>'\r'</tt>), a carriage return followed immediately
+    * by a linefeed, or an end of stream.
     *
     * @return  The reader associated with this console
     */
diff --git a/ojluni/src/main/java/java/io/DataOutput.java b/ojluni/src/main/java/java/io/DataOutput.java
index 07fbc3a..c6692a6 100644
--- a/ojluni/src/main/java/java/io/DataOutput.java
+++ b/ojluni/src/main/java/java/io/DataOutput.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -134,11 +134,11 @@
      * Writes two bytes to the output
      * stream to represent the value of the argument.
      * The byte values to be written, in the  order
-     * shown, are: <p>
-     * <pre><code>
-     * (byte)(0xff &amp; (v &gt;&gt; 8))
-     * (byte)(0xff &amp; v)
-     * </code> </pre> <p>
+     * shown, are:
+     * <pre>{@code
+     * (byte)(0xff & (v >> 8))
+     * (byte)(0xff & v)
+     * }</pre> <p>
      * The bytes written by this method may be
      * read by the <code>readShort</code> method
      * of interface <code>DataInput</code> , which
@@ -156,10 +156,10 @@
      * output stream.
      * The byte values to be written, in the  order
      * shown, are:
-     * <p><pre><code>
-     * (byte)(0xff &amp; (v &gt;&gt; 8))
-     * (byte)(0xff &amp; v)
-     * </code></pre><p>
+     * <pre>{@code
+     * (byte)(0xff & (v >> 8))
+     * (byte)(0xff & v)
+     * }</pre><p>
      * The bytes written by this method may be
      * read by the <code>readChar</code> method
      * of interface <code>DataInput</code> , which
@@ -176,12 +176,12 @@
      * comprised of four bytes, to the output stream.
      * The byte values to be written, in the  order
      * shown, are:
-     * <p><pre><code>
-     * (byte)(0xff &amp; (v &gt;&gt; 24))
-     * (byte)(0xff &amp; (v &gt;&gt; 16))
-     * (byte)(0xff &amp; (v &gt;&gt; &#32; &#32;8))
-     * (byte)(0xff &amp; v)
-     * </code></pre><p>
+     * <pre>{@code
+     * (byte)(0xff & (v >> 24))
+     * (byte)(0xff & (v >> 16))
+     * (byte)(0xff & (v >>  8))
+     * (byte)(0xff & v)
+     * }</pre><p>
      * The bytes written by this method may be read
      * by the <code>readInt</code> method of interface
      * <code>DataInput</code> , which will then
@@ -197,16 +197,16 @@
      * comprised of eight bytes, to the output stream.
      * The byte values to be written, in the  order
      * shown, are:
-     * <p><pre><code>
-     * (byte)(0xff &amp; (v &gt;&gt; 56))
-     * (byte)(0xff &amp; (v &gt;&gt; 48))
-     * (byte)(0xff &amp; (v &gt;&gt; 40))
-     * (byte)(0xff &amp; (v &gt;&gt; 32))
-     * (byte)(0xff &amp; (v &gt;&gt; 24))
-     * (byte)(0xff &amp; (v &gt;&gt; 16))
-     * (byte)(0xff &amp; (v &gt;&gt;  8))
-     * (byte)(0xff &amp; v)
-     * </code></pre><p>
+     * <pre>{@code
+     * (byte)(0xff & (v >> 56))
+     * (byte)(0xff & (v >> 48))
+     * (byte)(0xff & (v >> 40))
+     * (byte)(0xff & (v >> 32))
+     * (byte)(0xff & (v >> 24))
+     * (byte)(0xff & (v >> 16))
+     * (byte)(0xff & (v >>  8))
+     * (byte)(0xff & v)
+     * }</pre><p>
      * The bytes written by this method may be
      * read by the <code>readLong</code> method
      * of interface <code>DataInput</code> , which
@@ -314,24 +314,24 @@
      * If a character <code>c</code>
      * is in the range <code>&#92;u0001</code> through
      * <code>&#92;u007f</code>, it is represented
-     * by one byte:<p>
+     * by one byte:
      * <pre>(byte)c </pre>  <p>
      * If a character <code>c</code> is <code>&#92;u0000</code>
      * or is in the range <code>&#92;u0080</code>
      * through <code>&#92;u07ff</code>, then it is
      * represented by two bytes, to be written
-     * in the order shown:<p> <pre><code>
-     * (byte)(0xc0 | (0x1f &amp; (c &gt;&gt; 6)))
-     * (byte)(0x80 | (0x3f &amp; c))
-     *  </code></pre>  <p> If a character
+     * in the order shown: <pre>{@code
+     * (byte)(0xc0 | (0x1f & (c >> 6)))
+     * (byte)(0x80 | (0x3f & c))
+     * }</pre> <p> If a character
      * <code>c</code> is in the range <code>&#92;u0800</code>
      * through <code>uffff</code>, then it is
      * represented by three bytes, to be written
-     * in the order shown:<p> <pre><code>
-     * (byte)(0xe0 | (0x0f &amp; (c &gt;&gt; 12)))
-     * (byte)(0x80 | (0x3f &amp; (c &gt;&gt;  6)))
-     * (byte)(0x80 | (0x3f &amp; c))
-     *  </code></pre>  <p> First,
+     * in the order shown: <pre>{@code
+     * (byte)(0xe0 | (0x0f & (c >> 12)))
+     * (byte)(0x80 | (0x3f & (c >>  6)))
+     * (byte)(0x80 | (0x3f & c))
+     * }</pre>  <p> First,
      * the total number of bytes needed to represent
      * all the characters of <code>s</code> is
      * calculated. If this number is larger than
diff --git a/ojluni/src/main/java/java/io/DefaultFileSystem.java b/ojluni/src/main/java/java/io/DefaultFileSystem.java
new file mode 100644
index 0000000..8e8cf08
--- /dev/null
+++ b/ojluni/src/main/java/java/io/DefaultFileSystem.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+
+package java.io;
+
+/**
+ *
+ * @since 1.8
+ */
+class DefaultFileSystem {
+
+    /**
+     * Return the FileSystem object for Unix-based platform.
+     */
+    public static FileSystem getFileSystem() {
+        return new UnixFileSystem();
+    }
+}
diff --git a/ojluni/src/main/java/java/io/EOFException.java b/ojluni/src/main/java/java/io/EOFException.java
index ed6ca0f..536669f 100644
--- a/ojluni/src/main/java/java/io/EOFException.java
+++ b/ojluni/src/main/java/java/io/EOFException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
  * This exception is mainly used by data input streams to signal end of
  * stream. Note that many other input operations return a special value on
  * end of stream rather than throwing an exception.
- * <p>
  *
  * @author  Frank Yellin
  * @see     java.io.DataInputStream
diff --git a/ojluni/src/main/java/java/io/ExpiringCache.java b/ojluni/src/main/java/java/io/ExpiringCache.java
index 8c07afb..02fd222 100644
--- a/ojluni/src/main/java/java/io/ExpiringCache.java
+++ b/ojluni/src/main/java/java/io/ExpiringCache.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -35,7 +35,7 @@
 
 class ExpiringCache {
     private long millisUntilExpiration;
-    private Map  map;
+    private Map<String,Entry> map;
     // Clear out old entries every few queries
     private int queryCount;
     private int queryOverflow = 300;
@@ -61,9 +61,11 @@
         this(30000);
     }
 
+    @SuppressWarnings("serial")
     ExpiringCache(long millisUntilExpiration) {
         this.millisUntilExpiration = millisUntilExpiration;
-        map = new LinkedHashMap() {
+        map = new LinkedHashMap<String,Entry>() {
+            @Override
             protected boolean removeEldestEntry(Map.Entry eldest) {
               return size() > MAX_ENTRIES;
             }
@@ -99,7 +101,7 @@
     }
 
     private Entry entryFor(String key) {
-        Entry entry = (Entry) map.get(key);
+        Entry entry = map.get(key);
         if (entry != null) {
             long delta = System.currentTimeMillis() - entry.timestamp();
             if (delta < 0 || delta >= millisUntilExpiration) {
@@ -111,12 +113,11 @@
     }
 
     private void cleanup() {
-        Set keySet = map.keySet();
+        Set<String> keySet = map.keySet();
         // Avoid ConcurrentModificationExceptions
         String[] keys = new String[keySet.size()];
         int i = 0;
-        for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
-            String key = (String) iter.next();
+        for (String key: keySet) {
             keys[i++] = key;
         }
         for (int j = 0; j < keys.length; j++) {
diff --git a/ojluni/src/main/java/java/io/File.java b/ojluni/src/main/java/java/io/File.java
index 0b152cc..01e41f1 100644
--- a/ojluni/src/main/java/java/io/File.java
+++ b/ojluni/src/main/java/java/io/File.java
@@ -32,8 +32,10 @@
 import java.net.URISyntaxException;
 import java.util.List;
 import java.util.ArrayList;
+import java.security.AccessController;
 import java.nio.file.Path;
 import java.nio.file.FileSystems;
+import sun.security.action.GetPropertyAction;
 
 /**
  * An abstract representation of file and directory pathnames.
@@ -127,7 +129,7 @@
  * created, the abstract pathname represented by a <code>File</code> object
  * will never change.
  *
- * <h4>Interoperability with {@code java.nio.file} package</h4>
+ * <h3>Interoperability with {@code java.nio.file} package</h3>
  *
  * <p> The <a href="../../java/nio/file/package-summary.html">{@code java.nio.file}</a>
  * package defines interfaces and classes for the Java virtual machine to access
@@ -156,7 +158,7 @@
     /**
      * The FileSystem object representing the platform's local file system.
      */
-    static private final FileSystem fs = FileSystem.getFileSystem();
+    private static final FileSystem fs = DefaultFileSystem.getFileSystem();
 
     /**
      * This abstract pathname's normalized pathname string. A normalized
@@ -165,7 +167,7 @@
      *
      * @serial
      */
-    private String path;
+    private final String path;
 
     /**
      * Enum type that indicates the status of a file path.
@@ -197,7 +199,7 @@
      * The length of this abstract pathname's prefix, or zero if it has no
      * prefix.
      */
-    private transient int prefixLength;
+    private final transient int prefixLength;
 
     /**
      * Returns the length of this abstract pathname's prefix.
@@ -728,6 +730,8 @@
 
     /* -- Attribute accessors -- */
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * Tests whether the application can read the file denoted by this
      * abstract pathname.
@@ -752,6 +756,8 @@
         return fs.checkAccess(this, FileSystem.ACCESS_READ);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * Tests whether the application can modify the file denoted by this
      * abstract pathname.
@@ -1434,11 +1440,13 @@
         return fs.setLastModifiedTime(this, time);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * Marks the file or directory named by this abstract pathname so that
-     * only read operations are allowed.  After invoking this method the file
-     * or directory is guaranteed not to change until it is either deleted or
-     * marked to allow write access.  Whether or not a read-only file or
+     * only read operations are allowed. After invoking this method the file
+     * or directory will not change until it is either deleted or marked
+     * to allow write access. Whether or not a read-only file or
      * directory may be deleted depends upon the underlying system.
      *
      * @return <code>true</code> if and only if the operation succeeded;
@@ -1462,6 +1470,8 @@
         return fs.setReadOnly(this);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * Sets the owner's or everybody's write permission for this abstract
      * pathname.
@@ -1503,6 +1513,8 @@
         return fs.setPermission(this, FileSystem.ACCESS_WRITE, writable, ownerOnly);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * A convenience method to set the owner's write permission for this abstract
      * pathname.
@@ -1532,6 +1544,8 @@
         return setWritable(writable, true);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * Sets the owner's or everybody's read permission for this abstract
      * pathname.
@@ -1576,6 +1590,8 @@
         return fs.setPermission(this, FileSystem.ACCESS_READ, readable, ownerOnly);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * A convenience method to set the owner's read permission for this abstract
      * pathname.
@@ -1608,6 +1624,8 @@
         return setReadable(readable, true);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * Sets the owner's or everybody's execute permission for this abstract
      * pathname.
@@ -1652,9 +1670,11 @@
         return fs.setPermission(this, FileSystem.ACCESS_EXECUTE, executable, ownerOnly);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
-     * A convenience method to set the owner's execute permission for this abstract
-     * pathname.
+     * A convenience method to set the owner's execute permission for this
+     * abstract pathname.
      *
      * <p>An invocation of this method of the form <tt>file.setExcutable(arg)</tt>
      * behaves in exactly the same way as the invocation
@@ -1670,7 +1690,7 @@
      *           operation will fail if the user does not have permission to
      *           change the access permissions of this abstract pathname.  If
      *           <code>executable</code> is <code>false</code> and the underlying
-     *           file system does not implement an excute permission, then the
+     *           file system does not implement an execute permission, then the
      *           operation will fail.
      *
      * @throws  SecurityException
@@ -1684,6 +1704,8 @@
         return setExecutable(executable, true);
     }
 
+    // Android-changed. Removed javadoc comment about special privileges
+    // that doesn't make sense on android
     /**
      * Tests whether the application can execute the file denoted by this
      * abstract pathname.
@@ -1836,24 +1858,45 @@
     }
 
     /* -- Temporary files -- */
+    private static class TempDirectory {
+        private TempDirectory() { }
 
-    // file name generation
-    private static File generateTempFile(String prefix, String suffix, File dir)
+        // Android-changed: Don't cache java.io.tmpdir value
+        // temporary directory location
+        // private static final File tmpdir = new File(AccessController
+        //     .doPrivileged(new GetPropertyAction("java.io.tmpdir")));
+        // static File location() {
+        //     return tmpdir;
+        // }
+
+        // file name generation
+        static File generateFile(String prefix, String suffix, File dir)
             throws IOException
-    {
-        // Android-changed: Use Math.randomIntInternal. This (pseudo) random number
-        // is initialized post-fork
-        int n = Math.randomIntInternal();
-        if (n == Integer.MIN_VALUE) {
-            n = 0;      // corner case
-        } else {
-            n = Math.abs(n);
+        {
+            // Android-changed: Use Math.randomIntInternal. This (pseudo) random number
+            // is initialized post-fork
+
+            long n = Math.randomLongInternal();
+            if (n == Long.MIN_VALUE) {
+                n = 0;      // corner case
+            } else {
+                n = Math.abs(n);
+            }
+
+            // Android changed: Reject invalid file prefixes
+            // Use only the file name from the supplied prefix
+            //prefix = (new File(prefix)).getName();
+
+            String name = prefix + Long.toString(n) + suffix;
+            File f = new File(dir, name);
+            if (!name.equals(f.getName()) || f.isInvalid()) {
+                if (System.getSecurityManager() != null)
+                    throw new IOException("Unable to create temporary file");
+                else
+                    throw new IOException("Unable to create temporary file, " + f);
+            }
+            return f;
         }
-        String name = prefix + Integer.toString(n) + suffix;
-        File f = new File(dir, name);
-        if (!name.equals(f.getName()))
-            throw new IOException("Unable to create temporary file");
-        return f;
     }
 
     /**
@@ -1934,21 +1977,30 @@
         if (suffix == null)
             suffix = ".tmp";
 
+
         File tmpdir = (directory != null) ? directory
                                           : new File(System.getProperty("java.io.tmpdir", "."));
+        //SecurityManager sm = System.getSecurityManager();
         File f;
-        try {
-            do {
-                f = generateTempFile(prefix, suffix, tmpdir);
-            } while (f.exists());
-            if (!f.createNewFile())
-                throw new IOException("Unable to create temporary file");
-        } catch (SecurityException se) {
-            // don't reveal temporary directory location
-            if (directory == null)
-                throw new SecurityException("Unable to create temporary file");
-            throw se;
-        }
+        do {
+            f = TempDirectory.generateFile(prefix, suffix, tmpdir);
+
+            // Android change: sm is always null on android
+            // if (sm != null) {
+            //     try {
+            //         sm.checkWrite(f.getPath());
+            //     } catch (SecurityException se) {
+            //         // don't reveal temporary directory location
+            //         if (directory == null)
+            //             throw new SecurityException("Unable to create temporary file");
+            //         throw se;
+            //     }
+            // }
+        } while ((fs.getBooleanAttributes(f) & FileSystem.BA_EXISTS) != 0);
+
+        if (!fs.createFileExclusively(f.getPath()))
+            throw new IOException("Unable to create temporary file");
+
         return f;
     }
 
@@ -2078,7 +2130,7 @@
         throws IOException
     {
         s.defaultWriteObject();
-        s.writeChar(this.separatorChar); // Add the separator character
+        s.writeChar(separatorChar); // Add the separator character
     }
 
     /**
@@ -2095,10 +2147,28 @@
         char sep = s.readChar(); // read the previous separator char
         if (sep != separatorChar)
             pathField = pathField.replace(sep, separatorChar);
-        this.path = fs.normalize(pathField);
-        this.prefixLength = fs.prefixLength(this.path);
+        String path = fs.normalize(pathField);
+        UNSAFE.putObject(this, PATH_OFFSET, path);
+        UNSAFE.putIntVolatile(this, PREFIX_LENGTH_OFFSET, fs.prefixLength(path));
     }
 
+    private static final long PATH_OFFSET;
+    private static final long PREFIX_LENGTH_OFFSET;
+    private static final sun.misc.Unsafe UNSAFE;
+    static {
+        try {
+            sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
+            PATH_OFFSET = unsafe.objectFieldOffset(
+                    File.class.getDeclaredField("path"));
+            PREFIX_LENGTH_OFFSET = unsafe.objectFieldOffset(
+                    File.class.getDeclaredField("prefixLength"));
+            UNSAFE = unsafe;
+        } catch (ReflectiveOperationException e) {
+            throw new Error(e);
+        }
+    }
+
+
     /** use serialVersionUID from JDK 1.0.2 for interoperability */
     private static final long serialVersionUID = 301077366599181567L;
 
diff --git a/ojluni/src/main/java/java/lang/Math.java b/ojluni/src/main/java/java/lang/Math.java
index e96cc58..930d6c2 100644
--- a/ojluni/src/main/java/java/lang/Math.java
+++ b/ojluni/src/main/java/java/lang/Math.java
@@ -754,6 +754,13 @@
     }
 
     /**
+     * @hide for internal use only.
+     */
+    public static long randomLongInternal() {
+        return RandomNumberGeneratorHolder.randomNumberGenerator.nextLong();
+    }
+
+    /**
      * Returns the sum of its arguments,
      * throwing an exception if the result overflows an {@code int}.
      *
diff --git a/ojluni/src/main/java/java/lang/invoke/MethodHandles.java b/ojluni/src/main/java/java/lang/invoke/MethodHandles.java
new file mode 100644
index 0000000..17adc59
--- /dev/null
+++ b/ojluni/src/main/java/java/lang/invoke/MethodHandles.java
@@ -0,0 +1,2539 @@
+/*
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang.invoke;
+
+import java.lang.reflect.*;
+import java.util.List;
+import java.util.Arrays;
+
+import dalvik.system.VMStack;
+import sun.invoke.util.VerifyAccess;
+import sun.invoke.util.Wrapper;
+import static java.lang.invoke.MethodHandleStatics.*;
+
+/**
+ * This class consists exclusively of static methods that operate on or return
+ * method handles. They fall into several categories:
+ * <ul>
+ * <li>Lookup methods which help create method handles for methods and fields.
+ * <li>Combinator methods, which combine or transform pre-existing method handles into new ones.
+ * <li>Other factory methods to create method handles that emulate other common JVM operations or control flow patterns.
+ * </ul>
+ * <p>
+ * @author John Rose, JSR 292 EG
+ * @since 1.7
+ */
+public class MethodHandles {
+
+    private MethodHandles() { }  // do not instantiate
+
+    // Android-changed: We do not use MemberName / MethodHandleImpl.
+    //
+    // private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory();
+    // static { MethodHandleImpl.initStatics(); }
+    // See IMPL_LOOKUP below.
+
+    //// Method handle creation from ordinary methods.
+
+    /**
+     * Returns a {@link Lookup lookup object} with
+     * full capabilities to emulate all supported bytecode behaviors of the caller.
+     * These capabilities include <a href="MethodHandles.Lookup.html#privacc">private access</a> to the caller.
+     * Factory methods on the lookup object can create
+     * <a href="MethodHandleInfo.html#directmh">direct method handles</a>
+     * for any member that the caller has access to via bytecodes,
+     * including protected and private fields and methods.
+     * This lookup object is a <em>capability</em> which may be delegated to trusted agents.
+     * Do not store it in place where untrusted code can access it.
+     * <p>
+     * This method is caller sensitive, which means that it may return different
+     * values to different callers.
+     * <p>
+     * For any given caller class {@code C}, the lookup object returned by this call
+     * has equivalent capabilities to any lookup object
+     * supplied by the JVM to the bootstrap method of an
+     * <a href="package-summary.html#indyinsn">invokedynamic instruction</a>
+     * executing in the same caller class {@code C}.
+     * @return a lookup object for the caller of this method, with private access
+     */
+    // Android-changed: Remove caller sensitive.
+    // @CallerSensitive
+    public static Lookup lookup() {
+        // Android-changed: Do not use Reflection.getCallerClass().
+        return new Lookup(VMStack.getStackClass1());
+    }
+
+    /**
+     * Returns a {@link Lookup lookup object} which is trusted minimally.
+     * It can only be used to create method handles to
+     * publicly accessible fields and methods.
+     * <p>
+     * As a matter of pure convention, the {@linkplain Lookup#lookupClass lookup class}
+     * of this lookup object will be {@link java.lang.Object}.
+     *
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * The lookup class can be changed to any other class {@code C} using an expression of the form
+     * {@link Lookup#in publicLookup().in(C.class)}.
+     * Since all classes have equal access to public names,
+     * such a change would confer no new access rights.
+     * A public lookup object is always subject to
+     * <a href="MethodHandles.Lookup.html#secmgr">security manager checks</a>.
+     * Also, it cannot access
+     * <a href="MethodHandles.Lookup.html#callsens">caller sensitive methods</a>.
+     * @return a lookup object which is trusted minimally
+     */
+    public static Lookup publicLookup() {
+        return Lookup.PUBLIC_LOOKUP;
+    }
+
+    /**
+     * Performs an unchecked "crack" of a
+     * <a href="MethodHandleInfo.html#directmh">direct method handle</a>.
+     * The result is as if the user had obtained a lookup object capable enough
+     * to crack the target method handle, called
+     * {@link java.lang.invoke.MethodHandles.Lookup#revealDirect Lookup.revealDirect}
+     * on the target to obtain its symbolic reference, and then called
+     * {@link java.lang.invoke.MethodHandleInfo#reflectAs MethodHandleInfo.reflectAs}
+     * to resolve the symbolic reference to a member.
+     * <p>
+     * If there is a security manager, its {@code checkPermission} method
+     * is called with a {@code ReflectPermission("suppressAccessChecks")} permission.
+     * @param <T> the desired type of the result, either {@link Member} or a subtype
+     * @param target a direct method handle to crack into symbolic reference components
+     * @param expected a class object representing the desired result type {@code T}
+     * @return a reference to the method, constructor, or field object
+     * @exception SecurityException if the caller is not privileged to call {@code setAccessible}
+     * @exception NullPointerException if either argument is {@code null}
+     * @exception IllegalArgumentException if the target is not a direct method handle
+     * @exception ClassCastException if the member is not of the expected type
+     * @since 1.8
+     */
+    public static <T extends Member> T
+    reflectAs(Class<T> expected, MethodHandle target) {
+        SecurityManager smgr = System.getSecurityManager();
+        if (smgr != null)  smgr.checkPermission(ACCESS_PERMISSION);
+        Lookup lookup = Lookup.IMPL_LOOKUP;  // use maximally privileged lookup
+        return lookup.revealDirect(target).reflectAs(expected, lookup);
+    }
+    // Copied from AccessibleObject, as used by Method.setAccessible, etc.:
+    static final private java.security.Permission ACCESS_PERMISSION =
+        new ReflectPermission("suppressAccessChecks");
+
+    /**
+     * A <em>lookup object</em> is a factory for creating method handles,
+     * when the creation requires access checking.
+     * Method handles do not perform
+     * access checks when they are called, but rather when they are created.
+     * Therefore, method handle access
+     * restrictions must be enforced when a method handle is created.
+     * The caller class against which those restrictions are enforced
+     * is known as the {@linkplain #lookupClass lookup class}.
+     * <p>
+     * A lookup class which needs to create method handles will call
+     * {@link MethodHandles#lookup MethodHandles.lookup} to create a factory for itself.
+     * When the {@code Lookup} factory object is created, the identity of the lookup class is
+     * determined, and securely stored in the {@code Lookup} object.
+     * The lookup class (or its delegates) may then use factory methods
+     * on the {@code Lookup} object to create method handles for access-checked members.
+     * This includes all methods, constructors, and fields which are allowed to the lookup class,
+     * even private ones.
+     *
+     * <h1><a name="lookups"></a>Lookup Factory Methods</h1>
+     * The factory methods on a {@code Lookup} object correspond to all major
+     * use cases for methods, constructors, and fields.
+     * Each method handle created by a factory method is the functional
+     * equivalent of a particular <em>bytecode behavior</em>.
+     * (Bytecode behaviors are described in section 5.4.3.5 of the Java Virtual Machine Specification.)
+     * Here is a summary of the correspondence between these factory methods and
+     * the behavior the resulting method handles:
+     * <table border=1 cellpadding=5 summary="lookup method behaviors">
+     * <tr>
+     *     <th><a name="equiv"></a>lookup expression</th>
+     *     <th>member</th>
+     *     <th>bytecode behavior</th>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#findGetter lookup.findGetter(C.class,"f",FT.class)}</td>
+     *     <td>{@code FT f;}</td><td>{@code (T) this.f;}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#findStaticGetter lookup.findStaticGetter(C.class,"f",FT.class)}</td>
+     *     <td>{@code static}<br>{@code FT f;}</td><td>{@code (T) C.f;}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#findSetter lookup.findSetter(C.class,"f",FT.class)}</td>
+     *     <td>{@code FT f;}</td><td>{@code this.f = x;}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#findStaticSetter lookup.findStaticSetter(C.class,"f",FT.class)}</td>
+     *     <td>{@code static}<br>{@code FT f;}</td><td>{@code C.f = arg;}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#findVirtual lookup.findVirtual(C.class,"m",MT)}</td>
+     *     <td>{@code T m(A*);}</td><td>{@code (T) this.m(arg*);}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#findStatic lookup.findStatic(C.class,"m",MT)}</td>
+     *     <td>{@code static}<br>{@code T m(A*);}</td><td>{@code (T) C.m(arg*);}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#findSpecial lookup.findSpecial(C.class,"m",MT,this.class)}</td>
+     *     <td>{@code T m(A*);}</td><td>{@code (T) super.m(arg*);}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#findConstructor lookup.findConstructor(C.class,MT)}</td>
+     *     <td>{@code C(A*);}</td><td>{@code new C(arg*);}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#unreflectGetter lookup.unreflectGetter(aField)}</td>
+     *     <td>({@code static})?<br>{@code FT f;}</td><td>{@code (FT) aField.get(thisOrNull);}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#unreflectSetter lookup.unreflectSetter(aField)}</td>
+     *     <td>({@code static})?<br>{@code FT f;}</td><td>{@code aField.set(thisOrNull, arg);}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}</td>
+     *     <td>({@code static})?<br>{@code T m(A*);}</td><td>{@code (T) aMethod.invoke(thisOrNull, arg*);}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#unreflectConstructor lookup.unreflectConstructor(aConstructor)}</td>
+     *     <td>{@code C(A*);}</td><td>{@code (C) aConstructor.newInstance(arg*);}</td>
+     * </tr>
+     * <tr>
+     *     <td>{@link java.lang.invoke.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}</td>
+     *     <td>({@code static})?<br>{@code T m(A*);}</td><td>{@code (T) aMethod.invoke(thisOrNull, arg*);}</td>
+     * </tr>
+     * </table>
+     *
+     * Here, the type {@code C} is the class or interface being searched for a member,
+     * documented as a parameter named {@code refc} in the lookup methods.
+     * The method type {@code MT} is composed from the return type {@code T}
+     * and the sequence of argument types {@code A*}.
+     * The constructor also has a sequence of argument types {@code A*} and
+     * is deemed to return the newly-created object of type {@code C}.
+     * Both {@code MT} and the field type {@code FT} are documented as a parameter named {@code type}.
+     * The formal parameter {@code this} stands for the self-reference of type {@code C};
+     * if it is present, it is always the leading argument to the method handle invocation.
+     * (In the case of some {@code protected} members, {@code this} may be
+     * restricted in type to the lookup class; see below.)
+     * The name {@code arg} stands for all the other method handle arguments.
+     * In the code examples for the Core Reflection API, the name {@code thisOrNull}
+     * stands for a null reference if the accessed method or field is static,
+     * and {@code this} otherwise.
+     * The names {@code aMethod}, {@code aField}, and {@code aConstructor} stand
+     * for reflective objects corresponding to the given members.
+     * <p>
+     * In cases where the given member is of variable arity (i.e., a method or constructor)
+     * the returned method handle will also be of {@linkplain MethodHandle#asVarargsCollector variable arity}.
+     * In all other cases, the returned method handle will be of fixed arity.
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * The equivalence between looked-up method handles and underlying
+     * class members and bytecode behaviors
+     * can break down in a few ways:
+     * <ul style="font-size:smaller;">
+     * <li>If {@code C} is not symbolically accessible from the lookup class's loader,
+     * the lookup can still succeed, even when there is no equivalent
+     * Java expression or bytecoded constant.
+     * <li>Likewise, if {@code T} or {@code MT}
+     * is not symbolically accessible from the lookup class's loader,
+     * the lookup can still succeed.
+     * For example, lookups for {@code MethodHandle.invokeExact} and
+     * {@code MethodHandle.invoke} will always succeed, regardless of requested type.
+     * <li>If there is a security manager installed, it can forbid the lookup
+     * on various grounds (<a href="MethodHandles.Lookup.html#secmgr">see below</a>).
+     * By contrast, the {@code ldc} instruction on a {@code CONSTANT_MethodHandle}
+     * constant is not subject to security manager checks.
+     * <li>If the looked-up method has a
+     * <a href="MethodHandle.html#maxarity">very large arity</a>,
+     * the method handle creation may fail, due to the method handle
+     * type having too many parameters.
+     * </ul>
+     *
+     * <h1><a name="access"></a>Access checking</h1>
+     * Access checks are applied in the factory methods of {@code Lookup},
+     * when a method handle is created.
+     * This is a key difference from the Core Reflection API, since
+     * {@link java.lang.reflect.Method#invoke java.lang.reflect.Method.invoke}
+     * performs access checking against every caller, on every call.
+     * <p>
+     * All access checks start from a {@code Lookup} object, which
+     * compares its recorded lookup class against all requests to
+     * create method handles.
+     * A single {@code Lookup} object can be used to create any number
+     * of access-checked method handles, all checked against a single
+     * lookup class.
+     * <p>
+     * A {@code Lookup} object can be shared with other trusted code,
+     * such as a metaobject protocol.
+     * A shared {@code Lookup} object delegates the capability
+     * to create method handles on private members of the lookup class.
+     * Even if privileged code uses the {@code Lookup} object,
+     * the access checking is confined to the privileges of the
+     * original lookup class.
+     * <p>
+     * A lookup can fail, because
+     * the containing class is not accessible to the lookup class, or
+     * because the desired class member is missing, or because the
+     * desired class member is not accessible to the lookup class, or
+     * because the lookup object is not trusted enough to access the member.
+     * In any of these cases, a {@code ReflectiveOperationException} will be
+     * thrown from the attempted lookup.  The exact class will be one of
+     * the following:
+     * <ul>
+     * <li>NoSuchMethodException &mdash; if a method is requested but does not exist
+     * <li>NoSuchFieldException &mdash; if a field is requested but does not exist
+     * <li>IllegalAccessException &mdash; if the member exists but an access check fails
+     * </ul>
+     * <p>
+     * In general, the conditions under which a method handle may be
+     * looked up for a method {@code M} are no more restrictive than the conditions
+     * under which the lookup class could have compiled, verified, and resolved a call to {@code M}.
+     * Where the JVM would raise exceptions like {@code NoSuchMethodError},
+     * a method handle lookup will generally raise a corresponding
+     * checked exception, such as {@code NoSuchMethodException}.
+     * And the effect of invoking the method handle resulting from the lookup
+     * is <a href="MethodHandles.Lookup.html#equiv">exactly equivalent</a>
+     * to executing the compiled, verified, and resolved call to {@code M}.
+     * The same point is true of fields and constructors.
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * Access checks only apply to named and reflected methods,
+     * constructors, and fields.
+     * Other method handle creation methods, such as
+     * {@link MethodHandle#asType MethodHandle.asType},
+     * do not require any access checks, and are used
+     * independently of any {@code Lookup} object.
+     * <p>
+     * If the desired member is {@code protected}, the usual JVM rules apply,
+     * including the requirement that the lookup class must be either be in the
+     * same package as the desired member, or must inherit that member.
+     * (See the Java Virtual Machine Specification, sections 4.9.2, 5.4.3.5, and 6.4.)
+     * In addition, if the desired member is a non-static field or method
+     * in a different package, the resulting method handle may only be applied
+     * to objects of the lookup class or one of its subclasses.
+     * This requirement is enforced by narrowing the type of the leading
+     * {@code this} parameter from {@code C}
+     * (which will necessarily be a superclass of the lookup class)
+     * to the lookup class itself.
+     * <p>
+     * The JVM imposes a similar requirement on {@code invokespecial} instruction,
+     * that the receiver argument must match both the resolved method <em>and</em>
+     * the current class.  Again, this requirement is enforced by narrowing the
+     * type of the leading parameter to the resulting method handle.
+     * (See the Java Virtual Machine Specification, section 4.10.1.9.)
+     * <p>
+     * The JVM represents constructors and static initializer blocks as internal methods
+     * with special names ({@code "<init>"} and {@code "<clinit>"}).
+     * The internal syntax of invocation instructions allows them to refer to such internal
+     * methods as if they were normal methods, but the JVM bytecode verifier rejects them.
+     * A lookup of such an internal method will produce a {@code NoSuchMethodException}.
+     * <p>
+     * In some cases, access between nested classes is obtained by the Java compiler by creating
+     * an wrapper method to access a private method of another class
+     * in the same top-level declaration.
+     * For example, a nested class {@code C.D}
+     * can access private members within other related classes such as
+     * {@code C}, {@code C.D.E}, or {@code C.B},
+     * but the Java compiler may need to generate wrapper methods in
+     * those related classes.  In such cases, a {@code Lookup} object on
+     * {@code C.E} would be unable to those private members.
+     * A workaround for this limitation is the {@link Lookup#in Lookup.in} method,
+     * which can transform a lookup on {@code C.E} into one on any of those other
+     * classes, without special elevation of privilege.
+     * <p>
+     * The accesses permitted to a given lookup object may be limited,
+     * according to its set of {@link #lookupModes lookupModes},
+     * to a subset of members normally accessible to the lookup class.
+     * For example, the {@link MethodHandles#publicLookup publicLookup}
+     * method produces a lookup object which is only allowed to access
+     * public members in public classes.
+     * The caller sensitive method {@link MethodHandles#lookup lookup}
+     * produces a lookup object with full capabilities relative to
+     * its caller class, to emulate all supported bytecode behaviors.
+     * Also, the {@link Lookup#in Lookup.in} method may produce a lookup object
+     * with fewer access modes than the original lookup object.
+     *
+     * <p style="font-size:smaller;">
+     * <a name="privacc"></a>
+     * <em>Discussion of private access:</em>
+     * We say that a lookup has <em>private access</em>
+     * if its {@linkplain #lookupModes lookup modes}
+     * include the possibility of accessing {@code private} members.
+     * As documented in the relevant methods elsewhere,
+     * only lookups with private access possess the following capabilities:
+     * <ul style="font-size:smaller;">
+     * <li>access private fields, methods, and constructors of the lookup class
+     * <li>create method handles which invoke <a href="MethodHandles.Lookup.html#callsens">caller sensitive</a> methods,
+     *     such as {@code Class.forName}
+     * <li>create method handles which {@link Lookup#findSpecial emulate invokespecial} instructions
+     * <li>avoid <a href="MethodHandles.Lookup.html#secmgr">package access checks</a>
+     *     for classes accessible to the lookup class
+     * <li>create {@link Lookup#in delegated lookup objects} which have private access to other classes
+     *     within the same package member
+     * </ul>
+     * <p style="font-size:smaller;">
+     * Each of these permissions is a consequence of the fact that a lookup object
+     * with private access can be securely traced back to an originating class,
+     * whose <a href="MethodHandles.Lookup.html#equiv">bytecode behaviors</a> and Java language access permissions
+     * can be reliably determined and emulated by method handles.
+     *
+     * <h1><a name="secmgr"></a>Security manager interactions</h1>
+     * Although bytecode instructions can only refer to classes in
+     * a related class loader, this API can search for methods in any
+     * class, as long as a reference to its {@code Class} object is
+     * available.  Such cross-loader references are also possible with the
+     * Core Reflection API, and are impossible to bytecode instructions
+     * such as {@code invokestatic} or {@code getfield}.
+     * There is a {@linkplain java.lang.SecurityManager security manager API}
+     * to allow applications to check such cross-loader references.
+     * These checks apply to both the {@code MethodHandles.Lookup} API
+     * and the Core Reflection API
+     * (as found on {@link java.lang.Class Class}).
+     * <p>
+     * If a security manager is present, member lookups are subject to
+     * additional checks.
+     * From one to three calls are made to the security manager.
+     * Any of these calls can refuse access by throwing a
+     * {@link java.lang.SecurityException SecurityException}.
+     * Define {@code smgr} as the security manager,
+     * {@code lookc} as the lookup class of the current lookup object,
+     * {@code refc} as the containing class in which the member
+     * is being sought, and {@code defc} as the class in which the
+     * member is actually defined.
+     * The value {@code lookc} is defined as <em>not present</em>
+     * if the current lookup object does not have
+     * <a href="MethodHandles.Lookup.html#privacc">private access</a>.
+     * The calls are made according to the following rules:
+     * <ul>
+     * <li><b>Step 1:</b>
+     *     If {@code lookc} is not present, or if its class loader is not
+     *     the same as or an ancestor of the class loader of {@code refc},
+     *     then {@link SecurityManager#checkPackageAccess
+     *     smgr.checkPackageAccess(refcPkg)} is called,
+     *     where {@code refcPkg} is the package of {@code refc}.
+     * <li><b>Step 2:</b>
+     *     If the retrieved member is not public and
+     *     {@code lookc} is not present, then
+     *     {@link SecurityManager#checkPermission smgr.checkPermission}
+     *     with {@code RuntimePermission("accessDeclaredMembers")} is called.
+     * <li><b>Step 3:</b>
+     *     If the retrieved member is not public,
+     *     and if {@code lookc} is not present,
+     *     and if {@code defc} and {@code refc} are different,
+     *     then {@link SecurityManager#checkPackageAccess
+     *     smgr.checkPackageAccess(defcPkg)} is called,
+     *     where {@code defcPkg} is the package of {@code defc}.
+     * </ul>
+     * Security checks are performed after other access checks have passed.
+     * Therefore, the above rules presuppose a member that is public,
+     * or else that is being accessed from a lookup class that has
+     * rights to access the member.
+     *
+     * <h1><a name="callsens"></a>Caller sensitive methods</h1>
+     * A small number of Java methods have a special property called caller sensitivity.
+     * A <em>caller-sensitive</em> method can behave differently depending on the
+     * identity of its immediate caller.
+     * <p>
+     * If a method handle for a caller-sensitive method is requested,
+     * the general rules for <a href="MethodHandles.Lookup.html#equiv">bytecode behaviors</a> apply,
+     * but they take account of the lookup class in a special way.
+     * The resulting method handle behaves as if it were called
+     * from an instruction contained in the lookup class,
+     * so that the caller-sensitive method detects the lookup class.
+     * (By contrast, the invoker of the method handle is disregarded.)
+     * Thus, in the case of caller-sensitive methods,
+     * different lookup classes may give rise to
+     * differently behaving method handles.
+     * <p>
+     * In cases where the lookup object is
+     * {@link MethodHandles#publicLookup() publicLookup()},
+     * or some other lookup object without
+     * <a href="MethodHandles.Lookup.html#privacc">private access</a>,
+     * the lookup class is disregarded.
+     * In such cases, no caller-sensitive method handle can be created,
+     * access is forbidden, and the lookup fails with an
+     * {@code IllegalAccessException}.
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * For example, the caller-sensitive method
+     * {@link java.lang.Class#forName(String) Class.forName(x)}
+     * can return varying classes or throw varying exceptions,
+     * depending on the class loader of the class that calls it.
+     * A public lookup of {@code Class.forName} will fail, because
+     * there is no reasonable way to determine its bytecode behavior.
+     * <p style="font-size:smaller;">
+     * If an application caches method handles for broad sharing,
+     * it should use {@code publicLookup()} to create them.
+     * If there is a lookup of {@code Class.forName}, it will fail,
+     * and the application must take appropriate action in that case.
+     * It may be that a later lookup, perhaps during the invocation of a
+     * bootstrap method, can incorporate the specific identity
+     * of the caller, making the method accessible.
+     * <p style="font-size:smaller;">
+     * The function {@code MethodHandles.lookup} is caller sensitive
+     * so that there can be a secure foundation for lookups.
+     * Nearly all other methods in the JSR 292 API rely on lookup
+     * objects to check access requests.
+     */
+    public static final
+    class Lookup {
+        /** The class on behalf of whom the lookup is being performed. */
+        private final Class<?> lookupClass;
+
+        /** The allowed sorts of members which may be looked up (PUBLIC, etc.). */
+        private final int allowedModes;
+
+        /** A single-bit mask representing {@code public} access,
+         *  which may contribute to the result of {@link #lookupModes lookupModes}.
+         *  The value, {@code 0x01}, happens to be the same as the value of the
+         *  {@code public} {@linkplain java.lang.reflect.Modifier#PUBLIC modifier bit}.
+         */
+        public static final int PUBLIC = Modifier.PUBLIC;
+
+        /** A single-bit mask representing {@code private} access,
+         *  which may contribute to the result of {@link #lookupModes lookupModes}.
+         *  The value, {@code 0x02}, happens to be the same as the value of the
+         *  {@code private} {@linkplain java.lang.reflect.Modifier#PRIVATE modifier bit}.
+         */
+        public static final int PRIVATE = Modifier.PRIVATE;
+
+        /** A single-bit mask representing {@code protected} access,
+         *  which may contribute to the result of {@link #lookupModes lookupModes}.
+         *  The value, {@code 0x04}, happens to be the same as the value of the
+         *  {@code protected} {@linkplain java.lang.reflect.Modifier#PROTECTED modifier bit}.
+         */
+        public static final int PROTECTED = Modifier.PROTECTED;
+
+        /** A single-bit mask representing {@code package} access (default access),
+         *  which may contribute to the result of {@link #lookupModes lookupModes}.
+         *  The value is {@code 0x08}, which does not correspond meaningfully to
+         *  any particular {@linkplain java.lang.reflect.Modifier modifier bit}.
+         */
+        public static final int PACKAGE = Modifier.STATIC;
+
+        private static final int ALL_MODES = (PUBLIC | PRIVATE | PROTECTED | PACKAGE);
+        private static final int TRUSTED   = -1;
+
+        private static int fixmods(int mods) {
+            mods &= (ALL_MODES - PACKAGE);
+            return (mods != 0) ? mods : PACKAGE;
+        }
+
+        /** Tells which class is performing the lookup.  It is this class against
+         *  which checks are performed for visibility and access permissions.
+         *  <p>
+         *  The class implies a maximum level of access permission,
+         *  but the permissions may be additionally limited by the bitmask
+         *  {@link #lookupModes lookupModes}, which controls whether non-public members
+         *  can be accessed.
+         *  @return the lookup class, on behalf of which this lookup object finds members
+         */
+        public Class<?> lookupClass() {
+            return lookupClass;
+        }
+
+        // This is just for calling out to MethodHandleImpl.
+        private Class<?> lookupClassOrNull() {
+            return (allowedModes == TRUSTED) ? null : lookupClass;
+        }
+
+        /** Tells which access-protection classes of members this lookup object can produce.
+         *  The result is a bit-mask of the bits
+         *  {@linkplain #PUBLIC PUBLIC (0x01)},
+         *  {@linkplain #PRIVATE PRIVATE (0x02)},
+         *  {@linkplain #PROTECTED PROTECTED (0x04)},
+         *  and {@linkplain #PACKAGE PACKAGE (0x08)}.
+         *  <p>
+         *  A freshly-created lookup object
+         *  on the {@linkplain java.lang.invoke.MethodHandles#lookup() caller's class}
+         *  has all possible bits set, since the caller class can access all its own members.
+         *  A lookup object on a new lookup class
+         *  {@linkplain java.lang.invoke.MethodHandles.Lookup#in created from a previous lookup object}
+         *  may have some mode bits set to zero.
+         *  The purpose of this is to restrict access via the new lookup object,
+         *  so that it can access only names which can be reached by the original
+         *  lookup object, and also by the new lookup class.
+         *  @return the lookup modes, which limit the kinds of access performed by this lookup object
+         */
+        public int lookupModes() {
+            return allowedModes & ALL_MODES;
+        }
+
+        /** Embody the current class (the lookupClass) as a lookup class
+         * for method handle creation.
+         * Must be called by from a method in this package,
+         * which in turn is called by a method not in this package.
+         */
+        Lookup(Class<?> lookupClass) {
+            this(lookupClass, ALL_MODES);
+            // make sure we haven't accidentally picked up a privileged class:
+            checkUnprivilegedlookupClass(lookupClass, ALL_MODES);
+        }
+
+        private Lookup(Class<?> lookupClass, int allowedModes) {
+            this.lookupClass = lookupClass;
+            this.allowedModes = allowedModes;
+        }
+
+        /**
+         * Creates a lookup on the specified new lookup class.
+         * The resulting object will report the specified
+         * class as its own {@link #lookupClass lookupClass}.
+         * <p>
+         * However, the resulting {@code Lookup} object is guaranteed
+         * to have no more access capabilities than the original.
+         * In particular, access capabilities can be lost as follows:<ul>
+         * <li>If the new lookup class differs from the old one,
+         * protected members will not be accessible by virtue of inheritance.
+         * (Protected members may continue to be accessible because of package sharing.)
+         * <li>If the new lookup class is in a different package
+         * than the old one, protected and default (package) members will not be accessible.
+         * <li>If the new lookup class is not within the same package member
+         * as the old one, private members will not be accessible.
+         * <li>If the new lookup class is not accessible to the old lookup class,
+         * then no members, not even public members, will be accessible.
+         * (In all other cases, public members will continue to be accessible.)
+         * </ul>
+         *
+         * @param requestedLookupClass the desired lookup class for the new lookup object
+         * @return a lookup object which reports the desired lookup class
+         * @throws NullPointerException if the argument is null
+         */
+        public Lookup in(Class<?> requestedLookupClass) {
+            requestedLookupClass.getClass();  // null check
+            if (allowedModes == TRUSTED)  // IMPL_LOOKUP can make any lookup at all
+                return new Lookup(requestedLookupClass, ALL_MODES);
+            if (requestedLookupClass == this.lookupClass)
+                return this;  // keep same capabilities
+            int newModes = (allowedModes & (ALL_MODES & ~PROTECTED));
+            if ((newModes & PACKAGE) != 0
+                && !VerifyAccess.isSamePackage(this.lookupClass, requestedLookupClass)) {
+                newModes &= ~(PACKAGE|PRIVATE);
+            }
+            // Allow nestmate lookups to be created without special privilege:
+            if ((newModes & PRIVATE) != 0
+                && !VerifyAccess.isSamePackageMember(this.lookupClass, requestedLookupClass)) {
+                newModes &= ~PRIVATE;
+            }
+            if ((newModes & PUBLIC) != 0
+                && !VerifyAccess.isClassAccessible(requestedLookupClass, this.lookupClass, allowedModes)) {
+                // The requested class it not accessible from the lookup class.
+                // No permissions.
+                newModes = 0;
+            }
+            checkUnprivilegedlookupClass(requestedLookupClass, newModes);
+            return new Lookup(requestedLookupClass, newModes);
+        }
+
+        // Make sure outer class is initialized first.
+        //
+        // Android-changed: Removed unnecessary reference to IMPL_NAMES.
+        // static { IMPL_NAMES.getClass(); }
+
+        /** Version of lookup which is trusted minimally.
+         *  It can only be used to create method handles to
+         *  publicly accessible members.
+         */
+        static final Lookup PUBLIC_LOOKUP = new Lookup(Object.class, PUBLIC);
+
+        /** Package-private version of lookup which is trusted. */
+        static final Lookup IMPL_LOOKUP = new Lookup(Object.class, TRUSTED);
+
+        private static void checkUnprivilegedlookupClass(Class<?> lookupClass, int allowedModes) {
+            String name = lookupClass.getName();
+            if (name.startsWith("java.lang.invoke."))
+                throw newIllegalArgumentException("illegal lookupClass: "+lookupClass);
+
+            // For caller-sensitive MethodHandles.lookup()
+            // disallow lookup more restricted packages
+            //
+            // Android-changed: The bootstrap classloader isn't null.
+            if (allowedModes == ALL_MODES &&
+                    lookupClass.getClassLoader() == Object.class.getClassLoader()) {
+                if (name.startsWith("java.") ||
+                        (name.startsWith("sun.") && !name.startsWith("sun.invoke."))) {
+                    throw newIllegalArgumentException("illegal lookupClass: " + lookupClass);
+                }
+            }
+        }
+
+        /**
+         * Displays the name of the class from which lookups are to be made.
+         * (The name is the one reported by {@link java.lang.Class#getName() Class.getName}.)
+         * If there are restrictions on the access permitted to this lookup,
+         * this is indicated by adding a suffix to the class name, consisting
+         * of a slash and a keyword.  The keyword represents the strongest
+         * allowed access, and is chosen as follows:
+         * <ul>
+         * <li>If no access is allowed, the suffix is "/noaccess".
+         * <li>If only public access is allowed, the suffix is "/public".
+         * <li>If only public and package access are allowed, the suffix is "/package".
+         * <li>If only public, package, and private access are allowed, the suffix is "/private".
+         * </ul>
+         * If none of the above cases apply, it is the case that full
+         * access (public, package, private, and protected) is allowed.
+         * In this case, no suffix is added.
+         * This is true only of an object obtained originally from
+         * {@link java.lang.invoke.MethodHandles#lookup MethodHandles.lookup}.
+         * Objects created by {@link java.lang.invoke.MethodHandles.Lookup#in Lookup.in}
+         * always have restricted access, and will display a suffix.
+         * <p>
+         * (It may seem strange that protected access should be
+         * stronger than private access.  Viewed independently from
+         * package access, protected access is the first to be lost,
+         * because it requires a direct subclass relationship between
+         * caller and callee.)
+         * @see #in
+         */
+        @Override
+        public String toString() {
+            String cname = lookupClass.getName();
+            switch (allowedModes) {
+            case 0:  // no privileges
+                return cname + "/noaccess";
+            case PUBLIC:
+                return cname + "/public";
+            case PUBLIC|PACKAGE:
+                return cname + "/package";
+            case ALL_MODES & ~PROTECTED:
+                return cname + "/private";
+            case ALL_MODES:
+                return cname;
+            case TRUSTED:
+                return "/trusted";  // internal only; not exported
+            default:  // Should not happen, but it's a bitfield...
+                cname = cname + "/" + Integer.toHexString(allowedModes);
+                assert(false) : cname;
+                return cname;
+            }
+        }
+
+        /**
+         * Produces a method handle for a static method.
+         * The type of the method handle will be that of the method.
+         * (Since static methods do not take receivers, there is no
+         * additional receiver argument inserted into the method handle type,
+         * as there would be with {@link #findVirtual findVirtual} or {@link #findSpecial findSpecial}.)
+         * The method and all its argument types must be accessible to the lookup object.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
+         * <p>
+         * If the returned method handle is invoked, the method's class will
+         * be initialized, if it has not already been initialized.
+         * <p><b>Example:</b>
+         * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle MH_asList = publicLookup().findStatic(Arrays.class,
+  "asList", methodType(List.class, Object[].class));
+assertEquals("[x, y]", MH_asList.invoke("x", "y").toString());
+         * }</pre></blockquote>
+         * @param refc the class from which the method is accessed
+         * @param name the name of the method
+         * @param type the type of the method
+         * @return the desired method handle
+         * @throws NoSuchMethodException if the method does not exist
+         * @throws IllegalAccessException if access checking fails,
+         *                                or if the method is not {@code static},
+         *                                or if the method's variable arity modifier bit
+         *                                is set and {@code asVarargsCollector} fails
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         */
+        public
+        MethodHandle findStatic(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.findStatic is not implemented");
+        }
+
+        /**
+         * Produces a method handle for a virtual method.
+         * The type of the method handle will be that of the method,
+         * with the receiver type (usually {@code refc}) prepended.
+         * The method and all its argument types must be accessible to the lookup object.
+         * <p>
+         * When called, the handle will treat the first argument as a receiver
+         * and dispatch on the receiver's type to determine which method
+         * implementation to enter.
+         * (The dispatching action is identical with that performed by an
+         * {@code invokevirtual} or {@code invokeinterface} instruction.)
+         * <p>
+         * The first argument will be of type {@code refc} if the lookup
+         * class has full privileges to access the member.  Otherwise
+         * the member must be {@code protected} and the first argument
+         * will be restricted in type to the lookup class.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
+         * <p>
+         * Because of the general <a href="MethodHandles.Lookup.html#equiv">equivalence</a> between {@code invokevirtual}
+         * instructions and method handles produced by {@code findVirtual},
+         * if the class is {@code MethodHandle} and the name string is
+         * {@code invokeExact} or {@code invoke}, the resulting
+         * method handle is equivalent to one produced by
+         * {@link java.lang.invoke.MethodHandles#exactInvoker MethodHandles.exactInvoker} or
+         * {@link java.lang.invoke.MethodHandles#invoker MethodHandles.invoker}
+         * with the same {@code type} argument.
+         *
+         * <b>Example:</b>
+         * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle MH_concat = publicLookup().findVirtual(String.class,
+  "concat", methodType(String.class, String.class));
+MethodHandle MH_hashCode = publicLookup().findVirtual(Object.class,
+  "hashCode", methodType(int.class));
+MethodHandle MH_hashCode_String = publicLookup().findVirtual(String.class,
+  "hashCode", methodType(int.class));
+assertEquals("xy", (String) MH_concat.invokeExact("x", "y"));
+assertEquals("xy".hashCode(), (int) MH_hashCode.invokeExact((Object)"xy"));
+assertEquals("xy".hashCode(), (int) MH_hashCode_String.invokeExact("xy"));
+// interface method:
+MethodHandle MH_subSequence = publicLookup().findVirtual(CharSequence.class,
+  "subSequence", methodType(CharSequence.class, int.class, int.class));
+assertEquals("def", MH_subSequence.invoke("abcdefghi", 3, 6).toString());
+// constructor "internal method" must be accessed differently:
+MethodType MT_newString = methodType(void.class); //()V for new String()
+try { assertEquals("impossible", lookup()
+        .findVirtual(String.class, "<init>", MT_newString));
+ } catch (NoSuchMethodException ex) { } // OK
+MethodHandle MH_newString = publicLookup()
+  .findConstructor(String.class, MT_newString);
+assertEquals("", (String) MH_newString.invokeExact());
+         * }</pre></blockquote>
+         *
+         * @param refc the class or interface from which the method is accessed
+         * @param name the name of the method
+         * @param type the type of the method, with the receiver argument omitted
+         * @return the desired method handle
+         * @throws NoSuchMethodException if the method does not exist
+         * @throws IllegalAccessException if access checking fails,
+         *                                or if the method is {@code static}
+         *                                or if the method's variable arity modifier bit
+         *                                is set and {@code asVarargsCollector} fails
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         */
+        public MethodHandle findVirtual(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.findVirtual is not implemented");
+        }
+
+        /**
+         * Produces a method handle which creates an object and initializes it, using
+         * the constructor of the specified type.
+         * The parameter types of the method handle will be those of the constructor,
+         * while the return type will be a reference to the constructor's class.
+         * The constructor and all its argument types must be accessible to the lookup object.
+         * <p>
+         * The requested type must have a return type of {@code void}.
+         * (This is consistent with the JVM's treatment of constructor type descriptors.)
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the constructor's variable arity modifier bit ({@code 0x0080}) is set.
+         * <p>
+         * If the returned method handle is invoked, the constructor's class will
+         * be initialized, if it has not already been initialized.
+         * <p><b>Example:</b>
+         * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle MH_newArrayList = publicLookup().findConstructor(
+  ArrayList.class, methodType(void.class, Collection.class));
+Collection orig = Arrays.asList("x", "y");
+Collection copy = (ArrayList) MH_newArrayList.invokeExact(orig);
+assert(orig != copy);
+assertEquals(orig, copy);
+// a variable-arity constructor:
+MethodHandle MH_newProcessBuilder = publicLookup().findConstructor(
+  ProcessBuilder.class, methodType(void.class, String[].class));
+ProcessBuilder pb = (ProcessBuilder)
+  MH_newProcessBuilder.invoke("x", "y", "z");
+assertEquals("[x, y, z]", pb.command().toString());
+         * }</pre></blockquote>
+         * @param refc the class or interface from which the method is accessed
+         * @param type the type of the method, with the receiver argument omitted, and a void return type
+         * @return the desired method handle
+         * @throws NoSuchMethodException if the constructor does not exist
+         * @throws IllegalAccessException if access checking fails
+         *                                or if the method's variable arity modifier bit
+         *                                is set and {@code asVarargsCollector} fails
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         */
+        public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.findConstructor is not implemented");
+        }
+
+        /**
+         * Produces an early-bound method handle for a virtual method.
+         * It will bypass checks for overriding methods on the receiver,
+         * <a href="MethodHandles.Lookup.html#equiv">as if called</a> from an {@code invokespecial}
+         * instruction from within the explicitly specified {@code specialCaller}.
+         * The type of the method handle will be that of the method,
+         * with a suitably restricted receiver type prepended.
+         * (The receiver type will be {@code specialCaller} or a subtype.)
+         * The method and all its argument types must be accessible
+         * to the lookup object.
+         * <p>
+         * Before method resolution,
+         * if the explicitly specified caller class is not identical with the
+         * lookup class, or if this lookup object does not have
+         * <a href="MethodHandles.Lookup.html#privacc">private access</a>
+         * privileges, the access fails.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
+         * <p style="font-size:smaller;">
+         * <em>(Note:  JVM internal methods named {@code "<init>"} are not visible to this API,
+         * even though the {@code invokespecial} instruction can refer to them
+         * in special circumstances.  Use {@link #findConstructor findConstructor}
+         * to access instance initialization methods in a safe manner.)</em>
+         * <p><b>Example:</b>
+         * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+static class Listie extends ArrayList {
+  public String toString() { return "[wee Listie]"; }
+  static Lookup lookup() { return MethodHandles.lookup(); }
+}
+...
+// no access to constructor via invokeSpecial:
+MethodHandle MH_newListie = Listie.lookup()
+  .findConstructor(Listie.class, methodType(void.class));
+Listie l = (Listie) MH_newListie.invokeExact();
+try { assertEquals("impossible", Listie.lookup().findSpecial(
+        Listie.class, "<init>", methodType(void.class), Listie.class));
+ } catch (NoSuchMethodException ex) { } // OK
+// access to super and self methods via invokeSpecial:
+MethodHandle MH_super = Listie.lookup().findSpecial(
+  ArrayList.class, "toString" , methodType(String.class), Listie.class);
+MethodHandle MH_this = Listie.lookup().findSpecial(
+  Listie.class, "toString" , methodType(String.class), Listie.class);
+MethodHandle MH_duper = Listie.lookup().findSpecial(
+  Object.class, "toString" , methodType(String.class), Listie.class);
+assertEquals("[]", (String) MH_super.invokeExact(l));
+assertEquals(""+l, (String) MH_this.invokeExact(l));
+assertEquals("[]", (String) MH_duper.invokeExact(l)); // ArrayList method
+try { assertEquals("inaccessible", Listie.lookup().findSpecial(
+        String.class, "toString", methodType(String.class), Listie.class));
+ } catch (IllegalAccessException ex) { } // OK
+Listie subl = new Listie() { public String toString() { return "[subclass]"; } };
+assertEquals(""+l, (String) MH_this.invokeExact(subl)); // Listie method
+         * }</pre></blockquote>
+         *
+         * @param refc the class or interface from which the method is accessed
+         * @param name the name of the method (which must not be "&lt;init&gt;")
+         * @param type the type of the method, with the receiver argument omitted
+         * @param specialCaller the proposed calling class to perform the {@code invokespecial}
+         * @return the desired method handle
+         * @throws NoSuchMethodException if the method does not exist
+         * @throws IllegalAccessException if access checking fails
+         *                                or if the method's variable arity modifier bit
+         *                                is set and {@code asVarargsCollector} fails
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         */
+        public MethodHandle findSpecial(Class<?> refc, String name, MethodType type,
+                                        Class<?> specialCaller) throws NoSuchMethodException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.findSpecial is not implemented");
+        }
+
+        /**
+         * Produces a method handle giving read access to a non-static field.
+         * The type of the method handle will have a return type of the field's
+         * value type.
+         * The method handle's single argument will be the instance containing
+         * the field.
+         * Access checking is performed immediately on behalf of the lookup class.
+         * @param refc the class or interface from which the method is accessed
+         * @param name the field's name
+         * @param type the field's type
+         * @return a method handle which can load values from the field
+         * @throws NoSuchFieldException if the field does not exist
+         * @throws IllegalAccessException if access checking fails, or if the field is {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         */
+        public MethodHandle findGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.findGetter is not implemented");
+        }
+
+        /**
+         * Produces a method handle giving write access to a non-static field.
+         * The type of the method handle will have a void return type.
+         * The method handle will take two arguments, the instance containing
+         * the field, and the value to be stored.
+         * The second argument will be of the field's value type.
+         * Access checking is performed immediately on behalf of the lookup class.
+         * @param refc the class or interface from which the method is accessed
+         * @param name the field's name
+         * @param type the field's type
+         * @return a method handle which can store values into the field
+         * @throws NoSuchFieldException if the field does not exist
+         * @throws IllegalAccessException if access checking fails, or if the field is {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         */
+        public MethodHandle findSetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.findSetter is not implemented");
+        }
+
+        /**
+         * Produces a method handle giving read access to a static field.
+         * The type of the method handle will have a return type of the field's
+         * value type.
+         * The method handle will take no arguments.
+         * Access checking is performed immediately on behalf of the lookup class.
+         * <p>
+         * If the returned method handle is invoked, the field's class will
+         * be initialized, if it has not already been initialized.
+         * @param refc the class or interface from which the method is accessed
+         * @param name the field's name
+         * @param type the field's type
+         * @return a method handle which can load values from the field
+         * @throws NoSuchFieldException if the field does not exist
+         * @throws IllegalAccessException if access checking fails, or if the field is not {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         */
+        public MethodHandle findStaticGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.findStaticGetter is not implemented");
+        }
+
+        /**
+         * Produces a method handle giving write access to a static field.
+         * The type of the method handle will have a void return type.
+         * The method handle will take a single
+         * argument, of the field's value type, the value to be stored.
+         * Access checking is performed immediately on behalf of the lookup class.
+         * <p>
+         * If the returned method handle is invoked, the field's class will
+         * be initialized, if it has not already been initialized.
+         * @param refc the class or interface from which the method is accessed
+         * @param name the field's name
+         * @param type the field's type
+         * @return a method handle which can store values into the field
+         * @throws NoSuchFieldException if the field does not exist
+         * @throws IllegalAccessException if access checking fails, or if the field is not {@code static}
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         */
+        public MethodHandle findStaticSetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.findStaticSetter is not implemented");
+        }
+
+        /**
+         * Produces an early-bound method handle for a non-static method.
+         * The receiver must have a supertype {@code defc} in which a method
+         * of the given name and type is accessible to the lookup class.
+         * The method and all its argument types must be accessible to the lookup object.
+         * The type of the method handle will be that of the method,
+         * without any insertion of an additional receiver parameter.
+         * The given receiver will be bound into the method handle,
+         * so that every call to the method handle will invoke the
+         * requested method on the given receiver.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set
+         * <em>and</em> the trailing array argument is not the only argument.
+         * (If the trailing array argument is the only argument,
+         * the given receiver value will be bound to it.)
+         * <p>
+         * This is equivalent to the following code:
+         * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle mh0 = lookup().findVirtual(defc, name, type);
+MethodHandle mh1 = mh0.bindTo(receiver);
+MethodType mt1 = mh1.type();
+if (mh0.isVarargsCollector())
+  mh1 = mh1.asVarargsCollector(mt1.parameterType(mt1.parameterCount()-1));
+return mh1;
+         * }</pre></blockquote>
+         * where {@code defc} is either {@code receiver.getClass()} or a super
+         * type of that class, in which the requested method is accessible
+         * to the lookup class.
+         * (Note that {@code bindTo} does not preserve variable arity.)
+         * @param receiver the object from which the method is accessed
+         * @param name the name of the method
+         * @param type the type of the method, with the receiver argument omitted
+         * @return the desired method handle
+         * @throws NoSuchMethodException if the method does not exist
+         * @throws IllegalAccessException if access checking fails
+         *                                or if the method's variable arity modifier bit
+         *                                is set and {@code asVarargsCollector} fails
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws NullPointerException if any argument is null
+         * @see MethodHandle#bindTo
+         * @see #findVirtual
+         */
+        public MethodHandle bind(Object receiver, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.bind is not implemented");
+        }
+
+        /**
+         * Makes a <a href="MethodHandleInfo.html#directmh">direct method handle</a>
+         * to <i>m</i>, if the lookup class has permission.
+         * If <i>m</i> is non-static, the receiver argument is treated as an initial argument.
+         * If <i>m</i> is virtual, overriding is respected on every call.
+         * Unlike the Core Reflection API, exceptions are <em>not</em> wrapped.
+         * The type of the method handle will be that of the method,
+         * with the receiver type prepended (but only if it is non-static).
+         * If the method's {@code accessible} flag is not set,
+         * access checking is performed immediately on behalf of the lookup class.
+         * If <i>m</i> is not public, do not share the resulting handle with untrusted parties.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
+         * <p>
+         * If <i>m</i> is static, and
+         * if the returned method handle is invoked, the method's class will
+         * be initialized, if it has not already been initialized.
+         * @param m the reflected method
+         * @return a method handle which can invoke the reflected method
+         * @throws IllegalAccessException if access checking fails
+         *                                or if the method's variable arity modifier bit
+         *                                is set and {@code asVarargsCollector} fails
+         * @throws NullPointerException if the argument is null
+         */
+        public MethodHandle unreflect(Method m) throws IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.unreflect is not implemented");
+        }
+
+        /**
+         * Produces a method handle for a reflected method.
+         * It will bypass checks for overriding methods on the receiver,
+         * <a href="MethodHandles.Lookup.html#equiv">as if called</a> from an {@code invokespecial}
+         * instruction from within the explicitly specified {@code specialCaller}.
+         * The type of the method handle will be that of the method,
+         * with a suitably restricted receiver type prepended.
+         * (The receiver type will be {@code specialCaller} or a subtype.)
+         * If the method's {@code accessible} flag is not set,
+         * access checking is performed immediately on behalf of the lookup class,
+         * as if {@code invokespecial} instruction were being linked.
+         * <p>
+         * Before method resolution,
+         * if the explicitly specified caller class is not identical with the
+         * lookup class, or if this lookup object does not have
+         * <a href="MethodHandles.Lookup.html#privacc">private access</a>
+         * privileges, the access fails.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the method's variable arity modifier bit ({@code 0x0080}) is set.
+         * @param m the reflected method
+         * @param specialCaller the class nominally calling the method
+         * @return a method handle which can invoke the reflected method
+         * @throws IllegalAccessException if access checking fails
+         *                                or if the method's variable arity modifier bit
+         *                                is set and {@code asVarargsCollector} fails
+         * @throws NullPointerException if any argument is null
+         */
+        public MethodHandle unreflectSpecial(Method m, Class<?> specialCaller) throws IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.unreflectSpecial is not implemented");
+        }
+
+        /**
+         * Produces a method handle for a reflected constructor.
+         * The type of the method handle will be that of the constructor,
+         * with the return type changed to the declaring class.
+         * The method handle will perform a {@code newInstance} operation,
+         * creating a new instance of the constructor's class on the
+         * arguments passed to the method handle.
+         * <p>
+         * If the constructor's {@code accessible} flag is not set,
+         * access checking is performed immediately on behalf of the lookup class.
+         * <p>
+         * The returned method handle will have
+         * {@linkplain MethodHandle#asVarargsCollector variable arity} if and only if
+         * the constructor's variable arity modifier bit ({@code 0x0080}) is set.
+         * <p>
+         * If the returned method handle is invoked, the constructor's class will
+         * be initialized, if it has not already been initialized.
+         * @param c the reflected constructor
+         * @return a method handle which can invoke the reflected constructor
+         * @throws IllegalAccessException if access checking fails
+         *                                or if the method's variable arity modifier bit
+         *                                is set and {@code asVarargsCollector} fails
+         * @throws NullPointerException if the argument is null
+         */
+        public MethodHandle unreflectConstructor(Constructor<?> c) throws IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.unreflectConstructor is not implemented");
+        }
+
+        /**
+         * Produces a method handle giving read access to a reflected field.
+         * The type of the method handle will have a return type of the field's
+         * value type.
+         * If the field is static, the method handle will take no arguments.
+         * Otherwise, its single argument will be the instance containing
+         * the field.
+         * If the field's {@code accessible} flag is not set,
+         * access checking is performed immediately on behalf of the lookup class.
+         * <p>
+         * If the field is static, and
+         * if the returned method handle is invoked, the field's class will
+         * be initialized, if it has not already been initialized.
+         * @param f the reflected field
+         * @return a method handle which can load values from the reflected field
+         * @throws IllegalAccessException if access checking fails
+         * @throws NullPointerException if the argument is null
+         */
+        public MethodHandle unreflectGetter(Field f) throws IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.unreflectGetter is not implemented");
+        }
+
+        /**
+         * Produces a method handle giving write access to a reflected field.
+         * The type of the method handle will have a void return type.
+         * If the field is static, the method handle will take a single
+         * argument, of the field's value type, the value to be stored.
+         * Otherwise, the two arguments will be the instance containing
+         * the field, and the value to be stored.
+         * If the field's {@code accessible} flag is not set,
+         * access checking is performed immediately on behalf of the lookup class.
+         * <p>
+         * If the field is static, and
+         * if the returned method handle is invoked, the field's class will
+         * be initialized, if it has not already been initialized.
+         * @param f the reflected field
+         * @return a method handle which can store values into the reflected field
+         * @throws IllegalAccessException if access checking fails
+         * @throws NullPointerException if the argument is null
+         */
+        public MethodHandle unreflectSetter(Field f) throws IllegalAccessException {
+            // TODO(narayan): Implement this method.
+            throw new UnsupportedOperationException("MethodHandles.Lookup.unreflectSetter is not implemented");
+        }
+
+        /**
+         * Cracks a <a href="MethodHandleInfo.html#directmh">direct method handle</a>
+         * created by this lookup object or a similar one.
+         * Security and access checks are performed to ensure that this lookup object
+         * is capable of reproducing the target method handle.
+         * This means that the cracking may fail if target is a direct method handle
+         * but was created by an unrelated lookup object.
+         * This can happen if the method handle is <a href="MethodHandles.Lookup.html#callsens">caller sensitive</a>
+         * and was created by a lookup object for a different class.
+         * @param target a direct method handle to crack into symbolic reference components
+         * @return a symbolic reference which can be used to reconstruct this method handle from this lookup object
+         * @exception SecurityException if a security manager is present and it
+         *                              <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+         * @throws IllegalArgumentException if the target is not a direct method handle or if access checking fails
+         * @exception NullPointerException if the target is {@code null}
+         * @see MethodHandleInfo
+         * @since 1.8
+         */
+        public MethodHandleInfo revealDirect(MethodHandle target) {
+            // TODO(narayan): Implement this method.
+            //
+            // Notes: Only works for direct method handles. Must check access.
+            //
+            throw new UnsupportedOperationException("MethodHandles.Lookup.revealDirect is not implemented");
+        }
+    }
+
+    /**
+     * Produces a method handle giving read access to elements of an array.
+     * The type of the method handle will have a return type of the array's
+     * element type.  Its first argument will be the array type,
+     * and the second will be {@code int}.
+     * @param arrayClass an array type
+     * @return a method handle which can load values from the given array type
+     * @throws NullPointerException if the argument is null
+     * @throws  IllegalArgumentException if arrayClass is not an array type
+     */
+    public static
+    MethodHandle arrayElementGetter(Class<?> arrayClass) throws IllegalArgumentException {
+        // return MethodHandleImpl.makeArrayElementAccessor(arrayClass, false);
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.arrayElementGetter is not implemented");
+    }
+
+    /**
+     * Produces a method handle giving write access to elements of an array.
+     * The type of the method handle will have a void return type.
+     * Its last argument will be the array's element type.
+     * The first and second arguments will be the array type and int.
+     * @param arrayClass the class of an array
+     * @return a method handle which can store values into the array type
+     * @throws NullPointerException if the argument is null
+     * @throws IllegalArgumentException if arrayClass is not an array type
+     */
+    public static
+    MethodHandle arrayElementSetter(Class<?> arrayClass) throws IllegalArgumentException {
+        // return MethodHandleImpl.makeArrayElementAccessor(arrayClass, true);
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.arrayElementSetter is not implemented");
+    }
+
+    /// method handle invocation (reflective style)
+
+    /**
+     * Produces a method handle which will invoke any method handle of the
+     * given {@code type}, with a given number of trailing arguments replaced by
+     * a single trailing {@code Object[]} array.
+     * The resulting invoker will be a method handle with the following
+     * arguments:
+     * <ul>
+     * <li>a single {@code MethodHandle} target
+     * <li>zero or more leading values (counted by {@code leadingArgCount})
+     * <li>an {@code Object[]} array containing trailing arguments
+     * </ul>
+     * <p>
+     * The invoker will invoke its target like a call to {@link MethodHandle#invoke invoke} with
+     * the indicated {@code type}.
+     * That is, if the target is exactly of the given {@code type}, it will behave
+     * like {@code invokeExact}; otherwise it behave as if {@link MethodHandle#asType asType}
+     * is used to convert the target to the required {@code type}.
+     * <p>
+     * The type of the returned invoker will not be the given {@code type}, but rather
+     * will have all parameters except the first {@code leadingArgCount}
+     * replaced by a single array of type {@code Object[]}, which will be
+     * the final parameter.
+     * <p>
+     * Before invoking its target, the invoker will spread the final array, apply
+     * reference casts as necessary, and unbox and widen primitive arguments.
+     * If, when the invoker is called, the supplied array argument does
+     * not have the correct number of elements, the invoker will throw
+     * an {@link IllegalArgumentException} instead of invoking the target.
+     * <p>
+     * This method is equivalent to the following code (though it may be more efficient):
+     * <blockquote><pre>{@code
+MethodHandle invoker = MethodHandles.invoker(type);
+int spreadArgCount = type.parameterCount() - leadingArgCount;
+invoker = invoker.asSpreader(Object[].class, spreadArgCount);
+return invoker;
+     * }</pre></blockquote>
+     * This method throws no reflective or security exceptions.
+     * @param type the desired target type
+     * @param leadingArgCount number of fixed arguments, to be passed unchanged to the target
+     * @return a method handle suitable for invoking any method handle of the given type
+     * @throws NullPointerException if {@code type} is null
+     * @throws IllegalArgumentException if {@code leadingArgCount} is not in
+     *                  the range from 0 to {@code type.parameterCount()} inclusive,
+     *                  or if the resulting method handle's type would have
+     *          <a href="MethodHandle.html#maxarity">too many parameters</a>
+     */
+    static public
+    MethodHandle spreadInvoker(MethodType type, int leadingArgCount) {
+        if (leadingArgCount < 0 || leadingArgCount > type.parameterCount())
+            throw newIllegalArgumentException("bad argument count", leadingArgCount);
+        type = type.asSpreaderType(Object[].class, type.parameterCount() - leadingArgCount);
+        // return type.invokers().spreadInvoker(leadingArgCount);
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.spreadInvoker is not implemented");
+    }
+
+    /**
+     * Produces a special <em>invoker method handle</em> which can be used to
+     * invoke any method handle of the given type, as if by {@link MethodHandle#invokeExact invokeExact}.
+     * The resulting invoker will have a type which is
+     * exactly equal to the desired type, except that it will accept
+     * an additional leading argument of type {@code MethodHandle}.
+     * <p>
+     * This method is equivalent to the following code (though it may be more efficient):
+     * {@code publicLookup().findVirtual(MethodHandle.class, "invokeExact", type)}
+     *
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * Invoker method handles can be useful when working with variable method handles
+     * of unknown types.
+     * For example, to emulate an {@code invokeExact} call to a variable method
+     * handle {@code M}, extract its type {@code T},
+     * look up the invoker method {@code X} for {@code T},
+     * and call the invoker method, as {@code X.invoke(T, A...)}.
+     * (It would not work to call {@code X.invokeExact}, since the type {@code T}
+     * is unknown.)
+     * If spreading, collecting, or other argument transformations are required,
+     * they can be applied once to the invoker {@code X} and reused on many {@code M}
+     * method handle values, as long as they are compatible with the type of {@code X}.
+     * <p style="font-size:smaller;">
+     * <em>(Note:  The invoker method is not available via the Core Reflection API.
+     * An attempt to call {@linkplain java.lang.reflect.Method#invoke java.lang.reflect.Method.invoke}
+     * on the declared {@code invokeExact} or {@code invoke} method will raise an
+     * {@link java.lang.UnsupportedOperationException UnsupportedOperationException}.)</em>
+     * <p>
+     * This method throws no reflective or security exceptions.
+     * @param type the desired target type
+     * @return a method handle suitable for invoking any method handle of the given type
+     * @throws IllegalArgumentException if the resulting method handle's type would have
+     *          <a href="MethodHandle.html#maxarity">too many parameters</a>
+     */
+    static public
+    MethodHandle exactInvoker(MethodType type) {
+        // return type.invokers().exactInvoker();
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.exactInvoker is not implemented");
+    }
+
+    /**
+     * Produces a special <em>invoker method handle</em> which can be used to
+     * invoke any method handle compatible with the given type, as if by {@link MethodHandle#invoke invoke}.
+     * The resulting invoker will have a type which is
+     * exactly equal to the desired type, except that it will accept
+     * an additional leading argument of type {@code MethodHandle}.
+     * <p>
+     * Before invoking its target, if the target differs from the expected type,
+     * the invoker will apply reference casts as
+     * necessary and box, unbox, or widen primitive values, as if by {@link MethodHandle#asType asType}.
+     * Similarly, the return value will be converted as necessary.
+     * If the target is a {@linkplain MethodHandle#asVarargsCollector variable arity method handle},
+     * the required arity conversion will be made, again as if by {@link MethodHandle#asType asType}.
+     * <p>
+     * This method is equivalent to the following code (though it may be more efficient):
+     * {@code publicLookup().findVirtual(MethodHandle.class, "invoke", type)}
+     * <p style="font-size:smaller;">
+     * <em>Discussion:</em>
+     * A {@linkplain MethodType#genericMethodType general method type} is one which
+     * mentions only {@code Object} arguments and return values.
+     * An invoker for such a type is capable of calling any method handle
+     * of the same arity as the general type.
+     * <p style="font-size:smaller;">
+     * <em>(Note:  The invoker method is not available via the Core Reflection API.
+     * An attempt to call {@linkplain java.lang.reflect.Method#invoke java.lang.reflect.Method.invoke}
+     * on the declared {@code invokeExact} or {@code invoke} method will raise an
+     * {@link java.lang.UnsupportedOperationException UnsupportedOperationException}.)</em>
+     * <p>
+     * This method throws no reflective or security exceptions.
+     * @param type the desired target type
+     * @return a method handle suitable for invoking any method handle convertible to the given type
+     * @throws IllegalArgumentException if the resulting method handle's type would have
+     *          <a href="MethodHandle.html#maxarity">too many parameters</a>
+     */
+    static public
+    MethodHandle invoker(MethodType type) {
+        // return type.invokers().genericInvoker();
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.invoker is not implemented");
+    }
+
+    // Android-changed: Basic invokers are not supported.
+    //
+    // static /*non-public*/
+    // MethodHandle basicInvoker(MethodType type) {
+    //     return type.invokers().basicInvoker();
+    // }
+
+     /// method handle modification (creation from other method handles)
+
+    /**
+     * Produces a method handle which adapts the type of the
+     * given method handle to a new type by pairwise argument and return type conversion.
+     * The original type and new type must have the same number of arguments.
+     * The resulting method handle is guaranteed to report a type
+     * which is equal to the desired new type.
+     * <p>
+     * If the original type and new type are equal, returns target.
+     * <p>
+     * The same conversions are allowed as for {@link MethodHandle#asType MethodHandle.asType},
+     * and some additional conversions are also applied if those conversions fail.
+     * Given types <em>T0</em>, <em>T1</em>, one of the following conversions is applied
+     * if possible, before or instead of any conversions done by {@code asType}:
+     * <ul>
+     * <li>If <em>T0</em> and <em>T1</em> are references, and <em>T1</em> is an interface type,
+     *     then the value of type <em>T0</em> is passed as a <em>T1</em> without a cast.
+     *     (This treatment of interfaces follows the usage of the bytecode verifier.)
+     * <li>If <em>T0</em> is boolean and <em>T1</em> is another primitive,
+     *     the boolean is converted to a byte value, 1 for true, 0 for false.
+     *     (This treatment follows the usage of the bytecode verifier.)
+     * <li>If <em>T1</em> is boolean and <em>T0</em> is another primitive,
+     *     <em>T0</em> is converted to byte via Java casting conversion (JLS 5.5),
+     *     and the low order bit of the result is tested, as if by {@code (x & 1) != 0}.
+     * <li>If <em>T0</em> and <em>T1</em> are primitives other than boolean,
+     *     then a Java casting conversion (JLS 5.5) is applied.
+     *     (Specifically, <em>T0</em> will convert to <em>T1</em> by
+     *     widening and/or narrowing.)
+     * <li>If <em>T0</em> is a reference and <em>T1</em> a primitive, an unboxing
+     *     conversion will be applied at runtime, possibly followed
+     *     by a Java casting conversion (JLS 5.5) on the primitive value,
+     *     possibly followed by a conversion from byte to boolean by testing
+     *     the low-order bit.
+     * <li>If <em>T0</em> is a reference and <em>T1</em> a primitive,
+     *     and if the reference is null at runtime, a zero value is introduced.
+     * </ul>
+     * @param target the method handle to invoke after arguments are retyped
+     * @param newType the expected type of the new method handle
+     * @return a method handle which delegates to the target after performing
+     *           any necessary argument conversions, and arranges for any
+     *           necessary return value conversions
+     * @throws NullPointerException if either argument is null
+     * @throws WrongMethodTypeException if the conversion cannot be made
+     * @see MethodHandle#asType
+     */
+    public static
+    MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) {
+        explicitCastArgumentsChecks(target, newType);
+        // use the asTypeCache when possible:
+        MethodType oldType = target.type();
+        if (oldType == newType)  return target;
+        if (oldType.explicitCastEquivalentToAsType(newType)) {
+            return target.asFixedArity().asType(newType);
+        }
+
+        // return MethodHandleImpl.makePairwiseConvert(target, newType, false);
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.explicitCastArguments is not implemented");
+    }
+
+    private static void explicitCastArgumentsChecks(MethodHandle target, MethodType newType) {
+        if (target.type().parameterCount() != newType.parameterCount()) {
+            throw new WrongMethodTypeException("cannot explicitly cast " + target + " to " + newType);
+        }
+    }
+
+    /**
+     * Produces a method handle which adapts the calling sequence of the
+     * given method handle to a new type, by reordering the arguments.
+     * The resulting method handle is guaranteed to report a type
+     * which is equal to the desired new type.
+     * <p>
+     * The given array controls the reordering.
+     * Call {@code #I} the number of incoming parameters (the value
+     * {@code newType.parameterCount()}, and call {@code #O} the number
+     * of outgoing parameters (the value {@code target.type().parameterCount()}).
+     * Then the length of the reordering array must be {@code #O},
+     * and each element must be a non-negative number less than {@code #I}.
+     * For every {@code N} less than {@code #O}, the {@code N}-th
+     * outgoing argument will be taken from the {@code I}-th incoming
+     * argument, where {@code I} is {@code reorder[N]}.
+     * <p>
+     * No argument or return value conversions are applied.
+     * The type of each incoming argument, as determined by {@code newType},
+     * must be identical to the type of the corresponding outgoing parameter
+     * or parameters in the target method handle.
+     * The return type of {@code newType} must be identical to the return
+     * type of the original target.
+     * <p>
+     * The reordering array need not specify an actual permutation.
+     * An incoming argument will be duplicated if its index appears
+     * more than once in the array, and an incoming argument will be dropped
+     * if its index does not appear in the array.
+     * As in the case of {@link #dropArguments(MethodHandle,int,List) dropArguments},
+     * incoming arguments which are not mentioned in the reordering array
+     * are may be any type, as determined only by {@code newType}.
+     * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodType intfn1 = methodType(int.class, int.class);
+MethodType intfn2 = methodType(int.class, int.class, int.class);
+MethodHandle sub = ... (int x, int y) -> (x-y) ...;
+assert(sub.type().equals(intfn2));
+MethodHandle sub1 = permuteArguments(sub, intfn2, 0, 1);
+MethodHandle rsub = permuteArguments(sub, intfn2, 1, 0);
+assert((int)rsub.invokeExact(1, 100) == 99);
+MethodHandle add = ... (int x, int y) -> (x+y) ...;
+assert(add.type().equals(intfn2));
+MethodHandle twice = permuteArguments(add, intfn1, 0, 0);
+assert(twice.type().equals(intfn1));
+assert((int)twice.invokeExact(21) == 42);
+     * }</pre></blockquote>
+     * @param target the method handle to invoke after arguments are reordered
+     * @param newType the expected type of the new method handle
+     * @param reorder an index array which controls the reordering
+     * @return a method handle which delegates to the target after it
+     *           drops unused arguments and moves and/or duplicates the other arguments
+     * @throws NullPointerException if any argument is null
+     * @throws IllegalArgumentException if the index array length is not equal to
+     *                  the arity of the target, or if any index array element
+     *                  not a valid index for a parameter of {@code newType},
+     *                  or if two corresponding parameter types in
+     *                  {@code target.type()} and {@code newType} are not identical,
+     */
+    public static
+    MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) {
+        reorder = reorder.clone();  // get a private copy
+        MethodType oldType = target.type();
+        permuteArgumentChecks(reorder, newType, oldType);
+
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.permuteArguments is not implemented");
+    }
+
+    // Android-changed: findFirstDupOrDrop is unused and removed.
+    // private static int findFirstDupOrDrop(int[] reorder, int newArity);
+
+    private static boolean permuteArgumentChecks(int[] reorder, MethodType newType, MethodType oldType) {
+        if (newType.returnType() != oldType.returnType())
+            throw newIllegalArgumentException("return types do not match",
+                    oldType, newType);
+        if (reorder.length == oldType.parameterCount()) {
+            int limit = newType.parameterCount();
+            boolean bad = false;
+            for (int j = 0; j < reorder.length; j++) {
+                int i = reorder[j];
+                if (i < 0 || i >= limit) {
+                    bad = true; break;
+                }
+                Class<?> src = newType.parameterType(i);
+                Class<?> dst = oldType.parameterType(j);
+                if (src != dst)
+                    throw newIllegalArgumentException("parameter types do not match after reorder",
+                            oldType, newType);
+            }
+            if (!bad)  return true;
+        }
+        throw newIllegalArgumentException("bad reorder array: "+Arrays.toString(reorder));
+    }
+
+    /**
+     * Produces a method handle of the requested return type which returns the given
+     * constant value every time it is invoked.
+     * <p>
+     * Before the method handle is returned, the passed-in value is converted to the requested type.
+     * If the requested type is primitive, widening primitive conversions are attempted,
+     * else reference conversions are attempted.
+     * <p>The returned method handle is equivalent to {@code identity(type).bindTo(value)}.
+     * @param type the return type of the desired method handle
+     * @param value the value to return
+     * @return a method handle of the given return type and no arguments, which always returns the given value
+     * @throws NullPointerException if the {@code type} argument is null
+     * @throws ClassCastException if the value cannot be converted to the required return type
+     * @throws IllegalArgumentException if the given type is {@code void.class}
+     */
+    public static
+    MethodHandle constant(Class<?> type, Object value) {
+        if (type.isPrimitive()) {
+            if (type == void.class)
+                throw newIllegalArgumentException("void type");
+            Wrapper w = Wrapper.forPrimitiveType(type);
+            value = w.convert(value, type);
+            if (w.zero().equals(value))
+                return zero(w, type);
+            return insertArguments(identity(type), 0, value);
+        } else {
+            if (value == null)
+                return zero(Wrapper.OBJECT, type);
+            return identity(type).bindTo(value);
+        }
+    }
+
+    /**
+     * Produces a method handle which returns its sole argument when invoked.
+     * @param type the type of the sole parameter and return value of the desired method handle
+     * @return a unary method handle which accepts and returns the given type
+     * @throws NullPointerException if the argument is null
+     * @throws IllegalArgumentException if the given type is {@code void.class}
+     */
+    public static
+    MethodHandle identity(Class<?> type) {
+        Wrapper btw = (type.isPrimitive() ? Wrapper.forPrimitiveType(type) : Wrapper.OBJECT);
+        int pos = btw.ordinal();
+        MethodHandle ident = IDENTITY_MHS[pos];
+        if (ident == null) {
+            ident = setCachedMethodHandle(IDENTITY_MHS, pos, makeIdentity(btw.primitiveType()));
+        }
+        if (ident.type().returnType() == type)
+            return ident;
+        // something like identity(Foo.class); do not bother to intern these
+        assert(btw == Wrapper.OBJECT);
+        return makeIdentity(type);
+    }
+    private static final MethodHandle[] IDENTITY_MHS = new MethodHandle[Wrapper.values().length];
+    private static MethodHandle makeIdentity(Class<?> ptype) {
+        // MethodType mtype = MethodType.methodType(ptype, ptype);
+        // LambdaForm lform = LambdaForm.identityForm(BasicType.basicType(ptype));
+        // return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.IDENTITY);
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.makeIdentity is not implemented");
+    }
+
+    private static MethodHandle zero(Wrapper btw, Class<?> rtype) {
+        int pos = btw.ordinal();
+        MethodHandle zero = ZERO_MHS[pos];
+        if (zero == null) {
+            zero = setCachedMethodHandle(ZERO_MHS, pos, makeZero(btw.primitiveType()));
+        }
+        if (zero.type().returnType() == rtype)
+            return zero;
+        assert(btw == Wrapper.OBJECT);
+        return makeZero(rtype);
+    }
+    private static final MethodHandle[] ZERO_MHS = new MethodHandle[Wrapper.values().length];
+    private static MethodHandle makeZero(Class<?> rtype) {
+        // MethodType mtype = MethodType.methodType(rtype);
+        // LambdaForm lform = LambdaForm.zeroForm(BasicType.basicType(rtype));
+        // return MethodHandleImpl.makeIntrinsic(mtype, lform, Intrinsic.ZERO);
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.makeZero is not implemented");
+    }
+
+    synchronized private static MethodHandle setCachedMethodHandle(MethodHandle[] cache, int pos, MethodHandle value) {
+        // Simulate a CAS, to avoid racy duplication of results.
+        MethodHandle prev = cache[pos];
+        if (prev != null) return prev;
+        return cache[pos] = value;
+    }
+
+    /**
+     * Provides a target method handle with one or more <em>bound arguments</em>
+     * in advance of the method handle's invocation.
+     * The formal parameters to the target corresponding to the bound
+     * arguments are called <em>bound parameters</em>.
+     * Returns a new method handle which saves away the bound arguments.
+     * When it is invoked, it receives arguments for any non-bound parameters,
+     * binds the saved arguments to their corresponding parameters,
+     * and calls the original target.
+     * <p>
+     * The type of the new method handle will drop the types for the bound
+     * parameters from the original target type, since the new method handle
+     * will no longer require those arguments to be supplied by its callers.
+     * <p>
+     * Each given argument object must match the corresponding bound parameter type.
+     * If a bound parameter type is a primitive, the argument object
+     * must be a wrapper, and will be unboxed to produce the primitive value.
+     * <p>
+     * The {@code pos} argument selects which parameters are to be bound.
+     * It may range between zero and <i>N-L</i> (inclusively),
+     * where <i>N</i> is the arity of the target method handle
+     * and <i>L</i> is the length of the values array.
+     * @param target the method handle to invoke after the argument is inserted
+     * @param pos where to insert the argument (zero for the first)
+     * @param values the series of arguments to insert
+     * @return a method handle which inserts an additional argument,
+     *         before calling the original method handle
+     * @throws NullPointerException if the target or the {@code values} array is null
+     * @see MethodHandle#bindTo
+     */
+    public static
+    MethodHandle insertArguments(MethodHandle target, int pos, Object... values) {
+        int insCount = values.length;
+        Class<?>[] ptypes = insertArgumentsChecks(target, insCount, pos);
+        if (insCount == 0)  return target;
+
+        // BoundMethodHandle result = target.rebind();
+        // for (int i = 0; i < insCount; i++) {
+        //     Object value = values[i];
+        //     Class<?> ptype = ptypes[pos+i];
+        //     if (ptype.isPrimitive()) {
+        //         result = insertArgumentPrimitive(result, pos, ptype, value);
+        //     } else {
+        //         value = ptype.cast(value);  // throw CCE if needed
+        //         result = result.bindArgumentL(pos, value);
+        //     }
+        // }
+        // return result;
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.insertArguments is not implemented");
+    }
+
+    // Android-changed: insertArgumentPrimitive is unused.
+    //
+    // private static BoundMethodHandle insertArgumentPrimitive(BoundMethodHandle result, int pos,
+    //                                                          Class<?> ptype, Object value) {
+    //     Wrapper w = Wrapper.forPrimitiveType(ptype);
+    //     // perform unboxing and/or primitive conversion
+    //     value = w.convert(value, ptype);
+    //     switch (w) {
+    //     case INT:     return result.bindArgumentI(pos, (int)value);
+    //     case LONG:    return result.bindArgumentJ(pos, (long)value);
+    //     case FLOAT:   return result.bindArgumentF(pos, (float)value);
+    //     case DOUBLE:  return result.bindArgumentD(pos, (double)value);
+    //     default:      return result.bindArgumentI(pos, ValueConversions.widenSubword(value));
+    //     }
+    // }
+
+    private static Class<?>[] insertArgumentsChecks(MethodHandle target, int insCount, int pos) throws RuntimeException {
+        MethodType oldType = target.type();
+        int outargs = oldType.parameterCount();
+        int inargs  = outargs - insCount;
+        if (inargs < 0)
+            throw newIllegalArgumentException("too many values to insert");
+        if (pos < 0 || pos > inargs)
+            throw newIllegalArgumentException("no argument type to append");
+        return oldType.ptypes();
+    }
+
+    /**
+     * Produces a method handle which will discard some dummy arguments
+     * before calling some other specified <i>target</i> method handle.
+     * The type of the new method handle will be the same as the target's type,
+     * except it will also include the dummy argument types,
+     * at some given position.
+     * <p>
+     * The {@code pos} argument may range between zero and <i>N</i>,
+     * where <i>N</i> is the arity of the target.
+     * If {@code pos} is zero, the dummy arguments will precede
+     * the target's real arguments; if {@code pos} is <i>N</i>
+     * they will come after.
+     * <p>
+     * <b>Example:</b>
+     * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle cat = lookup().findVirtual(String.class,
+  "concat", methodType(String.class, String.class));
+assertEquals("xy", (String) cat.invokeExact("x", "y"));
+MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
+MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
+assertEquals(bigType, d0.type());
+assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
+     * }</pre></blockquote>
+     * <p>
+     * This method is also equivalent to the following code:
+     * <blockquote><pre>
+     * {@link #dropArguments(MethodHandle,int,Class...) dropArguments}{@code (target, pos, valueTypes.toArray(new Class[0]))}
+     * </pre></blockquote>
+     * @param target the method handle to invoke after the arguments are dropped
+     * @param valueTypes the type(s) of the argument(s) to drop
+     * @param pos position of first argument to drop (zero for the leftmost)
+     * @return a method handle which drops arguments of the given types,
+     *         before calling the original method handle
+     * @throws NullPointerException if the target is null,
+     *                              or if the {@code valueTypes} list or any of its elements is null
+     * @throws IllegalArgumentException if any element of {@code valueTypes} is {@code void.class},
+     *                  or if {@code pos} is negative or greater than the arity of the target,
+     *                  or if the new method handle's type would have too many parameters
+     */
+    public static
+    MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
+        MethodType oldType = target.type();  // get NPE
+        int dropped = dropArgumentChecks(oldType, pos, valueTypes);
+
+        MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
+        // if (dropped == 0)  return target;
+        // BoundMethodHandle result = target.rebind();
+        // LambdaForm lform = result.form;
+        // int insertFormArg = 1 + pos;
+        // for (Class<?> ptype : valueTypes) {
+        //     lform = lform.editor().addArgumentForm(insertFormArg++, BasicType.basicType(ptype));
+        // }
+        // result = result.copyWith(newType, lform);
+        // return result;
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.dropArguments is not implemented");
+    }
+
+    private static int dropArgumentChecks(MethodType oldType, int pos, List<Class<?>> valueTypes) {
+        int dropped = valueTypes.size();
+        MethodType.checkSlotCount(dropped);
+        int outargs = oldType.parameterCount();
+        int inargs  = outargs + dropped;
+        if (pos < 0 || pos > outargs)
+            throw newIllegalArgumentException("no argument type to remove"
+                    + Arrays.asList(oldType, pos, valueTypes, inargs, outargs)
+                    );
+        return dropped;
+    }
+
+    /**
+     * Produces a method handle which will discard some dummy arguments
+     * before calling some other specified <i>target</i> method handle.
+     * The type of the new method handle will be the same as the target's type,
+     * except it will also include the dummy argument types,
+     * at some given position.
+     * <p>
+     * The {@code pos} argument may range between zero and <i>N</i>,
+     * where <i>N</i> is the arity of the target.
+     * If {@code pos} is zero, the dummy arguments will precede
+     * the target's real arguments; if {@code pos} is <i>N</i>
+     * they will come after.
+     * <p>
+     * <b>Example:</b>
+     * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle cat = lookup().findVirtual(String.class,
+  "concat", methodType(String.class, String.class));
+assertEquals("xy", (String) cat.invokeExact("x", "y"));
+MethodHandle d0 = dropArguments(cat, 0, String.class);
+assertEquals("yz", (String) d0.invokeExact("x", "y", "z"));
+MethodHandle d1 = dropArguments(cat, 1, String.class);
+assertEquals("xz", (String) d1.invokeExact("x", "y", "z"));
+MethodHandle d2 = dropArguments(cat, 2, String.class);
+assertEquals("xy", (String) d2.invokeExact("x", "y", "z"));
+MethodHandle d12 = dropArguments(cat, 1, int.class, boolean.class);
+assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
+     * }</pre></blockquote>
+     * <p>
+     * This method is also equivalent to the following code:
+     * <blockquote><pre>
+     * {@link #dropArguments(MethodHandle,int,List) dropArguments}{@code (target, pos, Arrays.asList(valueTypes))}
+     * </pre></blockquote>
+     * @param target the method handle to invoke after the arguments are dropped
+     * @param valueTypes the type(s) of the argument(s) to drop
+     * @param pos position of first argument to drop (zero for the leftmost)
+     * @return a method handle which drops arguments of the given types,
+     *         before calling the original method handle
+     * @throws NullPointerException if the target is null,
+     *                              or if the {@code valueTypes} array or any of its elements is null
+     * @throws IllegalArgumentException if any element of {@code valueTypes} is {@code void.class},
+     *                  or if {@code pos} is negative or greater than the arity of the target,
+     *                  or if the new method handle's type would have
+     *                  <a href="MethodHandle.html#maxarity">too many parameters</a>
+     */
+    public static
+    MethodHandle dropArguments(MethodHandle target, int pos, Class<?>... valueTypes) {
+        return dropArguments(target, pos, Arrays.asList(valueTypes));
+    }
+
+    /**
+     * Adapts a target method handle by pre-processing
+     * one or more of its arguments, each with its own unary filter function,
+     * and then calling the target with each pre-processed argument
+     * replaced by the result of its corresponding filter function.
+     * <p>
+     * The pre-processing is performed by one or more method handles,
+     * specified in the elements of the {@code filters} array.
+     * The first element of the filter array corresponds to the {@code pos}
+     * argument of the target, and so on in sequence.
+     * <p>
+     * Null arguments in the array are treated as identity functions,
+     * and the corresponding arguments left unchanged.
+     * (If there are no non-null elements in the array, the original target is returned.)
+     * Each filter is applied to the corresponding argument of the adapter.
+     * <p>
+     * If a filter {@code F} applies to the {@code N}th argument of
+     * the target, then {@code F} must be a method handle which
+     * takes exactly one argument.  The type of {@code F}'s sole argument
+     * replaces the corresponding argument type of the target
+     * in the resulting adapted method handle.
+     * The return type of {@code F} must be identical to the corresponding
+     * parameter type of the target.
+     * <p>
+     * It is an error if there are elements of {@code filters}
+     * (null or not)
+     * which do not correspond to argument positions in the target.
+     * <p><b>Example:</b>
+     * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle cat = lookup().findVirtual(String.class,
+  "concat", methodType(String.class, String.class));
+MethodHandle upcase = lookup().findVirtual(String.class,
+  "toUpperCase", methodType(String.class));
+assertEquals("xy", (String) cat.invokeExact("x", "y"));
+MethodHandle f0 = filterArguments(cat, 0, upcase);
+assertEquals("Xy", (String) f0.invokeExact("x", "y")); // Xy
+MethodHandle f1 = filterArguments(cat, 1, upcase);
+assertEquals("xY", (String) f1.invokeExact("x", "y")); // xY
+MethodHandle f2 = filterArguments(cat, 0, upcase, upcase);
+assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY
+     * }</pre></blockquote>
+     * <p> Here is pseudocode for the resulting adapter:
+     * <blockquote><pre>{@code
+     * V target(P... p, A[i]... a[i], B... b);
+     * A[i] filter[i](V[i]);
+     * T adapter(P... p, V[i]... v[i], B... b) {
+     *   return target(p..., f[i](v[i])..., b...);
+     * }
+     * }</pre></blockquote>
+     *
+     * @param target the method handle to invoke after arguments are filtered
+     * @param pos the position of the first argument to filter
+     * @param filters method handles to call initially on filtered arguments
+     * @return method handle which incorporates the specified argument filtering logic
+     * @throws NullPointerException if the target is null
+     *                              or if the {@code filters} array is null
+     * @throws IllegalArgumentException if a non-null element of {@code filters}
+     *          does not match a corresponding argument type of target as described above,
+     *          or if the {@code pos+filters.length} is greater than {@code target.type().parameterCount()},
+     *          or if the resulting method handle's type would have
+     *          <a href="MethodHandle.html#maxarity">too many parameters</a>
+     */
+    public static
+    MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) {
+        filterArgumentsCheckArity(target, pos, filters);
+        MethodHandle adapter = target;
+        int curPos = pos-1;  // pre-incremented
+        for (MethodHandle filter : filters) {
+            curPos += 1;
+            if (filter == null)  continue;  // ignore null elements of filters
+            adapter = filterArgument(adapter, curPos, filter);
+        }
+        return adapter;
+    }
+
+    /*non-public*/ static
+    MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
+        filterArgumentChecks(target, pos, filter);
+        // MethodType targetType = target.type();
+        // MethodType filterType = filter.type();
+        // BoundMethodHandle result = target.rebind();
+        // Class<?> newParamType = filterType.parameterType(0);
+        // LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType));
+        // MethodType newType = targetType.changeParameterType(pos, newParamType);
+        // result = result.copyWithExtendL(newType, lform, filter);
+        // return result;
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.filterArgument is not implemented");
+    }
+
+    private static void filterArgumentsCheckArity(MethodHandle target, int pos, MethodHandle[] filters) {
+        MethodType targetType = target.type();
+        int maxPos = targetType.parameterCount();
+        if (pos + filters.length > maxPos)
+            throw newIllegalArgumentException("too many filters");
+    }
+
+    private static void filterArgumentChecks(MethodHandle target, int pos, MethodHandle filter) throws RuntimeException {
+        MethodType targetType = target.type();
+        MethodType filterType = filter.type();
+        if (filterType.parameterCount() != 1
+            || filterType.returnType() != targetType.parameterType(pos))
+            throw newIllegalArgumentException("target and filter types do not match", targetType, filterType);
+    }
+
+    /**
+     * Adapts a target method handle by pre-processing
+     * a sub-sequence of its arguments with a filter (another method handle).
+     * The pre-processed arguments are replaced by the result (if any) of the
+     * filter function.
+     * The target is then called on the modified (usually shortened) argument list.
+     * <p>
+     * If the filter returns a value, the target must accept that value as
+     * its argument in position {@code pos}, preceded and/or followed by
+     * any arguments not passed to the filter.
+     * If the filter returns void, the target must accept all arguments
+     * not passed to the filter.
+     * No arguments are reordered, and a result returned from the filter
+     * replaces (in order) the whole subsequence of arguments originally
+     * passed to the adapter.
+     * <p>
+     * The argument types (if any) of the filter
+     * replace zero or one argument types of the target, at position {@code pos},
+     * in the resulting adapted method handle.
+     * The return type of the filter (if any) must be identical to the
+     * argument type of the target at position {@code pos}, and that target argument
+     * is supplied by the return value of the filter.
+     * <p>
+     * In all cases, {@code pos} must be greater than or equal to zero, and
+     * {@code pos} must also be less than or equal to the target's arity.
+     * <p><b>Example:</b>
+     * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle deepToString = publicLookup()
+  .findStatic(Arrays.class, "deepToString", methodType(String.class, Object[].class));
+
+MethodHandle ts1 = deepToString.asCollector(String[].class, 1);
+assertEquals("[strange]", (String) ts1.invokeExact("strange"));
+
+MethodHandle ts2 = deepToString.asCollector(String[].class, 2);
+assertEquals("[up, down]", (String) ts2.invokeExact("up", "down"));
+
+MethodHandle ts3 = deepToString.asCollector(String[].class, 3);
+MethodHandle ts3_ts2 = collectArguments(ts3, 1, ts2);
+assertEquals("[top, [up, down], strange]",
+             (String) ts3_ts2.invokeExact("top", "up", "down", "strange"));
+
+MethodHandle ts3_ts2_ts1 = collectArguments(ts3_ts2, 3, ts1);
+assertEquals("[top, [up, down], [strange]]",
+             (String) ts3_ts2_ts1.invokeExact("top", "up", "down", "strange"));
+
+MethodHandle ts3_ts2_ts3 = collectArguments(ts3_ts2, 1, ts3);
+assertEquals("[top, [[up, down, strange], charm], bottom]",
+             (String) ts3_ts2_ts3.invokeExact("top", "up", "down", "strange", "charm", "bottom"));
+     * }</pre></blockquote>
+     * <p> Here is pseudocode for the resulting adapter:
+     * <blockquote><pre>{@code
+     * T target(A...,V,C...);
+     * V filter(B...);
+     * T adapter(A... a,B... b,C... c) {
+     *   V v = filter(b...);
+     *   return target(a...,v,c...);
+     * }
+     * // and if the filter has no arguments:
+     * T target2(A...,V,C...);
+     * V filter2();
+     * T adapter2(A... a,C... c) {
+     *   V v = filter2();
+     *   return target2(a...,v,c...);
+     * }
+     * // and if the filter has a void return:
+     * T target3(A...,C...);
+     * void filter3(B...);
+     * void adapter3(A... a,B... b,C... c) {
+     *   filter3(b...);
+     *   return target3(a...,c...);
+     * }
+     * }</pre></blockquote>
+     * <p>
+     * A collection adapter {@code collectArguments(mh, 0, coll)} is equivalent to
+     * one which first "folds" the affected arguments, and then drops them, in separate
+     * steps as follows:
+     * <blockquote><pre>{@code
+     * mh = MethodHandles.dropArguments(mh, 1, coll.type().parameterList()); //step 2
+     * mh = MethodHandles.foldArguments(mh, coll); //step 1
+     * }</pre></blockquote>
+     * If the target method handle consumes no arguments besides than the result
+     * (if any) of the filter {@code coll}, then {@code collectArguments(mh, 0, coll)}
+     * is equivalent to {@code filterReturnValue(coll, mh)}.
+     * If the filter method handle {@code coll} consumes one argument and produces
+     * a non-void result, then {@code collectArguments(mh, N, coll)}
+     * is equivalent to {@code filterArguments(mh, N, coll)}.
+     * Other equivalences are possible but would require argument permutation.
+     *
+     * @param target the method handle to invoke after filtering the subsequence of arguments
+     * @param pos the position of the first adapter argument to pass to the filter,
+     *            and/or the target argument which receives the result of the filter
+     * @param filter method handle to call on the subsequence of arguments
+     * @return method handle which incorporates the specified argument subsequence filtering logic
+     * @throws NullPointerException if either argument is null
+     * @throws IllegalArgumentException if the return type of {@code filter}
+     *          is non-void and is not the same as the {@code pos} argument of the target,
+     *          or if {@code pos} is not between 0 and the target's arity, inclusive,
+     *          or if the resulting method handle's type would have
+     *          <a href="MethodHandle.html#maxarity">too many parameters</a>
+     * @see MethodHandles#foldArguments
+     * @see MethodHandles#filterArguments
+     * @see MethodHandles#filterReturnValue
+     */
+    public static
+    MethodHandle collectArguments(MethodHandle target, int pos, MethodHandle filter) {
+        MethodType newType = collectArgumentsChecks(target, pos, filter);
+        MethodType collectorType = filter.type();
+
+        // BoundMethodHandle result = target.rebind();
+        // LambdaForm lform;
+        // if (collectorType.returnType().isArray() && filter.intrinsicName() == Intrinsic.NEW_ARRAY) {
+        //     lform = result.editor().collectArgumentArrayForm(1 + pos, filter);
+        //     if (lform != null) {
+        //         return result.copyWith(newType, lform);
+        //     }
+        // }
+        // lform = result.editor().collectArgumentsForm(1 + pos, collectorType.basicType());
+        // return result.copyWithExtendL(newType, lform, filter);
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.collectArguments is not implemented");
+    }
+
+    private static MethodType collectArgumentsChecks(MethodHandle target, int pos, MethodHandle filter) throws RuntimeException {
+        MethodType targetType = target.type();
+        MethodType filterType = filter.type();
+        Class<?> rtype = filterType.returnType();
+        List<Class<?>> filterArgs = filterType.parameterList();
+        if (rtype == void.class) {
+            return targetType.insertParameterTypes(pos, filterArgs);
+        }
+        if (rtype != targetType.parameterType(pos)) {
+            throw newIllegalArgumentException("target and filter types do not match", targetType, filterType);
+        }
+        return targetType.dropParameterTypes(pos, pos+1).insertParameterTypes(pos, filterArgs);
+    }
+
+    /**
+     * Adapts a target method handle by post-processing
+     * its return value (if any) with a filter (another method handle).
+     * The result of the filter is returned from the adapter.
+     * <p>
+     * If the target returns a value, the filter must accept that value as
+     * its only argument.
+     * If the target returns void, the filter must accept no arguments.
+     * <p>
+     * The return type of the filter
+     * replaces the return type of the target
+     * in the resulting adapted method handle.
+     * The argument type of the filter (if any) must be identical to the
+     * return type of the target.
+     * <p><b>Example:</b>
+     * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle cat = lookup().findVirtual(String.class,
+  "concat", methodType(String.class, String.class));
+MethodHandle length = lookup().findVirtual(String.class,
+  "length", methodType(int.class));
+System.out.println((String) cat.invokeExact("x", "y")); // xy
+MethodHandle f0 = filterReturnValue(cat, length);
+System.out.println((int) f0.invokeExact("x", "y")); // 2
+     * }</pre></blockquote>
+     * <p> Here is pseudocode for the resulting adapter:
+     * <blockquote><pre>{@code
+     * V target(A...);
+     * T filter(V);
+     * T adapter(A... a) {
+     *   V v = target(a...);
+     *   return filter(v);
+     * }
+     * // and if the target has a void return:
+     * void target2(A...);
+     * T filter2();
+     * T adapter2(A... a) {
+     *   target2(a...);
+     *   return filter2();
+     * }
+     * // and if the filter has a void return:
+     * V target3(A...);
+     * void filter3(V);
+     * void adapter3(A... a) {
+     *   V v = target3(a...);
+     *   filter3(v);
+     * }
+     * }</pre></blockquote>
+     * @param target the method handle to invoke before filtering the return value
+     * @param filter method handle to call on the return value
+     * @return method handle which incorporates the specified return value filtering logic
+     * @throws NullPointerException if either argument is null
+     * @throws IllegalArgumentException if the argument list of {@code filter}
+     *          does not match the return type of target as described above
+     */
+    public static
+    MethodHandle filterReturnValue(MethodHandle target, MethodHandle filter) {
+        MethodType targetType = target.type();
+        MethodType filterType = filter.type();
+        filterReturnValueChecks(targetType, filterType);
+
+        // BoundMethodHandle result = target.rebind();
+        // BasicType rtype = BasicType.basicType(filterType.returnType());
+        // LambdaForm lform = result.editor().filterReturnForm(rtype, false);
+        // MethodType newType = targetType.changeReturnType(filterType.returnType());
+        // result = result.copyWithExtendL(newType, lform, filter);
+        // return result;
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.filterReturnValue is not implemented");
+    }
+
+    private static void filterReturnValueChecks(MethodType targetType, MethodType filterType) throws RuntimeException {
+        Class<?> rtype = targetType.returnType();
+        int filterValues = filterType.parameterCount();
+        if (filterValues == 0
+                ? (rtype != void.class)
+                : (rtype != filterType.parameterType(0)))
+            throw newIllegalArgumentException("target and filter types do not match", targetType, filterType);
+    }
+
+    /**
+     * Adapts a target method handle by pre-processing
+     * some of its arguments, and then calling the target with
+     * the result of the pre-processing, inserted into the original
+     * sequence of arguments.
+     * <p>
+     * The pre-processing is performed by {@code combiner}, a second method handle.
+     * Of the arguments passed to the adapter, the first {@code N} arguments
+     * are copied to the combiner, which is then called.
+     * (Here, {@code N} is defined as the parameter count of the combiner.)
+     * After this, control passes to the target, with any result
+     * from the combiner inserted before the original {@code N} incoming
+     * arguments.
+     * <p>
+     * If the combiner returns a value, the first parameter type of the target
+     * must be identical with the return type of the combiner, and the next
+     * {@code N} parameter types of the target must exactly match the parameters
+     * of the combiner.
+     * <p>
+     * If the combiner has a void return, no result will be inserted,
+     * and the first {@code N} parameter types of the target
+     * must exactly match the parameters of the combiner.
+     * <p>
+     * The resulting adapter is the same type as the target, except that the
+     * first parameter type is dropped,
+     * if it corresponds to the result of the combiner.
+     * <p>
+     * (Note that {@link #dropArguments(MethodHandle,int,List) dropArguments} can be used to remove any arguments
+     * that either the combiner or the target does not wish to receive.
+     * If some of the incoming arguments are destined only for the combiner,
+     * consider using {@link MethodHandle#asCollector asCollector} instead, since those
+     * arguments will not need to be live on the stack on entry to the
+     * target.)
+     * <p><b>Example:</b>
+     * <blockquote><pre>{@code
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle trace = publicLookup().findVirtual(java.io.PrintStream.class,
+  "println", methodType(void.class, String.class))
+    .bindTo(System.out);
+MethodHandle cat = lookup().findVirtual(String.class,
+  "concat", methodType(String.class, String.class));
+assertEquals("boojum", (String) cat.invokeExact("boo", "jum"));
+MethodHandle catTrace = foldArguments(cat, trace);
+// also prints "boo":
+assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
+     * }</pre></blockquote>
+     * <p> Here is pseudocode for the resulting adapter:
+     * <blockquote><pre>{@code
+     * // there are N arguments in A...
+     * T target(V, A[N]..., B...);
+     * V combiner(A...);
+     * T adapter(A... a, B... b) {
+     *   V v = combiner(a...);
+     *   return target(v, a..., b...);
+     * }
+     * // and if the combiner has a void return:
+     * T target2(A[N]..., B...);
+     * void combiner2(A...);
+     * T adapter2(A... a, B... b) {
+     *   combiner2(a...);
+     *   return target2(a..., b...);
+     * }
+     * }</pre></blockquote>
+     * @param target the method handle to invoke after arguments are combined
+     * @param combiner method handle to call initially on the incoming arguments
+     * @return method handle which incorporates the specified argument folding logic
+     * @throws NullPointerException if either argument is null
+     * @throws IllegalArgumentException if {@code combiner}'s return type
+     *          is non-void and not the same as the first argument type of
+     *          the target, or if the initial {@code N} argument types
+     *          of the target
+     *          (skipping one matching the {@code combiner}'s return type)
+     *          are not identical with the argument types of {@code combiner}
+     */
+    public static
+    MethodHandle foldArguments(MethodHandle target, MethodHandle combiner) {
+        int foldPos = 0;
+        MethodType targetType = target.type();
+        MethodType combinerType = combiner.type();
+        Class<?> rtype = foldArgumentChecks(foldPos, targetType, combinerType);
+
+        // BoundMethodHandle result = target.rebind();
+        // boolean dropResult = (rtype == void.class);
+        // // Note:  This may cache too many distinct LFs. Consider backing off to varargs code.
+        // LambdaForm lform = result.editor().foldArgumentsForm(1 + foldPos, dropResult, combinerType.basicType());
+        // MethodType newType = targetType;
+        // if (!dropResult)
+        //     newType = newType.dropParameterTypes(foldPos, foldPos + 1);
+        // result = result.copyWithExtendL(newType, lform, combiner);
+        // return result;
+
+        // TODO(narayan): Implement this method.
+        throw new UnsupportedOperationException("MethodHandles.foldArguments is not implemented");
+    }
+
+    private static Class<?> foldArgumentChecks(int foldPos, MethodType targetType, MethodType combinerType) {
+        int foldArgs   = combinerType.parameterCount();
+        Class<?> rtype = combinerType.returnType();
+        int foldVals = rtype == void.class ? 0 : 1;
+        int afterInsertPos = foldPos + foldVals;
+        boolean ok = (targetType.parameterCount() >= afterInsertPos + foldArgs);
+        if (ok && !(combinerType.parameterList()
+                    .equals(targetType.parameterList().subList(afterInsertPos,
+                                                               afterInsertPos + foldArgs))))
+            ok = false;
+        if (ok && foldVals != 0 && combinerType.returnType() != targetType.parameterType(0))
+            ok = false;
+        if (!ok)
+            throw misMatchedTypes("target and combiner types", targetType, combinerType);
+        return rtype;
+    }
+
+    /**
+     * Makes a method handle which adapts a target method handle,
+     * by guarding it with a test, a boolean-valued method handle.
+     * If the guard fails, a fallback handle is called instead.
+     * All three method handles must have the same corresponding
+     * argument and return types, except that the return type
+     * of the test must be boolean, and the test is allowed
+     * to have fewer arguments than the other two method handles.
+     * <p> Here is pseudocode for the resulting adapter:
+     * <blockquote><pre>{@code
+     * boolean test(A...);
+     * T target(A...,B...);
+     * T fallback(A...,B...);
+     * T adapter(A... a,B... b) {
+     *   if (test(a...))
+     *     return target(a..., b...);
+     *   else
+     *     return fallback(a..., b...);
+     * }
+     * }</pre></blockquote>
+     * Note that the test arguments ({@code a...} in the pseudocode) cannot
+     * be modified by execution of the test, and so are passed unchanged
+     * from the caller to the target or fallback as appropriate.
+     * @param test method handle used for test, must return boolean
+     * @param target method handle to call if test passes
+     * @param fallback method handle to call if test fails
+     * @return method handle which incorporates the specified if/then/else logic
+     * @throws NullPointerException if any argument is null
+     * @throws IllegalArgumentException if {@code test} does not return boolean,
+     *          or if all three method types do not match (with the return
+     *          type of {@code test} changed to match that of the target).
+     */
+    public static
+    MethodHandle guardWithTest(MethodHandle test,
+                               MethodHandle target,
+                               MethodHandle fallback) {
+        MethodType gtype = test.type();
+        MethodType ttype = target.type();
+        MethodType ftype = fallback.type();
+        if (!ttype.equals(ftype))
+            throw misMatchedTypes("target and fallback types", ttype, ftype);
+        if (gtype.returnType() != boolean.class)
+            throw newIllegalArgumentException("guard type is not a predicate "+gtype);
+        List<Class<?>> targs = ttype.parameterList();
+        List<Class<?>> gargs = gtype.parameterList();
+        if (!targs.equals(gargs)) {
+            int gpc = gargs.size(), tpc = targs.size();
+            if (gpc >= tpc || !targs.subList(0, gpc).equals(gargs))
+                throw misMatchedTypes("target and test types", ttype, gtype);
+            test = dropArguments(test, gpc, targs.subList(gpc, tpc));
+            gtype = test.type();
+        }
+
+        // TODO(narayan): Implement this method.
+        // return MethodHandleImpl.makeGuardWithTest(test, target, fallback);
+        throw new UnsupportedOperationException("MethodHandles.guardWithTest is not implemented");
+    }
+
+    static RuntimeException misMatchedTypes(String what, MethodType t1, MethodType t2) {
+        return newIllegalArgumentException(what + " must match: " + t1 + " != " + t2);
+    }
+
+    /**
+     * Makes a method handle which adapts a target method handle,
+     * by running it inside an exception handler.
+     * If the target returns normally, the adapter returns that value.
+     * If an exception matching the specified type is thrown, the fallback
+     * handle is called instead on the exception, plus the original arguments.
+     * <p>
+     * The target and handler must have the same corresponding
+     * argument and return types, except that handler may omit trailing arguments
+     * (similarly to the predicate in {@link #guardWithTest guardWithTest}).
+     * Also, the handler must have an extra leading parameter of {@code exType} or a supertype.
+     * <p> Here is pseudocode for the resulting adapter:
+     * <blockquote><pre>{@code
+     * T target(A..., B...);
+     * T handler(ExType, A...);
+     * T adapter(A... a, B... b) {
+     *   try {
+     *     return target(a..., b...);
+     *   } catch (ExType ex) {
+     *     return handler(ex, a...);
+     *   }
+     * }
+     * }</pre></blockquote>
+     * Note that the saved arguments ({@code a...} in the pseudocode) cannot
+     * be modified by execution of the target, and so are passed unchanged
+     * from the caller to the handler, if the handler is invoked.
+     * <p>
+     * The target and handler must return the same type, even if the handler
+     * always throws.  (This might happen, for instance, because the handler
+     * is simulating a {@code finally} clause).
+     * To create such a throwing handler, compose the handler creation logic
+     * with {@link #throwException throwException},
+     * in order to create a method handle of the correct return type.
+     * @param target method handle to call
+     * @param exType the type of exception which the handler will catch
+     * @param handler method handle to call if a matching exception is thrown
+     * @return method handle which incorporates the specified try/catch logic
+     * @throws NullPointerException if any argument is null
+     * @throws IllegalArgumentException if {@code handler} does not accept
+     *          the given exception type, or if the method handle types do
+     *          not match in their return types and their
+     *          corresponding parameters
+     */
+    public static
+    MethodHandle catchException(MethodHandle target,
+                                Class<? extends Throwable> exType,
+                                MethodHandle handler) {
+        MethodType ttype = target.type();
+        MethodType htype = handler.type();
+        if (htype.parameterCount() < 1 ||
+            !htype.parameterType(0).isAssignableFrom(exType))
+            throw newIllegalArgumentException("handler does not accept exception type "+exType);
+        if (htype.returnType() != ttype.returnType())
+            throw misMatchedTypes("target and handler return types", ttype, htype);
+        List<Class<?>> targs = ttype.parameterList();
+        List<Class<?>> hargs = htype.parameterList();
+        hargs = hargs.subList(1, hargs.size());  // omit leading parameter from handler
+        if (!targs.equals(hargs)) {
+            int hpc = hargs.size(), tpc = targs.size();
+            if (hpc >= tpc || !targs.subList(0, hpc).equals(hargs))
+                throw misMatchedTypes("target and handler types", ttype, htype);
+            handler = dropArguments(handler, 1+hpc, targs.subList(hpc, tpc));
+            htype = handler.type();
+        }
+
+        // TODO(narayan): Implement this method.
+        // return MethodHandleImpl.makeGuardWithCatch(target, exType, handler);
+        throw new UnsupportedOperationException("MethodHandles.catchException is not implemented");
+    }
+
+    /**
+     * Produces a method handle which will throw exceptions of the given {@code exType}.
+     * The method handle will accept a single argument of {@code exType},
+     * and immediately throw it as an exception.
+     * The method type will nominally specify a return of {@code returnType}.
+     * The return type may be anything convenient:  It doesn't matter to the
+     * method handle's behavior, since it will never return normally.
+     * @param returnType the return type of the desired method handle
+     * @param exType the parameter type of the desired method handle
+     * @return method handle which can throw the given exceptions
+     * @throws NullPointerException if either argument is null
+     */
+    public static
+    MethodHandle throwException(Class<?> returnType, Class<? extends Throwable> exType) {
+        if (!Throwable.class.isAssignableFrom(exType))
+            throw new ClassCastException(exType.getName());
+
+        // TODO(narayan): Implement this method.
+        // return MethodHandleImpl.throwException(MethodType.methodType(returnType, exType));
+        throw new UnsupportedOperationException("MethodHandles.throwException is not implemented");
+    }
+}
diff --git a/ojluni/src/main/java/java/lang/reflect/Constructor.java b/ojluni/src/main/java/java/lang/reflect/Constructor.java
index a85d427..7e3a71d 100644
--- a/ojluni/src/main/java/java/lang/reflect/Constructor.java
+++ b/ojluni/src/main/java/java/lang/reflect/Constructor.java
@@ -26,10 +26,8 @@
 
 package java.lang.reflect;
 
-import java.util.Comparator;
-import libcore.reflect.Types;
-
 import java.lang.annotation.Annotation;
+import java.util.Comparator;
 
 /**
  * {@code Constructor} provides information about, and access to, a single
@@ -51,7 +49,7 @@
  * @author      Kenneth Russell
  * @author      Nakul Saraiya
  */
-public final class Constructor<T> extends AbstractMethod {
+public final class Constructor<T> extends Executable {
     private static final Comparator<Method> ORDER_BY_SIGNATURE = null; // Unused; must match Method.
 
     private final Class<?> serializationClass;
@@ -76,7 +74,7 @@
 
     @Override
     boolean hasGenericInformation() {
-        // Android-changed: Signature retrieval is handled in AbstractMethod.
+        // Android-changed: Signature retrieval is handled in Executable.
         return super.hasGenericInformationInternal();
     }
 
@@ -86,8 +84,8 @@
     @Override
     @SuppressWarnings({"rawtypes", "unchecked"})
     public Class<T> getDeclaringClass() {
-        // Android-changed: This is handled by AbstractMethod.
-        return (Class<T>) super.getDeclaringClass();
+        // Android-changed: This is handled by Executable.
+        return (Class<T>) super.getDeclaringClassInternal();
     }
 
     /**
@@ -104,8 +102,8 @@
      */
     @Override
     public int getModifiers() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getModifiers();
+        // Android-changed: This is handled by Executable.
+        return super.getModifiersInternal();
     }
 
     /**
@@ -116,7 +114,7 @@
     @Override
     @SuppressWarnings({"rawtypes", "unchecked"})
     public TypeVariable<Constructor<T>>[] getTypeParameters() {
-        // Android-changed: This is mostly handled by AbstractMethod.
+        // Android-changed: This is mostly handled by Executable.
         GenericInfo info = getMethodOrConstructorGenericInfoInternal();
         return (TypeVariable<Constructor<T>>[]) info.formalTypeParameters.clone();
     }
@@ -127,16 +125,16 @@
      */
     @Override
     public Class<?>[] getParameterTypes() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getParameterTypes();
+        // Android-changed: This is handled by Executable.
+        return super.getParameterTypesInternal();
     }
 
     /**
      * {@inheritDoc}
      */
     public int getParameterCount() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getParameterCount();
+        // Android-changed: This is handled by Executable.
+        return super.getParameterCountInternal();
     }
 
     /**
@@ -377,7 +375,7 @@
      */
     @Override
     public Annotation[][] getParameterAnnotations() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getParameterAnnotations();
+        // Android-changed: This is handled by Executable.
+        return super.getParameterAnnotationsInternal();
     }
 }
diff --git a/ojluni/src/main/java/java/lang/reflect/Executable.java b/ojluni/src/main/java/java/lang/reflect/Executable.java
index 6c7f775..38e6f99 100644
--- a/ojluni/src/main/java/java/lang/reflect/Executable.java
+++ b/ojluni/src/main/java/java/lang/reflect/Executable.java
@@ -25,8 +25,15 @@
 
 package java.lang.reflect;
 
+import com.android.dex.Dex;
+
 import java.lang.annotation.Annotation;
+import java.util.Objects;
 import libcore.reflect.AnnotatedElements;
+import libcore.reflect.GenericSignatureParser;
+import libcore.reflect.ListOfTypes;
+import libcore.reflect.Types;
+import libcore.util.EmptyArray;
 
 /**
  * A shared superclass for the common functionality of {@link Method}
@@ -113,7 +120,6 @@
      */
     abstract void specificToStringHeader(StringBuilder sb);
 
-
     String sharedToGenericString(int modifierMask, boolean isDefault) {
         try {
             StringBuilder sb = new StringBuilder();
@@ -255,9 +261,9 @@
      *     type that cannot be instantiated for any reason
      */
     public Type[] getGenericParameterTypes() {
-        // Android-changed: Implemented in AbstractMethod instead.
-        throw new UnsupportedOperationException(
-                "Executable.getGenericParameterTypes() not implemented");
+        // Android-changed: Changed to use Types / getMethodOrConstructorGenericInfoInternal()
+        return Types.getTypeArray(
+                getMethodOrConstructorGenericInfoInternal().genericParameterTypes, false);
     }
 
     /**
@@ -322,7 +328,6 @@
      * a MethodParameters attribute that is improperly formatted.
      * @return an array of {@code Parameter} objects representing all
      * the parameters to the executable this object represents.
-     * @hide Hidden pending tests
      */
     public Parameter[] getParameters() {
         // TODO: This may eventually need to be guarded by security
@@ -448,9 +453,9 @@
      *     parameterized type that cannot be instantiated for any reason
      */
     public Type[] getGenericExceptionTypes() {
-        // Android-changed: Implemented in AbstractMethod instead.
-        throw new UnsupportedOperationException(
-                "Executable.getGenericExceptionTypes() not implemented");
+        // Android-changed: Changed to use Types / getMethodOrConstructorGenericInfoInternal()
+        return Types.getTypeArray(
+                getMethodOrConstructorGenericInfoInternal().genericExceptionTypes, false);
     }
 
     /**
@@ -469,7 +474,8 @@
      * to take a variable number of arguments.
      */
     public boolean isVarArgs()  {
-        return (getModifiers() & Modifier.VARARGS) != 0;
+        // Android-changed: Slightly more efficient.
+        return (accessFlags & Modifier.VARARGS) != 0;
     }
 
     /**
@@ -482,7 +488,8 @@
      * @jls 13.1 The Form of a Binary
      */
     public boolean isSynthetic() {
-        return Modifier.isSynthetic(getModifiers());
+        // Android-changed: Slightly more efficient.
+        return (accessFlags & Modifier.SYNTHETIC) != 0;
     }
 
     /**
@@ -504,8 +511,11 @@
      * A compiler may add extra parameters that are implicitly
      * declared in source ("mandated"), as well as parameters that
      * are neither implicitly nor explicitly declared in source
-     * ("synthetic") to the parameter list for a method.
+     * ("synthetic") to the parameter list for a method.  See {@link
+     * java.lang.reflect.Parameter} for more information.
      *
+     * @see java.lang.reflect.Parameter
+     * @see java.lang.reflect.Parameter#getAnnotations
      * @return an array of arrays that represent the annotations on
      *    the formal and implicit parameters, in declaration order, of
      *    the executable represented by this object
@@ -517,9 +527,11 @@
      * @throws NullPointerException  {@inheritDoc}
      */
     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
-        // Android-changed: Implemented in AbstractMethod instead.
-        throw new UnsupportedOperationException("Executable.getAnnotation(Class) not implemented");
+        Objects.requireNonNull(annotationClass);
+        // Android-changed: Implemented natively.
+        return getAnnotationNative(annotationClass);
     }
+    private native <T extends Annotation> T getAnnotationNative(Class<T> annotationClass);
 
     /**
      * {@inheritDoc}
@@ -536,8 +548,226 @@
      * {@inheritDoc}
      */
     public Annotation[] getDeclaredAnnotations()  {
-        // Android-changed: Implemented in AbstractMethod instead.
-        throw new UnsupportedOperationException(
-                "Executable.getDeclaredAnnotations() not implemented");
+        // Android-changed: Implemented natively.
+        return getDeclaredAnnotationsNative();
+    }
+    private native Annotation[] getDeclaredAnnotationsNative();
+
+    // Android-changed: Additional ART-related fields and logic below that is shared between
+    // Method and Constructor.
+
+    /** Bits encoding access (e.g. public, private) as well as other runtime specific flags */
+    @SuppressWarnings("unused") // set by runtime
+    private int accessFlags;
+
+    /**
+     * The ArtMethod associated with this Executable, required for dispatching due to entrypoints
+     * Classloader is held live by the declaring class.
+     */
+    @SuppressWarnings("unused") // set by runtime
+    private long artMethod;
+
+    /** Executable's declaring class */
+    @SuppressWarnings("unused") // set by runtime
+    private Class<?> declaringClass;
+
+    /**
+     * Overriden method's declaring class (same as declaringClass unless declaringClass is a proxy
+     * class).
+     */
+    @SuppressWarnings("unused") // set by runtime
+    private Class<?> declaringClassOfOverriddenMethod;
+
+    /** The method index of this method within its defining dex file */
+    @SuppressWarnings("unused") // set by runtime
+    private int dexMethodIndex;
+
+    /**
+     * We insert native method stubs for abstract methods so we don't have to
+     * check the access flags at the time of the method call.  This results in
+     * "native abstract" methods, which can't exist.  If we see the "abstract"
+     * flag set, clear the "native" flag.
+     *
+     * We also move the DECLARED_SYNCHRONIZED flag into the SYNCHRONIZED
+     * position, because the callers of this function are trying to convey
+     * the "traditional" meaning of the flags to their callers.
+     */
+    private static int fixMethodFlags(int flags) {
+        if ((flags & Modifier.ABSTRACT) != 0) {
+            flags &= ~Modifier.NATIVE;
+        }
+        flags &= ~Modifier.SYNCHRONIZED;
+        int ACC_DECLARED_SYNCHRONIZED = 0x00020000;
+        if ((flags & ACC_DECLARED_SYNCHRONIZED) != 0) {
+            flags |= Modifier.SYNCHRONIZED;
+        }
+        return flags & 0xffff;  // mask out bits not used by Java
+    }
+
+    final int getModifiersInternal() {
+        return fixMethodFlags(accessFlags);
+    }
+
+    final Class<?> getDeclaringClassInternal() {
+        return declaringClass;
+    }
+
+    /**
+     * Returns an array of {@code Class} objects associated with the parameter types of this
+     * Executable. If the Executable was declared with no parameters, an empty array will be
+     * returned.
+     *
+     * @return the parameter types
+     */
+    final Class<?>[] getParameterTypesInternal() {
+        Dex dex = declaringClassOfOverriddenMethod.getDex();
+        short[] types = dex.parameterTypeIndicesFromMethodIndex(dexMethodIndex);
+        if (types.length == 0) {
+            return EmptyArray.CLASS;
+        }
+        Class<?>[] parametersArray = new Class[types.length];
+        for (int i = 0; i < types.length; i++) {
+            // Note, in the case of a Proxy the dex cache types are equal.
+            parametersArray[i] = declaringClassOfOverriddenMethod.getDexCacheType(dex, types[i]);
+        }
+        return parametersArray;
+    }
+
+    final int getParameterCountInternal() {
+        Dex dex = declaringClassOfOverriddenMethod.getDex();
+        short[] types = dex.parameterTypeIndicesFromMethodIndex(dexMethodIndex);
+        return types.length;
+    }
+
+    // Android provides a more efficient implementation of this method for Executable than the one
+    // implemented in AnnotatedElement.
+    @Override
+    public final boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+        Objects.requireNonNull(annotationType);
+        return isAnnotationPresentNative(annotationType);
+    }
+    private native boolean isAnnotationPresentNative(Class<? extends Annotation> annotationType);
+
+    final Annotation[][] getParameterAnnotationsInternal() {
+        Annotation[][] parameterAnnotations = getParameterAnnotationsNative();
+        if (parameterAnnotations == null) {
+            parameterAnnotations = new Annotation[getParameterTypes().length][0];
+        }
+        return parameterAnnotations;
+    }
+    private native Annotation[][] getParameterAnnotationsNative();
+
+    /**
+     * @hide - exposed for use by {@link Class}.
+     */
+    public final int getAccessFlags() {
+        return accessFlags;
+    }
+
+    static final class GenericInfo {
+        final ListOfTypes genericExceptionTypes;
+        final ListOfTypes genericParameterTypes;
+        final Type genericReturnType;
+        final TypeVariable<?>[] formalTypeParameters;
+
+        GenericInfo(ListOfTypes exceptions, ListOfTypes parameters, Type ret,
+                TypeVariable<?>[] formal) {
+            genericExceptionTypes = exceptions;
+            genericParameterTypes = parameters;
+            genericReturnType = ret;
+            formalTypeParameters = formal;
+        }
+    }
+
+    final boolean hasGenericInformationInternal() {
+        return getSignatureAnnotation() != null;
+    }
+
+    /**
+     * Returns generic information associated with this method/constructor member.
+     */
+    final GenericInfo getMethodOrConstructorGenericInfoInternal() {
+        String signatureAttribute = getSignatureAttribute();
+        Class<?>[] exceptionTypes = this.getExceptionTypes();
+        GenericSignatureParser parser =
+                new GenericSignatureParser(this.getDeclaringClass().getClassLoader());
+        if (this instanceof Method) {
+            parser.parseForMethod(this, signatureAttribute, exceptionTypes);
+        } else {
+            parser.parseForConstructor(this, signatureAttribute, exceptionTypes);
+        }
+        return new GenericInfo(parser.exceptionTypes, parser.parameterTypes,
+                parser.returnType, parser.formalTypeParameters);
+    }
+
+    private String getSignatureAttribute() {
+        String[] annotation = getSignatureAnnotation();
+        if (annotation == null) {
+            return null;
+        }
+        StringBuilder result = new StringBuilder();
+        for (String s : annotation) {
+            result.append(s);
+        }
+        return result.toString();
+    }
+    private native String[] getSignatureAnnotation();
+
+    final boolean equalNameAndParametersInternal(Method m) {
+        return getName().equals(m.getName()) && equalMethodParameters(m.getParameterTypes());
+    }
+
+    private boolean equalMethodParameters(Class<?>[] params) {
+        Dex dex = declaringClassOfOverriddenMethod.getDex();
+        short[] types = dex.parameterTypeIndicesFromMethodIndex(dexMethodIndex);
+        if (types.length != params.length) {
+            return false;
+        }
+        for (int i = 0; i < types.length; i++) {
+            if (declaringClassOfOverriddenMethod.getDexCacheType(dex, types[i]) != params[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    final int compareMethodParametersInternal(Class<?>[] params) {
+        Dex dex = declaringClassOfOverriddenMethod.getDex();
+        short[] types = dex.parameterTypeIndicesFromMethodIndex(dexMethodIndex);
+        int length = Math.min(types.length, params.length);
+        for (int i = 0; i < length; i++) {
+            Class<?> aType = declaringClassOfOverriddenMethod.getDexCacheType(dex, types[i]);
+            Class<?> bType = params[i];
+            if (aType != bType) {
+                int comparison = aType.getName().compareTo(bType.getName());
+                if (comparison != 0) {
+                    return comparison;
+                }
+            }
+        }
+        return types.length - params.length;
+    }
+
+    final String getMethodNameInternal() {
+        Dex dex = declaringClassOfOverriddenMethod.getDex();
+        int nameIndex = dex.nameIndexFromMethodIndex(dexMethodIndex);
+        return declaringClassOfOverriddenMethod.getDexCacheString(dex, nameIndex);
+    }
+
+    final Class<?> getMethodReturnTypeInternal() {
+        Dex dex = declaringClassOfOverriddenMethod.getDex();
+        int returnTypeIndex = dex.returnTypeIndexFromMethodIndex(dexMethodIndex);
+        // Note, in the case of a Proxy the dex cache types are equal.
+        return declaringClassOfOverriddenMethod.getDexCacheType(dex, returnTypeIndex);
+    }
+
+    /** A cheap implementation for {@link Method#isDefault()}. */
+    final boolean isDefaultMethodInternal() {
+        return (accessFlags & Modifier.DEFAULT) != 0;
+    }
+
+    /** A cheap implementation for {@link Method#isBridge()}. */
+    final boolean isBridgeMethodInternal() {
+        return (accessFlags & Modifier.BRIDGE) != 0;
     }
 }
diff --git a/ojluni/src/main/java/java/lang/reflect/Method.java b/ojluni/src/main/java/java/lang/reflect/Method.java
index fe41c5e..e3fa1c9 100644
--- a/ojluni/src/main/java/java/lang/reflect/Method.java
+++ b/ojluni/src/main/java/java/lang/reflect/Method.java
@@ -50,7 +50,7 @@
  * @author Kenneth Russell
  * @author Nakul Saraiya
  */
-public final class Method extends AbstractMethod  {
+public final class Method extends Executable  {
     /**
      * Orders methods by their name, parameters and return type.
      *
@@ -84,7 +84,7 @@
 
     @Override
     boolean hasGenericInformation() {
-        // Android-changed: Signature retrieval is handled in AbstractMethod.
+        // Android-changed: Signature retrieval is handled in Executable.
         return super.hasGenericInformationInternal();
     }
 
@@ -93,8 +93,8 @@
      */
     @Override
     public Class<?> getDeclaringClass() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getDeclaringClass();
+        // Android-changed: This is handled by Executable.
+        return super.getDeclaringClassInternal();
     }
 
     /**
@@ -103,7 +103,7 @@
      */
     @Override
     public String getName() {
-        // Android-changed: This is handled by AbstractMethod.
+        // Android-changed: This is handled by Executable.
         return getMethodNameInternal();
     }
 
@@ -112,8 +112,8 @@
      */
     @Override
     public int getModifiers() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getModifiers();
+        // Android-changed: This is handled by Executable.
+        return super.getModifiersInternal();
     }
 
     /**
@@ -124,7 +124,7 @@
     @Override
     @SuppressWarnings({"rawtypes", "unchecked"})
     public TypeVariable<Method>[] getTypeParameters() {
-        // Android-changed: This is mostly handled by AbstractMethod.
+        // Android-changed: This is mostly handled by Executable.
         GenericInfo info = getMethodOrConstructorGenericInfoInternal();
         return (TypeVariable<Method>[]) info.formalTypeParameters.clone();
     }
@@ -136,7 +136,7 @@
      * @return the return type for the method this object represents
      */
     public Class<?> getReturnType() {
-        // Android-changed: This is handled by AbstractMethod.
+        // Android-changed: This is handled by Executable.
         return getMethodReturnTypeInternal();
     }
 
@@ -165,7 +165,7 @@
      * @since 1.5
      */
     public Type getGenericReturnType() {
-        // Android-changed: Modified implementation to use AbstractMethod.
+        // Android-changed: Modified implementation to use Executable.
       return Types.getType(getMethodOrConstructorGenericInfoInternal().genericReturnType);
     }
 
@@ -174,16 +174,16 @@
      */
     @Override
     public Class<?>[] getParameterTypes() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getParameterTypes();
+        // Android-changed: This is handled by Executable.
+        return super.getParameterTypesInternal();
     }
 
     /**
      * {@inheritDoc}
      */
     public int getParameterCount() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getParameterCount();
+        // Android-changed: This is handled by Executable.
+        return super.getParameterCountInternal();
     }
 
     /**
@@ -407,7 +407,7 @@
      * @since 1.5
      */
     public boolean isBridge() {
-        // Android-changed: This is handled by AbstractMethod.
+        // Android-changed: This is handled by Executable.
         return super.isBridgeMethodInternal();
     }
 
@@ -443,7 +443,7 @@
      * @since 1.8
      */
     public boolean isDefault() {
-        // Android-changed: This is handled by AbstractMethod.
+        // Android-changed: This is handled by Executable.
         return super.isDefaultMethodInternal();
     }
 
@@ -486,8 +486,8 @@
      */
     @Override
     public Annotation[][] getParameterAnnotations() {
-        // Android-changed: This is handled by AbstractMethod.
-        return super.getParameterAnnotations();
+        // Android-changed: This is handled by Executable.
+        return super.getParameterAnnotationsInternal();
     }
 
     /**
diff --git a/ojluni/src/main/java/java/lang/reflect/Parameter.java b/ojluni/src/main/java/java/lang/reflect/Parameter.java
index 89dd606..2d96307 100644
--- a/ojluni/src/main/java/java/lang/reflect/Parameter.java
+++ b/ojluni/src/main/java/java/lang/reflect/Parameter.java
@@ -38,7 +38,6 @@
  * means of obtaining attributes for the parameter.
  *
  * @since 1.8
- * @hide Hidden pending tests
  */
 public final class Parameter implements AnnotatedElement {
 
diff --git a/ojluni/src/main/java/java/security/Signature.java b/ojluni/src/main/java/java/security/Signature.java
index 8923ecd..a8a42a1 100644
--- a/ojluni/src/main/java/java/security/Signature.java
+++ b/ojluni/src/main/java/java/security/Signature.java
@@ -1,6 +1,6 @@
 /*
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright (C) 2014 The Android Open Source Project
- * Copyright (c) 1996, 2012, 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
@@ -42,8 +42,9 @@
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.BadPaddingException;
 import javax.crypto.NoSuchPaddingException;
-
+/* BEGIN ANDROID-REMOVED: this debugging mechanism is not available in Android.
 import sun.security.util.Debug;
+ * END ANDROID-REMOVED */
 import sun.security.jca.*;
 import sun.security.jca.GetInstance.Instance;
 
@@ -54,10 +55,10 @@
  *
  * <p> The signature algorithm can be, among others, the NIST standard
  * DSA, using DSA and SHA-1. The DSA algorithm using the
- * SHA-1 message digest algorithm can be specified as <tt>SHA1withDSA</tt>.
+ * SHA-1 message digest algorithm can be specified as {@code SHA1withDSA}.
  * In the case of RSA, there are multiple choices for the message digest
  * algorithm, so the signing algorithm could be specified as, for example,
- * <tt>MD2withRSA</tt>, <tt>MD5withRSA</tt>, or <tt>SHA1withRSA</tt>.
+ * {@code MD2withRSA}, {@code MD5withRSA}, or {@code SHA1withRSA}.
  * The algorithm name must be specified, as there is no default.
  *
  * <p> A Signature object can be used to generate and verify digital
@@ -78,13 +79,13 @@
  *     (see {@link #initSign(PrivateKey)}
  *     and {@link #initSign(PrivateKey, SecureRandom)}).
  *
- *     </ul><p>
+ *     </ul>
  *
- * <li>Updating<p>
+ * <li>Updating
  *
  * <p>Depending on the type of initialization, this will update the
  * bytes to be signed or verified. See the
- * {@link #update(byte) update} methods.<p>
+ * {@link #update(byte) update} methods.
  *
  * <li>Signing or Verifying a signature on all updated bytes. See the
  * {@link #sign() sign} methods and the {@link #verify(byte[]) verify}
@@ -93,13 +94,13 @@
  * </ol>
  *
  * <p>Note that this class is abstract and extends from
- * <code>SignatureSpi</code> for historical reasons.
+ * {@code SignatureSpi} for historical reasons.
  * Application developers should only take notice of the methods defined in
- * this <code>Signature</code> class; all the methods in
+ * this {@code Signature} class; all the methods in
  * the superclass are intended for cryptographic service providers who wish to
  * supply their own implementations of digital signature algorithms.
  *
- * <p> Android provides the following <code>Signature</code> algorithms:
+ * <p> Android provides the following {@code Signature} algorithms:
  * <table>
  *     <thead>
  *         <tr>
@@ -214,9 +215,16 @@
 
 public abstract class Signature extends SignatureSpi {
 
+    /* BEGIN ANDROID-REMOVED: this debugging mechanism not available in Android
     private static final Debug debug =
                         Debug.getInstance("jca", "Signature");
 
+    private static final Debug pdebug =
+                        Debug.getInstance("provider", "Provider");
+    private static final boolean skipDebug =
+        Debug.isOn("engine=") && !Debug.isOn("signature");
+     * END ANDROID-REMOVED */
+
     /*
      * The algorithm for this signature object.
      * This value is used to map an OID to the particular algorithm.
@@ -344,6 +352,7 @@
         Signature sig;
         if (instance.impl instanceof Signature) {
             sig = (Signature)instance.impl;
+            sig.algorithm = algorithm;
         } else {
             SignatureSpi spi = (SignatureSpi)instance.impl;
             sig = new Delegate(spi, algorithm);
@@ -385,11 +394,13 @@
                 // instance of SignatureSpi but not Signature
                 boolean r = (instance instanceof SignatureSpi)
                                 && (instance instanceof Signature == false);
+                /* BEGIN ANDROID-REMOVED: this mechanism not available in Android
                 if ((debug != null) && (r == false)) {
                     debug.println("Not a SignatureSpi " + className);
                     debug.println("Delayed provider selection may not be "
                         + "available for algorithm " + s.getAlgorithm());
                 }
+                 * END ANDROID-REMOVED */
                 result = Boolean.valueOf(r);
                 signatureInfo.put(className, result);
             } catch (Exception e) {
@@ -546,6 +557,13 @@
             throws InvalidKeyException {
         engineInitVerify(publicKey);
         state = VERIFY;
+
+        /* BEGIN ANDROID-REMOVED: this debugging mechanism not supported in Android.
+        if (!skipDebug && pdebug != null) {
+            pdebug.println("Signature." + algorithm +
+                " verification algorithm from: " + this.provider.getName());
+        }
+         * END ANDROID-REMOVED */
     }
 
     /**
@@ -556,7 +574,7 @@
      * extension field implies that the public key in
      * the certificate and its corresponding private key are not
      * supposed to be used for digital signatures, an
-     * <code>InvalidKeyException</code> is thrown.
+     * {@code InvalidKeyException} is thrown.
      *
      * @param certificate the certificate of the identity whose signature is
      * going to be verified.
@@ -590,6 +608,13 @@
         PublicKey publicKey = certificate.getPublicKey();
         engineInitVerify(publicKey);
         state = VERIFY;
+
+        /* BEGIN ANDROID-REMOVED: this debugging mechanism is not supported in Android.
+        if (!skipDebug && pdebug != null) {
+            pdebug.println("Signature." + algorithm +
+                " verification algorithm from: " + this.provider.getName());
+        }
+         * END ANDROID-REMOVED */
     }
 
     /**
@@ -606,6 +631,13 @@
             throws InvalidKeyException {
         engineInitSign(privateKey);
         state = SIGN;
+
+        /* BEGIN ANDROID-REMOVED: this debugging mechanism is not supported in Android.
+        if (!skipDebug && pdebug != null) {
+            pdebug.println("Signature." + algorithm +
+                " signing algorithm from: " + this.provider.getName());
+        }
+         * END ANDROID-REMOVED */
     }
 
     /**
@@ -624,6 +656,13 @@
             throws InvalidKeyException {
         engineInitSign(privateKey, random);
         state = SIGN;
+
+        /* BEGIN ANDROID-REMOVED: this debugging mechanism is not supported in Android.
+        if (!skipDebug && pdebug != null) {
+            pdebug.println("Signature." + algorithm +
+                " signing algorithm from: " + this.provider.getName());
+        }
+         * END ANDROID-REMOVED */
     }
 
     /**
@@ -633,10 +672,10 @@
      *
      * <p>A call to this method resets this signature object to the state
      * it was in when previously initialized for signing via a
-     * call to <code>initSign(PrivateKey)</code>. That is, the object is
+     * call to {@code initSign(PrivateKey)}. That is, the object is
      * reset and available to generate another signature from the same
-     * signer, if desired, via new calls to <code>update</code> and
-     * <code>sign</code>.
+     * signer, if desired, via new calls to {@code update} and
+     * {@code sign}.
      *
      * @return the signature bytes of the signing operation's result.
      *
@@ -654,28 +693,28 @@
 
     /**
      * Finishes the signature operation and stores the resulting signature
-     * bytes in the provided buffer <code>outbuf</code>, starting at
-     * <code>offset</code>.
+     * bytes in the provided buffer {@code outbuf}, starting at
+     * {@code offset}.
      * The format of the signature depends on the underlying
      * signature scheme.
      *
      * <p>This signature object is reset to its initial state (the state it
-     * was in after a call to one of the <code>initSign</code> methods) and
+     * was in after a call to one of the {@code initSign} methods) and
      * can be reused to generate further signatures with the same private key.
      *
      * @param outbuf buffer for the signature result.
      *
-     * @param offset offset into <code>outbuf</code> where the signature is
+     * @param offset offset into {@code outbuf} where the signature is
      * stored.
      *
-     * @param len number of bytes within <code>outbuf</code> allotted for the
+     * @param len number of bytes within {@code outbuf} allotted for the
      * signature.
      *
-     * @return the number of bytes placed into <code>outbuf</code>.
+     * @return the number of bytes placed into {@code outbuf}.
      *
      * @exception SignatureException if this signature object is not
      * initialized properly, if this signature algorithm is unable to
-     * process the input data provided, or if <code>len</code> is less
+     * process the input data provided, or if {@code len} is less
      * than the actual signature length.
      *
      * @since 1.2
@@ -685,6 +724,9 @@
         if (outbuf == null) {
             throw new IllegalArgumentException("No output buffer given");
         }
+        if (offset < 0 || len < 0) {
+            throw new IllegalArgumentException("offset or len is less than 0");
+        }
         if (outbuf.length - offset < len) {
             throw new IllegalArgumentException
                 ("Output buffer too small for specified offset and length");
@@ -701,9 +743,9 @@
      *
      * <p>A call to this method resets this signature object to the state
      * it was in when previously initialized for verification via a
-     * call to <code>initVerify(PublicKey)</code>. That is, the object is
+     * call to {@code initVerify(PublicKey)}. That is, the object is
      * reset and available to verify another signature from the identity
-     * whose public key was specified in the call to <code>initVerify</code>.
+     * whose public key was specified in the call to {@code initVerify}.
      *
      * @param signature the signature bytes to be verified.
      *
@@ -728,9 +770,9 @@
      *
      * <p>A call to this method resets this signature object to the state
      * it was in when previously initialized for verification via a
-     * call to <code>initVerify(PublicKey)</code>. That is, the object is
+     * call to {@code initVerify(PublicKey)}. That is, the object is
      * reset and available to verify another signature from the identity
-     * whose public key was specified in the call to <code>initVerify</code>.
+     * whose public key was specified in the call to {@code initVerify}.
      *
      *
      * @param signature the signature bytes to be verified.
@@ -743,19 +785,26 @@
      * initialized properly, the passed-in signature is improperly
      * encoded or of the wrong type, if this signature algorithm is unable to
      * process the input data provided, etc.
-     * @exception IllegalArgumentException if the <code>signature</code>
-     * byte array is null, or the <code>offset</code> or <code>length</code>
-     * is less than 0, or the sum of the <code>offset</code> and
-     * <code>length</code> is greater than the length of the
-     * <code>signature</code> byte array.
+     * @exception IllegalArgumentException if the {@code signature}
+     * byte array is null, or the {@code offset} or {@code length}
+     * is less than 0, or the sum of the {@code offset} and
+     * {@code length} is greater than the length of the
+     * {@code signature} byte array.
      * @since 1.4
      */
     public final boolean verify(byte[] signature, int offset, int length)
         throws SignatureException {
         if (state == VERIFY) {
-            if ((signature == null) || (offset < 0) || (length < 0) ||
-                (length > signature.length - offset)) {
-                throw new IllegalArgumentException("Bad arguments");
+            if (signature == null) {
+                throw new IllegalArgumentException("signature is null");
+            }
+            if (offset < 0 || length < 0) {
+                throw new IllegalArgumentException
+                    ("offset or length is less than 0");
+            }
+            if (signature.length - offset < length) {
+                throw new IllegalArgumentException
+                    ("signature too small for specified offset and length");
             }
 
             return engineVerify(signature, offset, length);
@@ -807,17 +856,17 @@
      */
     public final void update(byte[] data, int off, int len)
             throws SignatureException {
-        // Android-changed: Check data, off & len early and throw an exception
-        // as soon as possible.
-        if (data == null) {
-            throw new IllegalArgumentException("data == null");
-        }
-
-        if (off < 0 || len < 0 || off + len > data.length) {
-            throw new IllegalArgumentException();
-        }
-
         if (state == SIGN || state == VERIFY) {
+            if (data == null) {
+                throw new IllegalArgumentException("data is null");
+            }
+            if (off < 0 || len < 0) {
+                throw new IllegalArgumentException("off or len is less than 0");
+            }
+            if (data.length - off < len) {
+                throw new IllegalArgumentException
+                    ("data too small for specified offset and length");
+            }
             engineUpdate(data, off, len);
         } else {
             throw new SignatureException("object not initialized for "
@@ -827,8 +876,8 @@
 
     /**
      * Updates the data to be signed or verified using the specified
-     * ByteBuffer. Processes the <code>data.remaining()</code> bytes
-     * starting at at <code>data.position()</code>.
+     * ByteBuffer. Processes the {@code data.remaining()} bytes
+     * starting at at {@code data.position()}.
      * Upon return, the buffer's position will be equal to its limit;
      * its limit will not have changed.
      *
@@ -895,7 +944,7 @@
      * @param param the string identifier of the parameter.
      * @param value the parameter value.
      *
-     * @exception InvalidParameterException if <code>param</code> is an
+     * @exception InvalidParameterException if {@code param} is an
      * invalid parameter for this signature algorithm engine,
      * the parameter is already set
      * and cannot be set again, a security exception occurs, and so on.
@@ -961,7 +1010,7 @@
      * @return the object that represents the parameter value, or null if
      * there is none.
      *
-     * @exception InvalidParameterException if <code>param</code> is an invalid
+     * @exception InvalidParameterException if {@code param} is an invalid
      * parameter for this engine, or another exception occurs while
      * trying to get this parameter.
      *
@@ -982,7 +1031,7 @@
      * @return a clone if the implementation is cloneable.
      *
      * @exception CloneNotSupportedException if this is called
-     * on an implementation that does not support <code>Cloneable</code>.
+     * on an implementation that does not support {@code Cloneable}.
      */
     public Object clone() throws CloneNotSupportedException {
         if (this instanceof Cloneable) {
@@ -1015,6 +1064,7 @@
      * and its original parent (Object).
      */
 
+    @SuppressWarnings("deprecation")
     private static class Delegate extends Signature {
 
         // The provider implementation (delegate)
@@ -1043,7 +1093,7 @@
          * @return a clone if the delegate is cloneable.
          *
          * @exception CloneNotSupportedException if this is called on a
-         * delegate that does not support <code>Cloneable</code>.
+         * delegate that does not support {@code Cloneable}.
          */
         public Object clone() throws CloneNotSupportedException {
             chooseFirstProvider();
@@ -1097,6 +1147,7 @@
                 if (sigSpi != null) {
                     return;
                 }
+                /* BEGIN ANDROID-REMOVED: this debugging mechanism is not supported in Android.
                 if (debug != null) {
                     int w = --warnCount;
                     if (w >= 0) {
@@ -1109,6 +1160,7 @@
                         new Exception("Call trace").printStackTrace();
                     }
                 }
+                 * END ANDROID-REMOVED */
                 Exception lastException = null;
                 List<Service> list;
                 if (((Signature)this).algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
@@ -1313,6 +1365,7 @@
     }
 
     // adapter for RSA/ECB/PKCS1Padding ciphers
+    @SuppressWarnings("deprecation")
     private static class CipherAdapter extends SignatureSpi {
 
         private final Cipher cipher;
@@ -1378,7 +1431,7 @@
                 byte[] out = cipher.doFinal(sigBytes);
                 byte[] dataBytes = data.toByteArray();
                 data.reset();
-                return Arrays.equals(out, dataBytes);
+                return MessageDigest.isEqual(out, dataBytes);
             } catch (BadPaddingException e) {
                 // e.g. wrong public key used
                 // return false rather than throwing exception
diff --git a/ojluni/src/main/java/java/text/SimpleDateFormat.java b/ojluni/src/main/java/java/text/SimpleDateFormat.java
index c1301b3..dfe1cb8 100644
--- a/ojluni/src/main/java/java/text/SimpleDateFormat.java
+++ b/ojluni/src/main/java/java/text/SimpleDateFormat.java
@@ -58,6 +58,7 @@
 
 import static java.text.DateFormatSymbols.*;
 
+// Android-changed: Added supported API level, removed unnecessary <br>
 /**
  * <code>SimpleDateFormat</code> is a concrete class for formatting and
  * parsing dates in a locale-sensitive manner. It allows for formatting
@@ -100,116 +101,139 @@
  *         <th align=left>Date or Time Component
  *         <th align=left>Presentation
  *         <th align=left>Examples
+ *         <th align=left>Supported (API Levels)
  *     <tr>
  *         <td><code>G</code>
  *         <td>Era designator
  *         <td><a href="#text">Text</a>
  *         <td><code>AD</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>y</code>
  *         <td>Year
  *         <td><a href="#year">Year</a>
  *         <td><code>1996</code>; <code>96</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>Y</code>
  *         <td>Week year
  *         <td><a href="#year">Year</a>
  *         <td><code>2009</code>; <code>09</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>M</code>
  *         <td>Month in year (context sensitive)
  *         <td><a href="#month">Month</a>
  *         <td><code>July</code>; <code>Jul</code>; <code>07</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>w</code>
  *         <td>Week in year
  *         <td><a href="#number">Number</a>
  *         <td><code>27</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>W</code>
  *         <td>Week in month
  *         <td><a href="#number">Number</a>
  *         <td><code>2</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>D</code>
  *         <td>Day in year
  *         <td><a href="#number">Number</a>
  *         <td><code>189</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>d</code>
  *         <td>Day in month
  *         <td><a href="#number">Number</a>
  *         <td><code>10</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>F</code>
  *         <td>Day of week in month
  *         <td><a href="#number">Number</a>
  *         <td><code>2</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>E</code>
  *         <td>Day name in week
  *         <td><a href="#text">Text</a>
  *         <td><code>Tuesday</code>; <code>Tue</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>u</code>
  *         <td>Day number of week (1 = Monday, ..., 7 = Sunday)
  *         <td><a href="#number">Number</a>
  *         <td><code>1</code>
+ *         <td>24+</td>
  *     <tr>
  *         <td><code>a</code>
  *         <td>Am/pm marker
  *         <td><a href="#text">Text</a>
  *         <td><code>PM</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>H</code>
  *         <td>Hour in day (0-23)
  *         <td><a href="#number">Number</a>
  *         <td><code>0</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>k</code>
  *         <td>Hour in day (1-24)
  *         <td><a href="#number">Number</a>
  *         <td><code>24</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>K</code>
  *         <td>Hour in am/pm (0-11)
  *         <td><a href="#number">Number</a>
  *         <td><code>0</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>h</code>
  *         <td>Hour in am/pm (1-12)
  *         <td><a href="#number">Number</a>
  *         <td><code>12</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>m</code>
  *         <td>Minute in hour
  *         <td><a href="#number">Number</a>
  *         <td><code>30</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>s</code>
  *         <td>Second in minute
  *         <td><a href="#number">Number</a>
  *         <td><code>55</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>S</code>
  *         <td>Millisecond
  *         <td><a href="#number">Number</a>
  *         <td><code>978</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>z</code>
  *         <td>Time zone
  *         <td><a href="#timezone">General time zone</a>
  *         <td><code>Pacific Standard Time</code>; <code>PST</code>; <code>GMT-08:00</code>
+ *         <td>1+</td>
  *     <tr style="background-color: rgb(238, 238, 255);">
  *         <td><code>Z</code>
  *         <td>Time zone
  *         <td><a href="#rfc822timezone">RFC 822 time zone</a>
  *         <td><code>-0800</code>
+ *         <td>1+</td>
  *     <tr>
  *         <td><code>X</code>
  *         <td>Time zone
  *         <td><a href="#iso8601timezone">ISO 8601 time zone</a>
  *         <td><code>-08</code>; <code>-0800</code>;  <code>-08:00</code>
+ *         <td>1+</td>
  * </table>
  * </blockquote>
  * Pattern letters are usually repeated, as their number determines the
@@ -220,15 +244,15 @@
  *     the full form is used; otherwise a short or abbreviated form
  *     is used if available.
  *     For parsing, both forms are accepted, independent of the number
- *     of pattern letters.<br><br></li>
+ *     of pattern letters.</li>
  * <li><strong><a name="number">Number:</a></strong>
  *     For formatting, the number of pattern letters is the minimum
  *     number of digits, and shorter numbers are zero-padded to this amount.
  *     For parsing, the number of pattern letters is ignored unless
- *     it's needed to separate two adjacent fields.<br><br></li>
+ *     it's needed to separate two adjacent fields.</li>
  * <li><strong><a name="year">Year:</a></strong>
  *     If the formatter's {@link #getCalendar() Calendar} is the Gregorian
- *     calendar, the following rules are applied.<br>
+ *     calendar, the following rules are applied.
  *     <ul>
  *     <li>For formatting, if the number of pattern letters is 2, the year
  *         is truncated to 2 digits; otherwise it is interpreted as a
@@ -257,7 +281,7 @@
  *     letters is 4 or more, a calendar specific {@linkplain
  *     Calendar#LONG long form} is used. Otherwise, a calendar
  *     specific {@linkplain Calendar#SHORT short or abbreviated form}
- *     is used.<br>
+ *     is used.
  *     <br>
  *     If week year {@code 'Y'} is specified and the {@linkplain
  *     #getCalendar() calendar} doesn't support any <a
@@ -266,11 +290,11 @@
  *     support of week years can be tested with a call to {@link
  *     DateFormat#getCalendar() getCalendar()}.{@link
  *     java.util.Calendar#isWeekDateSupported()
- *     isWeekDateSupported()}.<br><br></li>
+ *     isWeekDateSupported()}.</li>
  * <li><strong><a name="month">Month:</a></strong>
  *     If the number of pattern letters is 3 or more, the month is
  *     interpreted as <a href="#text">text</a>; otherwise,
- *     it is interpreted as a <a href="#number">number</a>.<br><br></li>
+ *     it is interpreted as a <a href="#number">number</a>.</li>
  * <li><strong><a name="timezone">General time zone:</a></strong>
  *     Time zones are interpreted as <a href="#text">text</a> if they have
  *     names. For time zones representing a GMT offset value, the
@@ -291,7 +315,7 @@
  *     00 and 59. The format is locale independent and digits must be taken
  *     from the Basic Latin block of the Unicode standard.
  *     <p>For parsing, <a href="#rfc822timezone">RFC 822 time zones</a> are also
- *     accepted.<br><br></li>
+ *     accepted.</li>
  * <li><strong><a name="rfc822timezone">RFC 822 time zone:</a></strong>
  *     For formatting, the RFC 822 4-digit time zone format is used:
  *
diff --git a/ojluni/src/main/java/java/util/Properties.java b/ojluni/src/main/java/java/util/Properties.java
index 7c3f0bb..fe61f98 100644
--- a/ojluni/src/main/java/java/util/Properties.java
+++ b/ojluni/src/main/java/java/util/Properties.java
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2014 The Android Open Source Project
- * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,8 +37,8 @@
 import java.io.BufferedWriter;
 
 /**
- * The <code>Properties</code> class represents a persistent set of
- * properties. The <code>Properties</code> can be saved to a stream
+ * The {@code Properties} class represents a persistent set of
+ * properties. The {@code Properties} can be saved to a stream
  * or loaded from a stream. Each key and its corresponding value in
  * the property list is a string.
  * <p>
@@ -46,17 +46,17 @@
  * "defaults"; this second property list is searched if
  * the property key is not found in the original property list.
  * <p>
- * Because <code>Properties</code> inherits from <code>Hashtable</code>, the
- * <code>put</code> and <code>putAll</code> methods can be applied to a
- * <code>Properties</code> object.  Their use is strongly discouraged as they
+ * Because {@code Properties} inherits from {@code Hashtable}, the
+ * {@code put} and {@code putAll} methods can be applied to a
+ * {@code Properties} object.  Their use is strongly discouraged as they
  * allow the caller to insert entries whose keys or values are not
- * <code>Strings</code>.  The <code>setProperty</code> method should be used
- * instead.  If the <code>store</code> or <code>save</code> method is called
- * on a "compromised" <code>Properties</code> object that contains a
- * non-<code>String</code> key or value, the call will fail. Similarly,
- * the call to the <code>propertyNames</code> or <code>list</code> method
- * will fail if it is called on a "compromised" <code>Properties</code>
- * object that contains a non-<code>String</code> key.
+ * {@code Strings}.  The {@code setProperty} method should be used
+ * instead.  If the {@code store} or {@code save} method is called
+ * on a "compromised" {@code Properties} object that contains a
+ * non-{@code String} key or value, the call will fail. Similarly,
+ * the call to the {@code propertyNames} or {@code list} method
+ * will fail if it is called on a "compromised" {@code Properties}
+ * object that contains a non-{@code String} key.
  *
  * <p>
  * The {@link #load(java.io.Reader) load(Reader)} <tt>/</tt>
@@ -78,8 +78,9 @@
  * <p> The {@link #loadFromXML(InputStream)} and {@link
  * #storeToXML(OutputStream, String, String)} methods load and store properties
  * in a simple XML format.  By default the UTF-8 character encoding is used,
- * however a specific encoding may be specified if required.  An XML properties
- * document has the following DOCTYPE declaration:
+ * however a specific encoding may be specified if required. Implementations
+ * are required to support UTF-8 and UTF-16 and may support other encodings.
+ * An XML properties document has the following DOCTYPE declaration:
  *
  * <pre>
  * &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;
@@ -146,15 +147,15 @@
     }
 
     /**
-     * Calls the <tt>Hashtable</tt> method <code>put</code>. Provided for
+     * Calls the <tt>Hashtable</tt> method {@code put}. Provided for
      * parallelism with the <tt>getProperty</tt> method. Enforces use of
      * strings for property keys and values. The value returned is the
-     * result of the <tt>Hashtable</tt> call to <code>put</code>.
+     * result of the <tt>Hashtable</tt> call to {@code put}.
      *
      * @param key the key to be placed into this property list.
      * @param value the value corresponding to <tt>key</tt>.
      * @return     the previous value of the specified key in this property
-     *             list, or <code>null</code> if it did not have one.
+     *             list, or {@code null} if it did not have one.
      * @see #getProperty
      * @since    1.2
      */
@@ -171,13 +172,13 @@
      * kinds of line, <i>natural lines</i> and <i>logical lines</i>.
      * A natural line is defined as a line of
      * characters that is terminated either by a set of line terminator
-     * characters (<code>\n</code> or <code>\r</code> or <code>\r\n</code>)
+     * characters ({@code \n} or {@code \r} or {@code \r\n})
      * or by the end of the stream. A natural line may be either a blank line,
      * a comment line, or hold all or some of a key-element pair. A logical
      * line holds all the data of a key-element pair, which may be spread
      * out across several adjacent natural lines by escaping
      * the line terminator sequence with a backslash character
-     * <code>\</code>.  Note that a comment line cannot be extended
+     * {@code \}.  Note that a comment line cannot be extended
      * in this manner; every natural line that is a comment must have
      * its own comment indicator, as described below. Lines are read from
      * input until the end of the stream is reached.
@@ -185,13 +186,13 @@
      * <p>
      * A natural line that contains only white space characters is
      * considered blank and is ignored.  A comment line has an ASCII
-     * <code>'#'</code> or <code>'!'</code> as its first non-white
+     * {@code '#'} or {@code '!'} as its first non-white
      * space character; comment lines are also ignored and do not
      * encode key-element information.  In addition to line
      * terminators, this format considers the characters space
-     * (<code>' '</code>, <code>'&#92;u0020'</code>), tab
-     * (<code>'\t'</code>, <code>'&#92;u0009'</code>), and form feed
-     * (<code>'\f'</code>, <code>'&#92;u000C'</code>) to be white
+     * ({@code ' '}, {@code '\u005Cu0020'}), tab
+     * ({@code '\t'}, {@code '\u005Cu0009'}), and form feed
+     * ({@code '\f'}, {@code '\u005Cu000C'}) to be white
      * space.
      *
      * <p>
@@ -215,32 +216,31 @@
      * <p>
      * The key contains all of the characters in the line starting
      * with the first non-white space character and up to, but not
-     * including, the first unescaped <code>'='</code>,
-     * <code>':'</code>, or white space character other than a line
+     * including, the first unescaped {@code '='},
+     * {@code ':'}, or white space character other than a line
      * terminator. All of these key termination characters may be
      * included in the key by escaping them with a preceding backslash
      * character; for example,<p>
      *
-     * <code>\:\=</code><p>
+     * {@code \:\=}<p>
      *
-     * would be the two-character key <code>":="</code>.  Line
-     * terminator characters can be included using <code>\r</code> and
-     * <code>\n</code> escape sequences.  Any white space after the
+     * would be the two-character key {@code ":="}.  Line
+     * terminator characters can be included using {@code \r} and
+     * {@code \n} escape sequences.  Any white space after the
      * key is skipped; if the first non-white space character after
-     * the key is <code>'='</code> or <code>':'</code>, then it is
+     * the key is {@code '='} or {@code ':'}, then it is
      * ignored and any white space characters after it are also
      * skipped.  All remaining characters on the line become part of
      * the associated element string; if there are no remaining
      * characters, the element is the empty string
-     * <code>&quot;&quot;</code>.  Once the raw character sequences
+     * {@code ""}.  Once the raw character sequences
      * constituting the key and element are identified, escape
      * processing is performed as described above.
      *
      * <p>
      * As an example, each of the following three lines specifies the key
-     * <code>"Truth"</code> and the associated element value
-     * <code>"Beauty"</code>:
-     * <p>
+     * {@code "Truth"} and the associated element value
+     * {@code "Beauty"}:
      * <pre>
      * Truth = Beauty
      *  Truth:Beauty
@@ -248,29 +248,25 @@
      * </pre>
      * As another example, the following three lines specify a single
      * property:
-     * <p>
      * <pre>
      * fruits                           apple, banana, pear, \
      *                                  cantaloupe, watermelon, \
      *                                  kiwi, mango
      * </pre>
-     * The key is <code>"fruits"</code> and the associated element is:
-     * <p>
+     * The key is {@code "fruits"} and the associated element is:
      * <pre>"apple, banana, pear, cantaloupe, watermelon, kiwi, mango"</pre>
-     * Note that a space appears before each <code>\</code> so that a space
-     * will appear after each comma in the final result; the <code>\</code>,
+     * Note that a space appears before each {@code \} so that a space
+     * will appear after each comma in the final result; the {@code \},
      * line terminator, and leading white space on the continuation line are
      * merely discarded and are <i>not</i> replaced by one or more other
      * characters.
      * <p>
      * As a third example, the line:
-     * <p>
      * <pre>cheeses
      * </pre>
-     * specifies that the key is <code>"cheeses"</code> and the associated
-     * element is the empty string <code>""</code>.<p>
+     * specifies that the key is {@code "cheeses"} and the associated
+     * element is the empty string {@code ""}.
      * <p>
-     *
      * <a name="unicodeescapes"></a>
      * Characters in keys and elements can be represented in escape
      * sequences similar to those used for character and string literals
@@ -283,24 +279,24 @@
      * <ul>
      * <li> Octal escapes are not recognized.
      *
-     * <li> The character sequence <code>\b</code> does <i>not</i>
+     * <li> The character sequence {@code \b} does <i>not</i>
      * represent a backspace character.
      *
      * <li> The method does not treat a backslash character,
-     * <code>\</code>, before a non-valid escape character as an
+     * {@code \}, before a non-valid escape character as an
      * error; the backslash is silently dropped.  For example, in a
-     * Java string the sequence <code>"\z"</code> would cause a
+     * Java string the sequence {@code "\z"} would cause a
      * compile time error.  In contrast, this method silently drops
      * the backslash.  Therefore, this method treats the two character
-     * sequence <code>"\b"</code> as equivalent to the single
-     * character <code>'b'</code>.
+     * sequence {@code "\b"} as equivalent to the single
+     * character {@code 'b'}.
      *
      * <li> Escapes are not necessary for single and double quotes;
      * however, by the rule above, single and double quote characters
      * preceded by a backslash still yield single and double quote
      * characters, respectively.
      *
-     * <li> Only a single 'u' character is allowed in a Uniocde escape
+     * <li> Only a single 'u' character is allowed in a Unicode escape
      * sequence.
      *
      * </ul>
@@ -366,7 +362,9 @@
                     valueStart = keyLen + 1;
                     hasSep = true;
                     break;
-                } else if (Character.isWhitespace(c) && !precedingBackslash) {
+                }
+                // Android-changed: use of Character.isWhitespace(c) b/25998006
+                else if (Character.isWhitespace(c) && !precedingBackslash) {
                     valueStart = keyLen + 1;
                     break;
                 }
@@ -379,6 +377,7 @@
             }
             while (valueStart < limit) {
                 c = lr.lineBuf[valueStart];
+                // Android-changed: use of Character.isWhitespace(c) b/25998006
                 if (!Character.isWhitespace(c)) {
                     if (!hasSep && (c == '=' ||  c == ':')) {
                         hasSep = true;
@@ -439,6 +438,9 @@
                         if (len == 0 || isCommentLine) {
                             return -1;
                         }
+                        if (precedingBackslash) {
+                            len--;
+                        }
                         return len;
                     }
                 }
@@ -456,6 +458,7 @@
                     }
                 }
                 if (skipWhiteSpace) {
+                    // Android-changed: use of Character.isWhitespace(c) b/25998006
                     if (Character.isWhitespace(c)) {
                         continue;
                     }
@@ -506,6 +509,9 @@
                                   :inStream.read(inByteBuf);
                         inOff = 0;
                         if (inLimit <= 0) {
+                            if (precedingBackslash) {
+                                len--;
+                            }
                             return len;
                         }
                     }
@@ -689,20 +695,20 @@
     }
 
     /**
-     * Calls the <code>store(OutputStream out, String comments)</code> method
+     * Calls the {@code store(OutputStream out, String comments)} method
      * and suppresses IOExceptions that were thrown.
      *
      * @deprecated This method does not throw an IOException if an I/O error
      * occurs while saving the property list.  The preferred way to save a
-     * properties list is via the <code>store(OutputStream out,
-     * String comments)</code> method or the
-     * <code>storeToXML(OutputStream os, String comment)</code> method.
+     * properties list is via the {@code store(OutputStream out,
+     * String comments)} method or the
+     * {@code storeToXML(OutputStream os, String comment)} method.
      *
      * @param   out      an output stream.
      * @param   comments   a description of the property list.
-     * @exception  ClassCastException  if this <code>Properties</code> object
+     * @exception  ClassCastException  if this {@code Properties} object
      *             contains any keys or values that are not
-     *             <code>Strings</code>.
+     *             {@code Strings}.
      */
     @Deprecated
     public void save(OutputStream out, String comments)  {
@@ -714,37 +720,37 @@
 
     /**
      * Writes this property list (key and element pairs) in this
-     * <code>Properties</code> table to the output character stream in a
+     * {@code Properties} table to the output character stream in a
      * format suitable for using the {@link #load(java.io.Reader) load(Reader)}
      * method.
      * <p>
-     * Properties from the defaults table of this <code>Properties</code>
+     * Properties from the defaults table of this {@code Properties}
      * table (if any) are <i>not</i> written out by this method.
      * <p>
-     * If the comments argument is not null, then an ASCII <code>#</code>
+     * If the comments argument is not null, then an ASCII {@code #}
      * character, the comments string, and a line separator are first written
-     * to the output stream. Thus, the <code>comments</code> can serve as an
+     * to the output stream. Thus, the {@code comments} can serve as an
      * identifying comment. Any one of a line feed ('\n'), a carriage
      * return ('\r'), or a carriage return followed immediately by a line feed
-     * in comments is replaced by a line separator generated by the <code>Writer</code>
-     * and if the next character in comments is not character <code>#</code> or
-     * character <code>!</code> then an ASCII <code>#</code> is written out
+     * in comments is replaced by a line separator generated by the {@code Writer}
+     * and if the next character in comments is not character {@code #} or
+     * character {@code !} then an ASCII {@code #} is written out
      * after that line separator.
      * <p>
      * Next, a comment line is always written, consisting of an ASCII
-     * <code>#</code> character, the current date and time (as if produced
-     * by the <code>toString</code> method of <code>Date</code> for the
-     * current time), and a line separator as generated by the <code>Writer</code>.
+     * {@code #} character, the current date and time (as if produced
+     * by the {@code toString} method of {@code Date} for the
+     * current time), and a line separator as generated by the {@code Writer}.
      * <p>
-     * Then every entry in this <code>Properties</code> table is
+     * Then every entry in this {@code Properties} table is
      * written out, one per line. For each entry the key string is
-     * written, then an ASCII <code>=</code>, then the associated
+     * written, then an ASCII {@code =}, then the associated
      * element string. For the key, all space characters are
-     * written with a preceding <code>\</code> character.  For the
+     * written with a preceding {@code \} character.  For the
      * element, leading space characters, but not embedded or trailing
-     * space characters, are written with a preceding <code>\</code>
-     * character. The key and element characters <code>#</code>,
-     * <code>!</code>, <code>=</code>, and <code>:</code> are written
+     * space characters, are written with a preceding {@code \}
+     * character. The key and element characters {@code #},
+     * {@code !}, {@code =}, and {@code :} are written
      * with a preceding backslash to ensure that they are properly loaded.
      * <p>
      * After the entries have been written, the output stream is flushed.
@@ -755,9 +761,9 @@
      * @param   comments   a description of the property list.
      * @exception  IOException if writing this property list to the specified
      *             output stream throws an <tt>IOException</tt>.
-     * @exception  ClassCastException  if this <code>Properties</code> object
-     *             contains any keys or values that are not <code>Strings</code>.
-     * @exception  NullPointerException  if <code>writer</code> is null.
+     * @exception  ClassCastException  if this {@code Properties} object
+     *             contains any keys or values that are not {@code Strings}.
+     * @exception  NullPointerException  if {@code writer} is null.
      * @since 1.6
      */
     public void store(Writer writer, String comments)
@@ -771,11 +777,11 @@
 
     /**
      * Writes this property list (key and element pairs) in this
-     * <code>Properties</code> table to the output stream in a format suitable
-     * for loading into a <code>Properties</code> table using the
+     * {@code Properties} table to the output stream in a format suitable
+     * for loading into a {@code Properties} table using the
      * {@link #load(InputStream) load(InputStream)} method.
      * <p>
-     * Properties from the defaults table of this <code>Properties</code>
+     * Properties from the defaults table of this {@code Properties}
      * table (if any) are <i>not</i> written out by this method.
      * <p>
      * This method outputs the comments, properties keys and values in
@@ -786,12 +792,12 @@
      * <li>The stream is written using the ISO 8859-1 character encoding.
      *
      * <li>Characters not in Latin-1 in the comments are written as
-     * <code>&#92;u</code><i>xxxx</i> for their appropriate unicode
+     * {@code \u005Cu}<i>xxxx</i> for their appropriate unicode
      * hexadecimal value <i>xxxx</i>.
      *
-     * <li>Characters less than <code>&#92;u0020</code> and characters greater
-     * than <code>&#92;u007E</code> in property keys or values are written
-     * as <code>&#92;u</code><i>xxxx</i> for the appropriate hexadecimal
+     * <li>Characters less than {@code \u005Cu0020} and characters greater
+     * than {@code \u005Cu007E} in property keys or values are written
+     * as {@code \u005Cu}<i>xxxx</i> for the appropriate hexadecimal
      * value <i>xxxx</i>.
      * </ul>
      * <p>
@@ -802,9 +808,9 @@
      * @param   comments   a description of the property list.
      * @exception  IOException if writing this property list to the specified
      *             output stream throws an <tt>IOException</tt>.
-     * @exception  ClassCastException  if this <code>Properties</code> object
-     *             contains any keys or values that are not <code>Strings</code>.
-     * @exception  NullPointerException  if <code>out</code> is null.
+     * @exception  ClassCastException  if this {@code Properties} object
+     *             contains any keys or values that are not {@code Strings}.
+     * @exception  NullPointerException  if {@code out} is null.
      * @since 1.2
      */
     public void store(OutputStream out, String comments)
@@ -824,7 +830,7 @@
         bw.write("#" + new Date().toString());
         bw.newLine();
         synchronized (this) {
-            for (Enumeration e = keys(); e.hasMoreElements();) {
+            for (Enumeration<?> e = keys(); e.hasMoreElements();) {
                 String key = (String)e.nextElement();
                 String val = (String)get(key);
                 key = saveConvert(key, true, escUnicode);
@@ -850,23 +856,36 @@
      * Furthermore, the document must satisfy the properties DTD described
      * above.
      *
+     * <p> An implementation is required to read XML documents that use the
+     * "{@code UTF-8}" or "{@code UTF-16}" encoding. An implementation may
+     * support additional encodings.
+     *
      * <p>The specified stream is closed after this method returns.
      *
      * @param in the input stream from which to read the XML document.
      * @throws IOException if reading from the specified input stream
      *         results in an <tt>IOException</tt>.
+     * @throws java.io.UnsupportedEncodingException if the document's encoding
+     *         declaration can be read and it specifies an encoding that is not
+     *         supported
      * @throws InvalidPropertiesFormatException Data on input stream does not
      *         constitute a valid XML document with the mandated document type.
-     * @throws NullPointerException if <code>in</code> is null.
+     * @throws NullPointerException if {@code in} is null.
      * @see    #storeToXML(OutputStream, String, String)
+     * @see    <a href="http://www.w3.org/TR/REC-xml/#charencoding">Character
+     *         Encoding in Entities</a>
      * @since 1.5
      */
     public synchronized void loadFromXML(InputStream in)
         throws IOException, InvalidPropertiesFormatException
     {
-        if (in == null)
-            throw new NullPointerException();
-        XMLUtils.load(this, in);
+        // Android-changed: Keep OpenJDK7u40's XmlUtils.
+        // XmlSupport's system property based XmlPropertiesProvider
+        // selection does not make sense on Android and has too many
+        // dependencies on classes that are not available on Android.
+        //
+        // XmlSupport.load(this, Objects.requireNonNull(in));
+        XMLUtils.load(this, Objects.requireNonNull(in));
         in.close();
     }
 
@@ -879,22 +898,20 @@
      * <tt>props.storeToXML(os, comment, "UTF-8");</tt>.
      *
      * @param os the output stream on which to emit the XML document.
-     * @param comment a description of the property list, or <code>null</code>
+     * @param comment a description of the property list, or {@code null}
      *        if no comment is desired.
      * @throws IOException if writing to the specified output stream
      *         results in an <tt>IOException</tt>.
-     * @throws NullPointerException if <code>os</code> is null.
-     * @throws ClassCastException  if this <code>Properties</code> object
+     * @throws NullPointerException if {@code os} is null.
+     * @throws ClassCastException  if this {@code Properties} object
      *         contains any keys or values that are not
-     *         <code>Strings</code>.
+     *         {@code Strings}.
      * @see    #loadFromXML(InputStream)
      * @since 1.5
      */
     public void storeToXML(OutputStream os, String comment)
         throws IOException
     {
-        if (os == null)
-            throw new NullPointerException();
         storeToXML(os, comment, "UTF-8");
     }
 
@@ -907,13 +924,17 @@
      * &lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;
      * </pre>
      *
-     *<p>If the specified comment is <code>null</code> then no comment
+     * <p>If the specified comment is {@code null} then no comment
      * will be stored in the document.
      *
+     * <p> An implementation is required to support writing of XML documents
+     * that use the "{@code UTF-8}" or "{@code UTF-16}" encoding. An
+     * implementation may support additional encodings.
+     *
      * <p>The specified stream remains open after this method returns.
      *
      * @param os        the output stream on which to emit the XML document.
-     * @param comment   a description of the property list, or <code>null</code>
+     * @param comment   a description of the property list, or {@code null}
      *                  if no comment is desired.
      * @param  encoding the name of a supported
      *                  <a href="../lang/package-summary.html#charenc">
@@ -921,27 +942,37 @@
      *
      * @throws IOException if writing to the specified output stream
      *         results in an <tt>IOException</tt>.
-     * @throws NullPointerException if <code>os</code> is <code>null</code>,
-     *         or if <code>encoding</code> is <code>null</code>.
-     * @throws ClassCastException  if this <code>Properties</code> object
+     * @throws java.io.UnsupportedEncodingException if the encoding is not
+     *         supported by the implementation.
+     * @throws NullPointerException if {@code os} is {@code null},
+     *         or if {@code encoding} is {@code null}.
+     * @throws ClassCastException  if this {@code Properties} object
      *         contains any keys or values that are not
-     *         <code>Strings</code>.
+     *         {@code Strings}.
      * @see    #loadFromXML(InputStream)
+     * @see    <a href="http://www.w3.org/TR/REC-xml/#charencoding">Character
+     *         Encoding in Entities</a>
      * @since 1.5
      */
     public void storeToXML(OutputStream os, String comment, String encoding)
         throws IOException
     {
-        if (os == null)
-            throw new NullPointerException();
-        XMLUtils.save(this, os, comment, encoding);
+        // Android-changed: Keep OpenJDK7u40's XmlUtils.
+        // XmlSupport's system property based XmlPropertiesProvider
+        // selection does not make sense on Android and has too many
+        // dependencies on classes that are not available on Android.
+        //
+        // XmlSupport.save(this, Objects.requireNonNull(os), comment,
+        //                Objects.requireNonNull(encoding));
+        XMLUtils.save(this, Objects.requireNonNull(os), comment,
+                       Objects.requireNonNull(encoding));
     }
 
     /**
      * Searches for the property with the specified key in this property list.
      * If the key is not found in this property list, the default property list,
      * and its defaults, recursively, are then checked. The method returns
-     * <code>null</code> if the property is not found.
+     * {@code null} if the property is not found.
      *
      * @param   key   the property key.
      * @return  the value in this property list with the specified key value.
@@ -987,7 +1018,7 @@
      * @see     #stringPropertyNames
      */
     public Enumeration<?> propertyNames() {
-        Hashtable h = new Hashtable();
+        Hashtable<String,Object> h = new Hashtable<>();
         enumerate(h);
         return h.keys();
     }
@@ -1026,10 +1057,10 @@
      */
     public void list(PrintStream out) {
         out.println("-- listing properties --");
-        Hashtable h = new Hashtable();
+        Hashtable<String,Object> h = new Hashtable<>();
         enumerate(h);
-        for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
-            String key = (String)e.nextElement();
+        for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
+            String key = e.nextElement();
             String val = (String)h.get(key);
             if (val.length() > 40) {
                 val = val.substring(0, 37) + "...";
@@ -1054,10 +1085,10 @@
      */
     public void list(PrintWriter out) {
         out.println("-- listing properties --");
-        Hashtable h = new Hashtable();
+        Hashtable<String,Object> h = new Hashtable<>();
         enumerate(h);
-        for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
-            String key = (String)e.nextElement();
+        for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
+            String key = e.nextElement();
             String val = (String)h.get(key);
             if (val.length() > 40) {
                 val = val.substring(0, 37) + "...";
@@ -1072,11 +1103,11 @@
      * @throws ClassCastException if any of the property keys
      *         is not of String type.
      */
-    private synchronized void enumerate(Hashtable h) {
+    private synchronized void enumerate(Hashtable<String,Object> h) {
         if (defaults != null) {
             defaults.enumerate(h);
         }
-        for (Enumeration e = keys() ; e.hasMoreElements() ;) {
+        for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
             String key = (String)e.nextElement();
             h.put(key, get(key));
         }
@@ -1091,7 +1122,7 @@
         if (defaults != null) {
             defaults.enumerateStringProperties(h);
         }
-        for (Enumeration e = keys() ; e.hasMoreElements() ;) {
+        for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
             Object k = e.nextElement();
             Object v = get(k);
             if (k instanceof String && v instanceof String) {
diff --git a/ojluni/src/main/java/java/util/Random.java b/ojluni/src/main/java/java/util/Random.java
index fb4ecfd..1061b59 100644
--- a/ojluni/src/main/java/java/util/Random.java
+++ b/ojluni/src/main/java/java/util/Random.java
@@ -312,9 +312,8 @@
      * Returns the next pseudorandom, uniformly distributed {@code int}
      * value from this random number generator's sequence. The general
      * contract of {@code nextInt} is that one {@code int} value is
-     * pseudorandomly generated and returned. All 2<font size="-1"><sup>32
-     * </sup></font> possible {@code int} values are produced with
-     * (approximately) equal probability.
+     * pseudorandomly generated and returned. All 2<sup>32</sup> possible
+     * {@code int} values are produced with (approximately) equal probability.
      *
      * <p>The method {@code nextInt} is implemented by class {@code Random}
      * as if by:
@@ -335,23 +334,23 @@
      * between 0 (inclusive) and the specified value (exclusive), drawn from
      * this random number generator's sequence.  The general contract of
      * {@code nextInt} is that one {@code int} value in the specified range
-     * is pseudorandomly generated and returned.  All {@code n} possible
+     * is pseudorandomly generated and returned.  All {@code bound} possible
      * {@code int} values are produced with (approximately) equal
-     * probability.  The method {@code nextInt(int n)} is implemented by
+     * probability.  The method {@code nextInt(int bound)} is implemented by
      * class {@code Random} as if by:
      *  <pre> {@code
-     * public int nextInt(int n) {
-     *   if (n <= 0)
-     *     throw new IllegalArgumentException("n must be positive");
+     * public int nextInt(int bound) {
+     *   if (bound <= 0)
+     *     throw new IllegalArgumentException("bound must be positive");
      *
-     *   if ((n & -n) == n)  // i.e., n is a power of 2
-     *     return (int)((n * (long)next(31)) >> 31);
+     *   if ((bound & -bound) == bound)  // i.e., bound is a power of 2
+     *     return (int)((bound * (long)next(31)) >> 31);
      *
      *   int bits, val;
      *   do {
      *       bits = next(31);
-     *       val = bits % n;
-     *   } while (bits - val + (n-1) < 0);
+     *       val = bits % bound;
+     *   } while (bits - val + (bound-1) < 0);
      *   return val;
      * }}</pre>
      *
@@ -377,28 +376,28 @@
      * greatly increases the length of the sequence of values returned by
      * successive calls to this method if n is a small power of two.
      *
-     * @param n the bound on the random number to be returned.  Must be
-     *        positive.
+     * @param bound the upper bound (exclusive).  Must be positive.
      * @return the next pseudorandom, uniformly distributed {@code int}
-     *         value between {@code 0} (inclusive) and {@code n} (exclusive)
+     *         value between zero (inclusive) and {@code bound} (exclusive)
      *         from this random number generator's sequence
-     * @throws IllegalArgumentException if n is not positive
+     * @throws IllegalArgumentException if bound is not positive
      * @since 1.2
      */
+    public int nextInt(int bound) {
+        if (bound <= 0)
+            throw new IllegalArgumentException(BadBound);
 
-    public int nextInt(int n) {
-        if (n <= 0)
-            throw new IllegalArgumentException("n must be positive");
-
-        if ((n & -n) == n)  // i.e., n is a power of 2
-            return (int)((n * (long)next(31)) >> 31);
-
-        int bits, val;
-        do {
-            bits = next(31);
-            val = bits % n;
-        } while (bits - val + (n-1) < 0);
-        return val;
+        int r = next(31);
+        int m = bound - 1;
+        if ((bound & m) == 0)  // i.e., bound is a power of 2
+            r = (int)((bound * (long)r) >> 31);
+        else {
+            for (int u = r;
+                 u - (r = u % bound) + m < 0;
+                 u = next(31))
+                ;
+        }
+        return r;
     }
 
     /**
@@ -457,11 +456,9 @@
      * <p>The general contract of {@code nextFloat} is that one
      * {@code float} value, chosen (approximately) uniformly from the
      * range {@code 0.0f} (inclusive) to {@code 1.0f} (exclusive), is
-     * pseudorandomly generated and returned. All 2<font
-     * size="-1"><sup>24</sup></font> possible {@code float} values
-     * of the form <i>m&nbsp;x&nbsp</i>2<font
-     * size="-1"><sup>-24</sup></font>, where <i>m</i> is a positive
-     * integer less than 2<font size="-1"><sup>24</sup> </font>, are
+     * pseudorandomly generated and returned. All 2<sup>24</sup> possible
+     * {@code float} values of the form <i>m&nbsp;x&nbsp;</i>2<sup>-24</sup>,
+     * where <i>m</i> is a positive integer less than 2<sup>24</sup>, are
      * produced with (approximately) equal probability.
      *
      * <p>The method {@code nextFloat} is implemented by class {@code Random}
@@ -532,8 +529,7 @@
      * @see Math#random
      */
     public double nextDouble() {
-        return (((long)(next(26)) << 27) + next(27))
-            / (double)(1L << 53);
+        return (((long)(next(26)) << 27) + next(27)) * DOUBLE_UNIT;
     }
 
     private double nextNextGaussian;
diff --git a/ojluni/src/main/java/javax/net/ssl/SSLContext.java b/ojluni/src/main/java/javax/net/ssl/SSLContext.java
index 7e615b8..fa8a3af 100644
--- a/ojluni/src/main/java/javax/net/ssl/SSLContext.java
+++ b/ojluni/src/main/java/javax/net/ssl/SSLContext.java
@@ -50,13 +50,13 @@
  *             <td>Default</td>
  *             <td>10+</td>
  *         </tr>
- *         <tr>
+ *         <tr class="deprecated">
  *             <td>SSL</td>
- *             <td>10+</td>
+ *             <td>10&ndash;TBD</td>
  *         </tr>
- *         <tr>
+ *         <tr class="deprecated">
  *             <td>SSLv3</td>
- *             <td>10+</td>
+ *             <td>10&ndash;TBD</td>
  *         </tr>
  *         <tr>
  *             <td>TLS</td>
diff --git a/ojluni/src/main/java/javax/net/ssl/SSLEngine.java b/ojluni/src/main/java/javax/net/ssl/SSLEngine.java
index 47783a0..c4b3df0 100644
--- a/ojluni/src/main/java/javax/net/ssl/SSLEngine.java
+++ b/ojluni/src/main/java/javax/net/ssl/SSLEngine.java
@@ -380,9 +380,9 @@
  *         </tr>
  *     </thead>
  *     <tbody>
- *         <tr>
+ *         <tr class="deprecated">
  *             <td>SSLv3</td>
- *             <td>1+</td>
+ *             <td>1&ndash;TBD</td>
  *             <td>1&ndash;22</td>
  *         </tr>
  *         <tr>
diff --git a/ojluni/src/main/java/javax/net/ssl/SSLSocket.java b/ojluni/src/main/java/javax/net/ssl/SSLSocket.java
index 4dd8b9e..093f2d9 100644
--- a/ojluni/src/main/java/javax/net/ssl/SSLSocket.java
+++ b/ojluni/src/main/java/javax/net/ssl/SSLSocket.java
@@ -155,9 +155,9 @@
  *         </tr>
  *     </thead>
  *     <tbody>
- *         <tr>
+ *         <tr class="deprecated">
  *             <td>SSLv3</td>
- *             <td>1+</td>
+ *             <td>1&ndash;TBD</td>
  *             <td>1&ndash;22</td>
  *         </tr>
  *         <tr>
@@ -188,9 +188,9 @@
  *         </tr>
  *     </thead>
  *     <tbody>
- *         <tr>
+ *         <tr class="deprecated">
  *             <td>SSLv3</td>
- *             <td>1+</td>
+ *             <td>1&ndash;TBD</td>
  *             <td>1&ndash;22</td>
  *         </tr>
  *         <tr>
diff --git a/ojluni/src/main/java/javax/security/auth/Subject.java b/ojluni/src/main/java/javax/security/auth/Subject.java
index 56e864c..2c9e8b8 100644
--- a/ojluni/src/main/java/javax/security/auth/Subject.java
+++ b/ojluni/src/main/java/javax/security/auth/Subject.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,39 +42,39 @@
 import sun.security.util.ResourcesMgr;
 
 /**
- * <p> A <code>Subject</code> represents a grouping of related information
+ * <p> A {@code Subject} represents a grouping of related information
  * for a single entity, such as a person.
  * Such information includes the Subject's identities as well as
  * its security-related attributes
  * (passwords and cryptographic keys, for example).
  *
  * <p> Subjects may potentially have multiple identities.
- * Each identity is represented as a <code>Principal</code>
- * within the <code>Subject</code>.  Principals simply bind names to a
- * <code>Subject</code>.  For example, a <code>Subject</code> that happens
+ * Each identity is represented as a {@code Principal}
+ * within the {@code Subject}.  Principals simply bind names to a
+ * {@code Subject}.  For example, a {@code Subject} that happens
  * to be a person, Alice, might have two Principals:
  * one which binds "Alice Bar", the name on her driver license,
- * to the <code>Subject</code>, and another which binds,
+ * to the {@code Subject}, and another which binds,
  * "999-99-9999", the number on her student identification card,
- * to the <code>Subject</code>.  Both Principals refer to the same
- * <code>Subject</code> even though each has a different name.
+ * to the {@code Subject}.  Both Principals refer to the same
+ * {@code Subject} even though each has a different name.
  *
- * <p> A <code>Subject</code> may also own security-related attributes,
+ * <p> A {@code Subject} may also own security-related attributes,
  * which are referred to as credentials.
  * Sensitive credentials that require special protection, such as
  * private cryptographic keys, are stored within a private credential
- * <code>Set</code>.  Credentials intended to be shared, such as
+ * {@code Set}.  Credentials intended to be shared, such as
  * public key certificates or Kerberos server tickets are stored
- * within a public credential <code>Set</code>.  Different permissions
+ * within a public credential {@code Set}.  Different permissions
  * are required to access and modify the different credential Sets.
  *
- * <p> To retrieve all the Principals associated with a <code>Subject</code>,
- * invoke the <code>getPrincipals</code> method.  To retrieve
- * all the public or private credentials belonging to a <code>Subject</code>,
- * invoke the <code>getPublicCredentials</code> method or
- * <code>getPrivateCredentials</code> method, respectively.
- * To modify the returned <code>Set</code> of Principals and credentials,
- * use the methods defined in the <code>Set</code> class.
+ * <p> To retrieve all the Principals associated with a {@code Subject},
+ * invoke the {@code getPrincipals} method.  To retrieve
+ * all the public or private credentials belonging to a {@code Subject},
+ * invoke the {@code getPublicCredentials} method or
+ * {@code getPrivateCredentials} method, respectively.
+ * To modify the returned {@code Set} of Principals and credentials,
+ * use the methods defined in the {@code Set} class.
  * For example:
  * <pre>
  *      Subject subject;
@@ -86,13 +86,13 @@
  *      subject.getPublicCredentials().add(credential);
  * </pre>
  *
- * <p> This <code>Subject</code> class implements <code>Serializable</code>.
- * While the Principals associated with the <code>Subject</code> are serialized,
- * the credentials associated with the <code>Subject</code> are not.
- * Note that the <code>java.security.Principal</code> class
- * does not implement <code>Serializable</code>.  Therefore all concrete
- * <code>Principal</code> implementations associated with Subjects
- * must implement <code>Serializable</code>.
+ * <p> This {@code Subject} class implements {@code Serializable}.
+ * While the Principals associated with the {@code Subject} are serialized,
+ * the credentials associated with the {@code Subject} are not.
+ * Note that the {@code java.security.Principal} class
+ * does not implement {@code Serializable}.  Therefore all concrete
+ * {@code Principal} implementations associated with Subjects
+ * must implement {@code Serializable}.
  *
  * @see java.security.Principal
  * @see java.security.DomainCombiner
@@ -102,14 +102,14 @@
     private static final long serialVersionUID = -8308522755600156056L;
 
     /**
-     * A <code>Set</code> that provides a view of all of this
+     * A {@code Set} that provides a view of all of this
      * Subject's Principals
      *
      * <p>
      *
      * @serial Each element in this set is a
-     *          <code>java.security.Principal</code>.
-     *          The set is a <code>Subject.SecureSet</code>.
+     *          {@code java.security.Principal}.
+     *          The set is a {@code Subject.SecureSet}.
      */
     Set<Principal> principals;
 
@@ -135,21 +135,21 @@
         = new ProtectionDomain[0];
 
     /**
-     * Create an instance of a <code>Subject</code>
-     * with an empty <code>Set</code> of Principals and empty
+     * Create an instance of a {@code Subject}
+     * with an empty {@code Set} of Principals and empty
      * Sets of public and private credentials.
      *
-     * <p> The newly constructed Sets check whether this <code>Subject</code>
+     * <p> The newly constructed Sets check whether this {@code Subject}
      * has been set read-only before permitting subsequent modifications.
      * The newly created Sets also prevent illegal modifications
      * by ensuring that callers have sufficient permissions.
      *
      * <p> To modify the Principals Set, the caller must have
-     * <code>AuthPermission("modifyPrincipals")</code>.
+     * {@code AuthPermission("modifyPrincipals")}.
      * To modify the public credential Set, the caller must have
-     * <code>AuthPermission("modifyPublicCredentials")</code>.
+     * {@code AuthPermission("modifyPublicCredentials")}.
      * To modify the private credential Set, the caller must have
-     * <code>AuthPermission("modifyPrivateCredentials")</code>.
+     * {@code AuthPermission("modifyPrivateCredentials")}.
      */
     public Subject() {
 
@@ -162,39 +162,39 @@
     }
 
     /**
-     * Create an instance of a <code>Subject</code> with
+     * Create an instance of a {@code Subject} with
      * Principals and credentials.
      *
      * <p> The Principals and credentials from the specified Sets
      * are copied into newly constructed Sets.
-     * These newly created Sets check whether this <code>Subject</code>
+     * These newly created Sets check whether this {@code Subject}
      * has been set read-only before permitting subsequent modifications.
      * The newly created Sets also prevent illegal modifications
      * by ensuring that callers have sufficient permissions.
      *
      * <p> To modify the Principals Set, the caller must have
-     * <code>AuthPermission("modifyPrincipals")</code>.
+     * {@code AuthPermission("modifyPrincipals")}.
      * To modify the public credential Set, the caller must have
-     * <code>AuthPermission("modifyPublicCredentials")</code>.
+     * {@code AuthPermission("modifyPublicCredentials")}.
      * To modify the private credential Set, the caller must have
-     * <code>AuthPermission("modifyPrivateCredentials")</code>.
+     * {@code AuthPermission("modifyPrivateCredentials")}.
      * <p>
      *
-     * @param readOnly true if the <code>Subject</code> is to be read-only,
+     * @param readOnly true if the {@code Subject} is to be read-only,
      *          and false otherwise. <p>
      *
-     * @param principals the <code>Set</code> of Principals
-     *          to be associated with this <code>Subject</code>. <p>
+     * @param principals the {@code Set} of Principals
+     *          to be associated with this {@code Subject}. <p>
      *
-     * @param pubCredentials the <code>Set</code> of public credentials
-     *          to be associated with this <code>Subject</code>. <p>
+     * @param pubCredentials the {@code Set} of public credentials
+     *          to be associated with this {@code Subject}. <p>
      *
-     * @param privCredentials the <code>Set</code> of private credentials
-     *          to be associated with this <code>Subject</code>.
+     * @param privCredentials the {@code Set} of private credentials
+     *          to be associated with this {@code Subject}.
      *
      * @exception NullPointerException if the specified
-     *          <code>principals</code>, <code>pubCredentials</code>,
-     *          or <code>privCredentials</code> are <code>null</code>.
+     *          {@code principals}, {@code pubCredentials},
+     *          or {@code privCredentials} are {@code null}.
      */
     public Subject(boolean readOnly, Set<? extends Principal> principals,
                    Set<?> pubCredentials, Set<?> privCredentials)
@@ -216,24 +216,24 @@
     }
 
     /**
-     * Set this <code>Subject</code> to be read-only.
+     * Set this {@code Subject} to be read-only.
      *
      * <p> Modifications (additions and removals) to this Subject's
-     * <code>Principal</code> <code>Set</code> and
+     * {@code Principal} {@code Set} and
      * credential Sets will be disallowed.
-     * The <code>destroy</code> operation on this Subject's credentials will
+     * The {@code destroy} operation on this Subject's credentials will
      * still be permitted.
      *
-     * <p> Subsequent attempts to modify the Subject's <code>Principal</code>
+     * <p> Subsequent attempts to modify the Subject's {@code Principal}
      * and credential Sets will result in an
-     * <code>IllegalStateException</code> being thrown.
-     * Also, once a <code>Subject</code> is read-only,
+     * {@code IllegalStateException} being thrown.
+     * Also, once a {@code Subject} is read-only,
      * it can not be reset to being writable again.
      *
      * <p>
      *
      * @exception SecurityException if the caller does not have permission
-     *          to set this <code>Subject</code> to be read-only.
+     *          to set this {@code Subject} to be read-only.
      */
     public void setReadOnly() {
         java.lang.SecurityManager sm = System.getSecurityManager();
@@ -245,40 +245,40 @@
     }
 
     /**
-     * Query whether this <code>Subject</code> is read-only.
+     * Query whether this {@code Subject} is read-only.
      *
      * <p>
      *
-     * @return true if this <code>Subject</code> is read-only, false otherwise.
+     * @return true if this {@code Subject} is read-only, false otherwise.
      */
     public boolean isReadOnly() {
         return this.readOnly;
     }
 
     /**
-     * Get the <code>Subject</code> associated with the provided
-     * <code>AccessControlContext</code>.
+     * Get the {@code Subject} associated with the provided
+     * {@code AccessControlContext}.
      *
-     * <p> The <code>AccessControlContext</code> may contain many
-     * Subjects (from nested <code>doAs</code> calls).
-     * In this situation, the most recent <code>Subject</code> associated
-     * with the <code>AccessControlContext</code> is returned.
+     * <p> The {@code AccessControlContext} may contain many
+     * Subjects (from nested {@code doAs} calls).
+     * In this situation, the most recent {@code Subject} associated
+     * with the {@code AccessControlContext} is returned.
      *
      * <p>
      *
-     * @param  acc the <code>AccessControlContext</code> from which to retrieve
-     *          the <code>Subject</code>.
+     * @param  acc the {@code AccessControlContext} from which to retrieve
+     *          the {@code Subject}.
      *
-     * @return  the <code>Subject</code> associated with the provided
-     *          <code>AccessControlContext</code>, or <code>null</code>
-     *          if no <code>Subject</code> is associated
-     *          with the provided <code>AccessControlContext</code>.
+     * @return  the {@code Subject} associated with the provided
+     *          {@code AccessControlContext}, or {@code null}
+     *          if no {@code Subject} is associated
+     *          with the provided {@code AccessControlContext}.
      *
      * @exception SecurityException if the caller does not have permission
-     *          to get the <code>Subject</code>. <p>
+     *          to get the {@code Subject}. <p>
      *
      * @exception NullPointerException if the provided
-     *          <code>AccessControlContext</code> is <code>null</code>.
+     *          {@code AccessControlContext} is {@code null}.
      */
     public static Subject getSubject(final AccessControlContext acc) {
 
@@ -306,33 +306,36 @@
     }
 
     /**
-     * Perform work as a particular <code>Subject</code>.
+     * Perform work as a particular {@code Subject}.
      *
      * <p> This method first retrieves the current Thread's
-     * <code>AccessControlContext</code> via
-     * <code>AccessController.getContext</code>,
-     * and then instantiates a new <code>AccessControlContext</code>
+     * {@code AccessControlContext} via
+     * {@code AccessController.getContext},
+     * and then instantiates a new {@code AccessControlContext}
      * using the retrieved context along with a new
-     * <code>SubjectDomainCombiner</code> (constructed using
-     * the provided <code>Subject</code>).
-     * Finally, this method invokes <code>AccessController.doPrivileged</code>,
-     * passing it the provided <code>PrivilegedAction</code>,
-     * as well as the newly constructed <code>AccessControlContext</code>.
+     * {@code SubjectDomainCombiner} (constructed using
+     * the provided {@code Subject}).
+     * Finally, this method invokes {@code AccessController.doPrivileged},
+     * passing it the provided {@code PrivilegedAction},
+     * as well as the newly constructed {@code AccessControlContext}.
      *
      * <p>
      *
-     * @param subject the <code>Subject</code> that the specified
-     *                  <code>action</code> will run as.  This parameter
-     *                  may be <code>null</code>. <p>
+     * @param subject the {@code Subject} that the specified
+     *                  {@code action} will run as.  This parameter
+     *                  may be {@code null}. <p>
+     *
+     * @param <T> the type of the value returned by the PrivilegedAction's
+     *                  {@code run} method.
      *
      * @param action the code to be run as the specified
-     *                  <code>Subject</code>. <p>
+     *                  {@code Subject}. <p>
      *
      * @return the value returned by the PrivilegedAction's
-     *                  <code>run</code> method.
+     *                  {@code run} method.
      *
-     * @exception NullPointerException if the <code>PrivilegedAction</code>
-     *                  is <code>null</code>. <p>
+     * @exception NullPointerException if the {@code PrivilegedAction}
+     *                  is {@code null}. <p>
      *
      * @exception SecurityException if the caller does not have permission
      *                  to invoke this method.
@@ -359,38 +362,41 @@
     }
 
     /**
-     * Perform work as a particular <code>Subject</code>.
+     * Perform work as a particular {@code Subject}.
      *
      * <p> This method first retrieves the current Thread's
-     * <code>AccessControlContext</code> via
-     * <code>AccessController.getContext</code>,
-     * and then instantiates a new <code>AccessControlContext</code>
+     * {@code AccessControlContext} via
+     * {@code AccessController.getContext},
+     * and then instantiates a new {@code AccessControlContext}
      * using the retrieved context along with a new
-     * <code>SubjectDomainCombiner</code> (constructed using
-     * the provided <code>Subject</code>).
-     * Finally, this method invokes <code>AccessController.doPrivileged</code>,
-     * passing it the provided <code>PrivilegedExceptionAction</code>,
-     * as well as the newly constructed <code>AccessControlContext</code>.
+     * {@code SubjectDomainCombiner} (constructed using
+     * the provided {@code Subject}).
+     * Finally, this method invokes {@code AccessController.doPrivileged},
+     * passing it the provided {@code PrivilegedExceptionAction},
+     * as well as the newly constructed {@code AccessControlContext}.
      *
      * <p>
      *
-     * @param subject the <code>Subject</code> that the specified
-     *                  <code>action</code> will run as.  This parameter
-     *                  may be <code>null</code>. <p>
+     * @param subject the {@code Subject} that the specified
+     *                  {@code action} will run as.  This parameter
+     *                  may be {@code null}. <p>
+     *
+     * @param <T> the type of the value returned by the
+     *                  PrivilegedExceptionAction's {@code run} method.
      *
      * @param action the code to be run as the specified
-     *                  <code>Subject</code>. <p>
+     *                  {@code Subject}. <p>
      *
      * @return the value returned by the
-     *                  PrivilegedExceptionAction's <code>run</code> method.
+     *                  PrivilegedExceptionAction's {@code run} method.
      *
      * @exception PrivilegedActionException if the
-     *                  <code>PrivilegedExceptionAction.run</code>
+     *                  {@code PrivilegedExceptionAction.run}
      *                  method throws a checked exception. <p>
      *
      * @exception NullPointerException if the specified
-     *                  <code>PrivilegedExceptionAction</code> is
-     *                  <code>null</code>. <p>
+     *                  {@code PrivilegedExceptionAction} is
+     *                  {@code null}. <p>
      *
      * @exception SecurityException if the caller does not have permission
      *                  to invoke this method.
@@ -418,33 +424,36 @@
     }
 
     /**
-     * Perform privileged work as a particular <code>Subject</code>.
+     * Perform privileged work as a particular {@code Subject}.
      *
-     * <p> This method behaves exactly as <code>Subject.doAs</code>,
+     * <p> This method behaves exactly as {@code Subject.doAs},
      * except that instead of retrieving the current Thread's
-     * <code>AccessControlContext</code>, it uses the provided
-     * <code>AccessControlContext</code>.  If the provided
-     * <code>AccessControlContext</code> is <code>null</code>,
-     * this method instantiates a new <code>AccessControlContext</code>
+     * {@code AccessControlContext}, it uses the provided
+     * {@code AccessControlContext}.  If the provided
+     * {@code AccessControlContext} is {@code null},
+     * this method instantiates a new {@code AccessControlContext}
      * with an empty collection of ProtectionDomains.
      *
      * <p>
      *
-     * @param subject the <code>Subject</code> that the specified
-     *                  <code>action</code> will run as.  This parameter
-     *                  may be <code>null</code>. <p>
+     * @param subject the {@code Subject} that the specified
+     *                  {@code action} will run as.  This parameter
+     *                  may be {@code null}. <p>
+     *
+     * @param <T> the type of the value returned by the PrivilegedAction's
+     *                  {@code run} method.
      *
      * @param action the code to be run as the specified
-     *                  <code>Subject</code>. <p>
+     *                  {@code Subject}. <p>
      *
-     * @param acc the <code>AccessControlContext</code> to be tied to the
+     * @param acc the {@code AccessControlContext} to be tied to the
      *                  specified <i>subject</i> and <i>action</i>. <p>
      *
      * @return the value returned by the PrivilegedAction's
-     *                  <code>run</code> method.
+     *                  {@code run} method.
      *
-     * @exception NullPointerException if the <code>PrivilegedAction</code>
-     *                  is <code>null</code>. <p>
+     * @exception NullPointerException if the {@code PrivilegedAction}
+     *                  is {@code null}. <p>
      *
      * @exception SecurityException if the caller does not have permission
      *                  to invoke this method.
@@ -476,38 +485,41 @@
     }
 
     /**
-     * Perform privileged work as a particular <code>Subject</code>.
+     * Perform privileged work as a particular {@code Subject}.
      *
-     * <p> This method behaves exactly as <code>Subject.doAs</code>,
+     * <p> This method behaves exactly as {@code Subject.doAs},
      * except that instead of retrieving the current Thread's
-     * <code>AccessControlContext</code>, it uses the provided
-     * <code>AccessControlContext</code>.  If the provided
-     * <code>AccessControlContext</code> is <code>null</code>,
-     * this method instantiates a new <code>AccessControlContext</code>
+     * {@code AccessControlContext}, it uses the provided
+     * {@code AccessControlContext}.  If the provided
+     * {@code AccessControlContext} is {@code null},
+     * this method instantiates a new {@code AccessControlContext}
      * with an empty collection of ProtectionDomains.
      *
      * <p>
      *
-     * @param subject the <code>Subject</code> that the specified
-     *                  <code>action</code> will run as.  This parameter
-     *                  may be <code>null</code>. <p>
+     * @param subject the {@code Subject} that the specified
+     *                  {@code action} will run as.  This parameter
+     *                  may be {@code null}. <p>
+     *
+     * @param <T> the type of the value returned by the
+     *                  PrivilegedExceptionAction's {@code run} method.
      *
      * @param action the code to be run as the specified
-     *                  <code>Subject</code>. <p>
+     *                  {@code Subject}. <p>
      *
-     * @param acc the <code>AccessControlContext</code> to be tied to the
+     * @param acc the {@code AccessControlContext} to be tied to the
      *                  specified <i>subject</i> and <i>action</i>. <p>
      *
      * @return the value returned by the
-     *                  PrivilegedExceptionAction's <code>run</code> method.
+     *                  PrivilegedExceptionAction's {@code run} method.
      *
      * @exception PrivilegedActionException if the
-     *                  <code>PrivilegedExceptionAction.run</code>
+     *                  {@code PrivilegedExceptionAction.run}
      *                  method throws a checked exception. <p>
      *
      * @exception NullPointerException if the specified
-     *                  <code>PrivilegedExceptionAction</code> is
-     *                  <code>null</code>. <p>
+     *                  {@code PrivilegedExceptionAction} is
+     *                  {@code null}. <p>
      *
      * @exception SecurityException if the caller does not have permission
      *                  to invoke this method.
@@ -556,19 +568,19 @@
     }
 
     /**
-     * Return the <code>Set</code> of Principals associated with this
-     * <code>Subject</code>.  Each <code>Principal</code> represents
-     * an identity for this <code>Subject</code>.
+     * Return the {@code Set} of Principals associated with this
+     * {@code Subject}.  Each {@code Principal} represents
+     * an identity for this {@code Subject}.
      *
-     * <p> The returned <code>Set</code> is backed by this Subject's
-     * internal <code>Principal</code> <code>Set</code>.  Any modification
-     * to the returned <code>Set</code> affects the internal
-     * <code>Principal</code> <code>Set</code> as well.
+     * <p> The returned {@code Set} is backed by this Subject's
+     * internal {@code Principal} {@code Set}.  Any modification
+     * to the returned {@code Set} affects the internal
+     * {@code Principal} {@code Set} as well.
      *
      * <p>
      *
-     * @return  The <code>Set</code> of Principals associated with this
-     *          <code>Subject</code>.
+     * @return  The {@code Set} of Principals associated with this
+     *          {@code Subject}.
      */
     public Set<Principal> getPrincipals() {
 
@@ -578,26 +590,28 @@
     }
 
     /**
-     * Return a <code>Set</code> of Principals associated with this
-     * <code>Subject</code> that are instances or subclasses of the specified
-     * <code>Class</code>.
+     * Return a {@code Set} of Principals associated with this
+     * {@code Subject} that are instances or subclasses of the specified
+     * {@code Class}.
      *
-     * <p> The returned <code>Set</code> is not backed by this Subject's
-     * internal <code>Principal</code> <code>Set</code>.  A new
-     * <code>Set</code> is created and returned for each method invocation.
-     * Modifications to the returned <code>Set</code>
-     * will not affect the internal <code>Principal</code> <code>Set</code>.
+     * <p> The returned {@code Set} is not backed by this Subject's
+     * internal {@code Principal} {@code Set}.  A new
+     * {@code Set} is created and returned for each method invocation.
+     * Modifications to the returned {@code Set}
+     * will not affect the internal {@code Principal} {@code Set}.
      *
      * <p>
      *
-     * @param c the returned <code>Set</code> of Principals will all be
+     * @param <T> the type of the class modeled by {@code c}
+     *
+     * @param c the returned {@code Set} of Principals will all be
      *          instances of this class.
      *
-     * @return a <code>Set</code> of Principals that are instances of the
-     *          specified <code>Class</code>.
+     * @return a {@code Set} of Principals that are instances of the
+     *          specified {@code Class}.
      *
-     * @exception NullPointerException if the specified <code>Class</code>
-     *                  is <code>null</code>.
+     * @exception NullPointerException if the specified {@code Class}
+     *                  is {@code null}.
      */
     public <T extends Principal> Set<T> getPrincipals(Class<T> c) {
 
@@ -611,18 +625,18 @@
     }
 
     /**
-     * Return the <code>Set</code> of public credentials held by this
-     * <code>Subject</code>.
+     * Return the {@code Set} of public credentials held by this
+     * {@code Subject}.
      *
-     * <p> The returned <code>Set</code> is backed by this Subject's
-     * internal public Credential <code>Set</code>.  Any modification
-     * to the returned <code>Set</code> affects the internal public
-     * Credential <code>Set</code> as well.
+     * <p> The returned {@code Set} is backed by this Subject's
+     * internal public Credential {@code Set}.  Any modification
+     * to the returned {@code Set} affects the internal public
+     * Credential {@code Set} as well.
      *
      * <p>
      *
-     * @return  A <code>Set</code> of public credentials held by this
-     *          <code>Subject</code>.
+     * @return  A {@code Set} of public credentials held by this
+     *          {@code Subject}.
      */
     public Set<Object> getPublicCredentials() {
 
@@ -632,29 +646,29 @@
     }
 
     /**
-     * Return the <code>Set</code> of private credentials held by this
-     * <code>Subject</code>.
+     * Return the {@code Set} of private credentials held by this
+     * {@code Subject}.
      *
-     * <p> The returned <code>Set</code> is backed by this Subject's
-     * internal private Credential <code>Set</code>.  Any modification
-     * to the returned <code>Set</code> affects the internal private
-     * Credential <code>Set</code> as well.
+     * <p> The returned {@code Set} is backed by this Subject's
+     * internal private Credential {@code Set}.  Any modification
+     * to the returned {@code Set} affects the internal private
+     * Credential {@code Set} as well.
      *
      * <p> A caller requires permissions to access the Credentials
-     * in the returned <code>Set</code>, or to modify the
-     * <code>Set</code> itself.  A <code>SecurityException</code>
+     * in the returned {@code Set}, or to modify the
+     * {@code Set} itself.  A {@code SecurityException}
      * is thrown if the caller does not have the proper permissions.
      *
-     * <p> While iterating through the <code>Set</code>,
-     * a <code>SecurityException</code> is thrown
+     * <p> While iterating through the {@code Set},
+     * a {@code SecurityException} is thrown
      * if the caller does not have permission to access a
-     * particular Credential.  The <code>Iterator</code>
-     * is nevertheless advanced to next element in the <code>Set</code>.
+     * particular Credential.  The {@code Iterator}
+     * is nevertheless advanced to next element in the {@code Set}.
      *
      * <p>
      *
-     * @return  A <code>Set</code> of private credentials held by this
-     *          <code>Subject</code>.
+     * @return  A {@code Set} of private credentials held by this
+     *          {@code Subject}.
      */
     public Set<Object> getPrivateCredentials() {
 
@@ -672,26 +686,28 @@
     }
 
     /**
-     * Return a <code>Set</code> of public credentials associated with this
-     * <code>Subject</code> that are instances or subclasses of the specified
-     * <code>Class</code>.
+     * Return a {@code Set} of public credentials associated with this
+     * {@code Subject} that are instances or subclasses of the specified
+     * {@code Class}.
      *
-     * <p> The returned <code>Set</code> is not backed by this Subject's
-     * internal public Credential <code>Set</code>.  A new
-     * <code>Set</code> is created and returned for each method invocation.
-     * Modifications to the returned <code>Set</code>
-     * will not affect the internal public Credential <code>Set</code>.
+     * <p> The returned {@code Set} is not backed by this Subject's
+     * internal public Credential {@code Set}.  A new
+     * {@code Set} is created and returned for each method invocation.
+     * Modifications to the returned {@code Set}
+     * will not affect the internal public Credential {@code Set}.
      *
      * <p>
      *
-     * @param c the returned <code>Set</code> of public credentials will all be
+     * @param <T> the type of the class modeled by {@code c}
+     *
+     * @param c the returned {@code Set} of public credentials will all be
      *          instances of this class.
      *
-     * @return a <code>Set</code> of public credentials that are instances
-     *          of the  specified <code>Class</code>.
+     * @return a {@code Set} of public credentials that are instances
+     *          of the  specified {@code Class}.
      *
-     * @exception NullPointerException if the specified <code>Class</code>
-     *          is <code>null</code>.
+     * @exception NullPointerException if the specified {@code Class}
+     *          is {@code null}.
      */
     public <T> Set<T> getPublicCredentials(Class<T> c) {
 
@@ -705,30 +721,32 @@
     }
 
     /**
-     * Return a <code>Set</code> of private credentials associated with this
-     * <code>Subject</code> that are instances or subclasses of the specified
-     * <code>Class</code>.
+     * Return a {@code Set} of private credentials associated with this
+     * {@code Subject} that are instances or subclasses of the specified
+     * {@code Class}.
      *
      * <p> The caller must have permission to access all of the
-     * requested Credentials, or a <code>SecurityException</code>
+     * requested Credentials, or a {@code SecurityException}
      * will be thrown.
      *
-     * <p> The returned <code>Set</code> is not backed by this Subject's
-     * internal private Credential <code>Set</code>.  A new
-     * <code>Set</code> is created and returned for each method invocation.
-     * Modifications to the returned <code>Set</code>
-     * will not affect the internal private Credential <code>Set</code>.
+     * <p> The returned {@code Set} is not backed by this Subject's
+     * internal private Credential {@code Set}.  A new
+     * {@code Set} is created and returned for each method invocation.
+     * Modifications to the returned {@code Set}
+     * will not affect the internal private Credential {@code Set}.
      *
      * <p>
      *
-     * @param c the returned <code>Set</code> of private credentials will all be
+     * @param <T> the type of the class modeled by {@code c}
+     *
+     * @param c the returned {@code Set} of private credentials will all be
      *          instances of this class.
      *
-     * @return a <code>Set</code> of private credentials that are instances
-     *          of the  specified <code>Class</code>.
+     * @return a {@code Set} of private credentials that are instances
+     *          of the  specified {@code Class}.
      *
-     * @exception NullPointerException if the specified <code>Class</code>
-     *          is <code>null</code>.
+     * @exception NullPointerException if the specified {@code Class}
+     *          is {@code null}.
      */
     public <T> Set<T> getPrivateCredentials(Class<T> c) {
 
@@ -750,25 +768,25 @@
     }
 
     /**
-     * Compares the specified Object with this <code>Subject</code>
+     * Compares the specified Object with this {@code Subject}
      * for equality.  Returns true if the given object is also a Subject
-     * and the two <code>Subject</code> instances are equivalent.
-     * More formally, two <code>Subject</code> instances are
-     * equal if their <code>Principal</code> and <code>Credential</code>
+     * and the two {@code Subject} instances are equivalent.
+     * More formally, two {@code Subject} instances are
+     * equal if their {@code Principal} and {@code Credential}
      * Sets are equal.
      *
      * <p>
      *
      * @param o Object to be compared for equality with this
-     *          <code>Subject</code>.
+     *          {@code Subject}.
      *
      * @return true if the specified Object is equal to this
-     *          <code>Subject</code>.
+     *          {@code Subject}.
      *
      * @exception SecurityException if the caller does not have permission
-     *          to access the private credentials for this <code>Subject</code>,
+     *          to access the private credentials for this {@code Subject},
      *          or if the caller does not have permission to access the
-     *          private credentials for the provided <code>Subject</code>.
+     *          private credentials for the provided {@code Subject}.
      */
     public boolean equals(Object o) {
 
@@ -815,11 +833,11 @@
     }
 
     /**
-     * Return the String representation of this <code>Subject</code>.
+     * Return the String representation of this {@code Subject}.
      *
      * <p>
      *
-     * @return the String representation of this <code>Subject</code>.
+     * @return the String representation of this {@code Subject}.
      */
     public String toString() {
         return toString(true);
@@ -876,11 +894,11 @@
     }
 
     /**
-     * Returns a hashcode for this <code>Subject</code>.
+     * Returns a hashcode for this {@code Subject}.
      *
      * <p>
      *
-     * @return a hashcode for this <code>Subject</code>.
+     * @return a hashcode for this {@code Subject}.
      *
      * @exception SecurityException if the caller does not have permission
      *          to access this Subject's private credentials.
@@ -892,10 +910,10 @@
          * hashcodes of this Subject's Principals and credentials.
          *
          * If a particular credential was destroyed
-         * (<code>credential.hashCode()</code> throws an
-         * <code>IllegalStateException</code>),
+         * ({@code credential.hashCode()} throws an
+         * {@code IllegalStateException}),
          * the hashcode for that credential is derived via:
-         * <code>credential.getClass().toString().hashCode()</code>.
+         * {@code credential.getClass().toString().hashCode()}.
          */
 
         int hashCode = 0;
@@ -941,12 +959,32 @@
     /**
      * Reads this object from a stream (i.e., deserializes it)
      */
+    @SuppressWarnings("unchecked")
     private void readObject(java.io.ObjectInputStream s)
                 throws java.io.IOException, ClassNotFoundException {
 
-        s.defaultReadObject();
+        ObjectInputStream.GetField gf = s.readFields();
 
-        // The Credential <code>Set</code> is not serialized, but we do not
+        readOnly = gf.get("readOnly", false);
+
+        Set<Principal> inputPrincs = (Set<Principal>)gf.get("principals", null);
+
+        // Rewrap the principals into a SecureSet
+        if (inputPrincs == null) {
+            throw new NullPointerException
+                (ResourcesMgr.getString("invalid.null.input.s."));
+        }
+        try {
+            principals = Collections.synchronizedSet(new SecureSet<Principal>
+                                (this, PRINCIPAL_SET, inputPrincs));
+        } catch (NullPointerException npe) {
+            // Sometimes people deserialize the principals set only.
+            // Subject is not accessible, so just don't fail.
+            principals = Collections.synchronizedSet
+                        (new SecureSet<Principal>(this, PRINCIPAL_SET));
+        }
+
+        // The Credential {@code Set} is not serialized, but we do not
         // want the default deserialization routine to set it to null.
         this.pubCredentials = Collections.synchronizedSet
                         (new SecureSet<Object>(this, PUB_CREDENTIAL_SET));
@@ -980,13 +1018,13 @@
 
         /**
          * @serial An integer identifying the type of objects contained
-         *      in this set.  If <code>which == 1</code>,
+         *      in this set.  If {@code which == 1},
          *      this is a Principal set and all the elements are
-         *      of type <code>java.security.Principal</code>.
-         *      If <code>which == 2</code>, this is a public credential
-         *      set and all the elements are of type <code>Object</code>.
-         *      If <code>which == 3</code>, this is a private credential
-         *      set and all the elements are of type <code>Object</code>.
+         *      of type {@code java.security.Principal}.
+         *      If {@code which == 2}, this is a public credential
+         *      set and all the elements are of type {@code Object}.
+         *      If {@code which == 3}, this is a private credential
+         *      set and all the elements are of type {@code Object}.
          */
         private int which;
 
@@ -1168,7 +1206,7 @@
         }
 
         public boolean removeAll(Collection<?> c) {
-
+            Objects.requireNonNull(c);
             boolean modified = false;
             final Iterator<E> e = iterator();
             while (e.hasNext()) {
@@ -1204,7 +1242,7 @@
         }
 
         public boolean retainAll(Collection<?> c) {
-
+            Objects.requireNonNull(c);
             boolean modified = false;
             boolean retain = false;
             final Iterator<E> e = iterator();
@@ -1291,18 +1329,25 @@
             oos.writeFields();
         }
 
+        @SuppressWarnings("unchecked")
         private void readObject(ObjectInputStream ois)
             throws IOException, ClassNotFoundException
         {
             ObjectInputStream.GetField fields = ois.readFields();
             subject = (Subject) fields.get("this$0", null);
-            elements = (LinkedList<E>) fields.get("elements", null);
             which = fields.get("which", 0);
+
+            LinkedList<E> tmp = (LinkedList<E>) fields.get("elements", null);
+            if (tmp.getClass() != LinkedList.class) {
+                elements = new LinkedList<E>(tmp);
+            } else {
+                elements = tmp;
+            }
         }
     }
 
     /**
-     * This class implements a <code>Set</code> which returns only
+     * This class implements a {@code Set} which returns only
      * members that are an instance of a specified Class.
      */
     private class ClassSet<T> extends AbstractSet<T> {
@@ -1329,6 +1374,7 @@
             }
         }
 
+        @SuppressWarnings("unchecked")     /*To suppress warning from line 1374*/
         private void populateSet() {
             final Iterator<?> iterator;
             switch(which) {
diff --git a/ojluni/src/main/java/sun/invoke/util/VerifyAccess.java b/ojluni/src/main/java/sun/invoke/util/VerifyAccess.java
new file mode 100644
index 0000000..d2e5820
--- /dev/null
+++ b/ojluni/src/main/java/sun/invoke/util/VerifyAccess.java
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.invoke.util;
+
+import java.lang.reflect.Modifier;
+import static java.lang.reflect.Modifier.*;
+import sun.reflect.Reflection;
+
+/**
+ * This class centralizes information about the JVM's linkage access control.
+ * @author jrose
+ */
+public class VerifyAccess {
+
+    private VerifyAccess() { }  // cannot instantiate
+
+    private static final int PACKAGE_ONLY = 0;
+    private static final int PACKAGE_ALLOWED = java.lang.invoke.MethodHandles.Lookup.PACKAGE;
+    private static final int PROTECTED_OR_PACKAGE_ALLOWED = (PACKAGE_ALLOWED|PROTECTED);
+    private static final int ALL_ACCESS_MODES = (PUBLIC|PRIVATE|PROTECTED|PACKAGE_ONLY);
+    private static final boolean ALLOW_NESTMATE_ACCESS = false;
+
+    /**
+     * Evaluate the JVM linkage rules for access to the given method
+     * on behalf of a caller class which proposes to perform the access.
+     * Return true if the caller class has privileges to invoke a method
+     * or access a field with the given properties.
+     * This requires an accessibility check of the referencing class,
+     * plus an accessibility check of the member within the class,
+     * which depends on the member's modifier flags.
+     * <p>
+     * The relevant properties include the defining class ({@code defc})
+     * of the member, and its modifier flags ({@code mods}).
+     * Also relevant is the class used to make the initial symbolic reference
+     * to the member ({@code refc}).  If this latter class is not distinguished,
+     * the defining class should be passed for both arguments ({@code defc == refc}).
+     * <h3>JVM Specification, 5.4.4 "Access Control"</h3>
+     * A field or method R is accessible to a class or interface D if
+     * and only if any of the following conditions is true:<ul>
+     * <li>R is public.
+     * <li>R is protected and is declared in a class C, and D is either
+     *     a subclass of C or C itself.  Furthermore, if R is not
+     *     static, then the symbolic reference to R must contain a
+     *     symbolic reference to a class T, such that T is either a
+     *     subclass of D, a superclass of D or D itself.
+     * <li>R is either protected or has default access (that is,
+     *     neither public nor protected nor private), and is declared
+     *     by a class in the same runtime package as D.
+     * <li>R is private and is declared in D.
+     * </ul>
+     * This discussion of access control omits a related restriction
+     * on the target of a protected field access or method invocation
+     * (the target must be of class D or a subtype of D). That
+     * requirement is checked as part of the verification process
+     * (5.4.1); it is not part of link-time access control.
+     * @param refc the class used in the symbolic reference to the proposed member
+     * @param defc the class in which the proposed member is actually defined
+     * @param mods modifier flags for the proposed member
+     * @param lookupClass the class for which the access check is being made
+     * @return true iff the the accessing class can access such a member
+     */
+    public static boolean isMemberAccessible(Class<?> refc,  // symbolic ref class
+                                             Class<?> defc,  // actual def class
+                                             int      mods,  // actual member mods
+                                             Class<?> lookupClass,
+                                             int      allowedModes) {
+        if (allowedModes == 0)  return false;
+        assert((allowedModes & PUBLIC) != 0 &&
+               (allowedModes & ~(ALL_ACCESS_MODES|PACKAGE_ALLOWED)) == 0);
+        // The symbolic reference class (refc) must always be fully verified.
+        if (!isClassAccessible(refc, lookupClass, allowedModes)) {
+            return false;
+        }
+        // Usually refc and defc are the same, but verify defc also in case they differ.
+        if (defc == lookupClass &&
+            (allowedModes & PRIVATE) != 0)
+            return true;        // easy check; all self-access is OK
+        switch (mods & ALL_ACCESS_MODES) {
+        case PUBLIC:
+            return true;  // already checked above
+        case PROTECTED:
+            assert !defc.isInterface(); // protected members aren't allowed in interfaces
+            if ((allowedModes & PROTECTED_OR_PACKAGE_ALLOWED) != 0 &&
+                isSamePackage(defc, lookupClass))
+                return true;
+            if ((allowedModes & PROTECTED) == 0)
+                return false;
+            // Protected members are accessible by subclasses, which does not include interfaces.
+            // Interfaces are types, not classes. They should not have access to
+            // protected members in j.l.Object, even though it is their superclass.
+            if ((mods & STATIC) != 0 &&
+                !isRelatedClass(refc, lookupClass))
+                return false;
+            if ((allowedModes & PROTECTED) != 0 &&
+                isSubClass(lookupClass, defc))
+                return true;
+            return false;
+        case PACKAGE_ONLY:  // That is, zero.  Unmarked member is package-only access.
+            assert !defc.isInterface(); // package-private members aren't allowed in interfaces
+            return ((allowedModes & PACKAGE_ALLOWED) != 0 &&
+                    isSamePackage(defc, lookupClass));
+        case PRIVATE:
+            // Loosened rules for privates follows access rules for inner classes.
+            return (ALLOW_NESTMATE_ACCESS &&
+                    (allowedModes & PRIVATE) != 0 &&
+                    isSamePackageMember(defc, lookupClass));
+        default:
+            throw new IllegalArgumentException("bad modifiers: "+Modifier.toString(mods));
+        }
+    }
+
+    static boolean isRelatedClass(Class<?> refc, Class<?> lookupClass) {
+        return (refc == lookupClass ||
+                isSubClass(refc, lookupClass) ||
+                isSubClass(lookupClass, refc));
+    }
+
+    static boolean isSubClass(Class<?> lookupClass, Class<?> defc) {
+        return defc.isAssignableFrom(lookupClass) &&
+               !lookupClass.isInterface(); // interfaces are types, not classes.
+    }
+
+    /**
+     * Evaluate the JVM linkage rules for access to the given class on behalf of caller.
+     * <h3>JVM Specification, 5.4.4 "Access Control"</h3>
+     * A class or interface C is accessible to a class or interface D
+     * if and only if either of the following conditions are true:<ul>
+     * <li>C is public.
+     * <li>C and D are members of the same runtime package.
+     * </ul>
+     * @param refc the symbolic reference class to which access is being checked (C)
+     * @param lookupClass the class performing the lookup (D)
+     */
+    public static boolean isClassAccessible(Class<?> refc, Class<?> lookupClass,
+                                            int allowedModes) {
+        if (allowedModes == 0)  return false;
+        // Android-changed: Use public APIs to figure out whether a class
+        // is public or not.
+        if (Modifier.isPublic(refc.getModifiers()))
+            return true;
+        if ((allowedModes & PACKAGE_ALLOWED) != 0 &&
+            isSamePackage(lookupClass, refc))
+            return true;
+        return false;
+    }
+
+    /**
+     * Decide if the given method type, attributed to a member or symbolic
+     * reference of a given reference class, is really visible to that class.
+     * @param type the supposed type of a member or symbolic reference of refc
+     * @param refc the class attempting to make the reference
+     */
+    public static boolean isTypeVisible(Class<?> type, Class<?> refc) {
+        if (type == refc)  return true;  // easy check
+        while (type.isArray())  type = type.getComponentType();
+        if (type.isPrimitive() || type == Object.class)  return true;
+        ClassLoader parent = type.getClassLoader();
+        if (parent == null)  return true;
+        ClassLoader child  = refc.getClassLoader();
+        if (child == null)  return false;
+        if (parent == child || loadersAreRelated(parent, child, true))
+            return true;
+        // Do it the hard way:  Look up the type name from the refc loader.
+        try {
+            Class<?> res = child.loadClass(type.getName());
+            return (type == res);
+        } catch (ClassNotFoundException ex) {
+            return false;
+        }
+    }
+
+    /**
+     * Decide if the given method type, attributed to a member or symbolic
+     * reference of a given reference class, is really visible to that class.
+     * @param type the supposed type of a member or symbolic reference of refc
+     * @param refc the class attempting to make the reference
+     */
+    public static boolean isTypeVisible(java.lang.invoke.MethodType type, Class<?> refc) {
+        for (int n = -1, max = type.parameterCount(); n < max; n++) {
+            Class<?> ptype = (n < 0 ? type.returnType() : type.parameterType(n));
+            if (!isTypeVisible(ptype, refc))
+                return false;
+        }
+        return true;
+    }
+
+    /**
+     * Test if two classes have the same class loader and package qualifier.
+     * @param class1 a class
+     * @param class2 another class
+     * @return whether they are in the same package
+     */
+    public static boolean isSamePackage(Class<?> class1, Class<?> class2) {
+        // Android-changed: Throw IAE (instead of asserting) if called with array classes.
+        if (class1.isArray() || class2.isArray()) {
+            throw new IllegalArgumentException();
+        }
+
+        if (class1 == class2)
+            return true;
+        if (class1.getClassLoader() != class2.getClassLoader())
+            return false;
+        String name1 = class1.getName(), name2 = class2.getName();
+        int dot = name1.lastIndexOf('.');
+        if (dot != name2.lastIndexOf('.'))
+            return false;
+        for (int i = 0; i < dot; i++) {
+            if (name1.charAt(i) != name2.charAt(i))
+                return false;
+        }
+        return true;
+    }
+
+    /** Return the package name for this class.
+     */
+    public static String getPackageName(Class<?> cls) {
+        assert(!cls.isArray());
+        String name = cls.getName();
+        int dot = name.lastIndexOf('.');
+        if (dot < 0)  return "";
+        return name.substring(0, dot);
+    }
+
+    /**
+     * Test if two classes are defined as part of the same package member (top-level class).
+     * If this is true, they can share private access with each other.
+     * @param class1 a class
+     * @param class2 another class
+     * @return whether they are identical or nested together
+     */
+    public static boolean isSamePackageMember(Class<?> class1, Class<?> class2) {
+        if (class1 == class2)
+            return true;
+        if (!isSamePackage(class1, class2))
+            return false;
+        if (getOutermostEnclosingClass(class1) != getOutermostEnclosingClass(class2))
+            return false;
+        return true;
+    }
+
+    private static Class<?> getOutermostEnclosingClass(Class<?> c) {
+        Class<?> pkgmem = c;
+        for (Class<?> enc = c; (enc = enc.getEnclosingClass()) != null; )
+            pkgmem = enc;
+        return pkgmem;
+    }
+
+    private static boolean loadersAreRelated(ClassLoader loader1, ClassLoader loader2,
+                                             boolean loader1MustBeParent) {
+        if (loader1 == loader2 || loader1 == null
+                || (loader2 == null && !loader1MustBeParent)) {
+            return true;
+        }
+        for (ClassLoader scan2 = loader2;
+                scan2 != null; scan2 = scan2.getParent()) {
+            if (scan2 == loader1)  return true;
+        }
+        if (loader1MustBeParent)  return false;
+        // see if loader2 is a parent of loader1:
+        for (ClassLoader scan1 = loader1;
+                scan1 != null; scan1 = scan1.getParent()) {
+            if (scan1 == loader2)  return true;
+        }
+        return false;
+    }
+
+    /**
+     * Is the class loader of parentClass identical to, or an ancestor of,
+     * the class loader of childClass?
+     * @param parentClass a class
+     * @param childClass another class, which may be a descendent of the first class
+     * @return whether parentClass precedes or equals childClass in class loader order
+     */
+    public static boolean classLoaderIsAncestor(Class<?> parentClass, Class<?> childClass) {
+        return loadersAreRelated(parentClass.getClassLoader(), childClass.getClassLoader(), true);
+    }
+}
diff --git a/ojluni/src/main/java/sun/security/util/Resources.java b/ojluni/src/main/java/sun/security/util/Resources.java
index 299facc..286acc9 100644
--- a/ojluni/src/main/java/sun/security/util/Resources.java
+++ b/ojluni/src/main/java/sun/security/util/Resources.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,509 +34,6 @@
 
     private static final Object[][] contents = {
 
-        // shared (from jarsigner)
-        {"SPACE", " "},
-        {"2SPACE", "  "},
-        {"6SPACE", "      "},
-        {"COMMA", ", "},
-        // shared (from keytool)
-        {"NEWLINE", "\n"},
-        {"STAR",
-                "*******************************************"},
-        {"STARNN",
-                "*******************************************\n\n"},
-
-        // keytool: Help part
-        {".OPTION.", " [OPTION]..."},
-        {"Options.", "Options:"},
-        {"Use.keytool.help.for.all.available.commands",
-                 "Use \"keytool -help\" for all available commands"},
-        {"Key.and.Certificate.Management.Tool",
-                 "Key and Certificate Management Tool"},
-        {"Commands.", "Commands:"},
-        {"Use.keytool.command.name.help.for.usage.of.command.name",
-                "Use \"keytool -command_name -help\" for usage of command_name"},
-        // keytool: help: commands
-        {"Generates.a.certificate.request",
-                "Generates a certificate request"}, //-certreq
-        {"Changes.an.entry.s.alias",
-                "Changes an entry's alias"}, //-changealias
-        {"Deletes.an.entry",
-                "Deletes an entry"}, //-delete
-        {"Exports.certificate",
-                "Exports certificate"}, //-exportcert
-        {"Generates.a.key.pair",
-                "Generates a key pair"}, //-genkeypair
-        {"Generates.a.secret.key",
-                "Generates a secret key"}, //-genseckey
-        {"Generates.certificate.from.a.certificate.request",
-                "Generates certificate from a certificate request"}, //-gencert
-        {"Generates.CRL", "Generates CRL"}, //-gencrl
-        {"Imports.entries.from.a.JDK.1.1.x.style.identity.database",
-                "Imports entries from a JDK 1.1.x-style identity database"}, //-identitydb
-        {"Imports.a.certificate.or.a.certificate.chain",
-                "Imports a certificate or a certificate chain"}, //-importcert
-        {"Imports.one.or.all.entries.from.another.keystore",
-                "Imports one or all entries from another keystore"}, //-importkeystore
-        {"Clones.a.key.entry",
-                "Clones a key entry"}, //-keyclone
-        {"Changes.the.key.password.of.an.entry",
-                "Changes the key password of an entry"}, //-keypasswd
-        {"Lists.entries.in.a.keystore",
-                "Lists entries in a keystore"}, //-list
-        {"Prints.the.content.of.a.certificate",
-                "Prints the content of a certificate"}, //-printcert
-        {"Prints.the.content.of.a.certificate.request",
-                "Prints the content of a certificate request"}, //-printcertreq
-        {"Prints.the.content.of.a.CRL.file",
-                "Prints the content of a CRL file"}, //-printcrl
-        {"Generates.a.self.signed.certificate",
-                "Generates a self-signed certificate"}, //-selfcert
-        {"Changes.the.store.password.of.a.keystore",
-                "Changes the store password of a keystore"}, //-storepasswd
-        // keytool: help: options
-        {"alias.name.of.the.entry.to.process",
-                "alias name of the entry to process"}, //-alias
-        {"destination.alias",
-                "destination alias"}, //-destalias
-        {"destination.key.password",
-                "destination key password"}, //-destkeypass
-        {"destination.keystore.name",
-                "destination keystore name"}, //-destkeystore
-        {"destination.keystore.password.protected",
-                "destination keystore password protected"}, //-destprotected
-        {"destination.keystore.provider.name",
-                "destination keystore provider name"}, //-destprovidername
-        {"destination.keystore.password",
-                "destination keystore password"}, //-deststorepass
-        {"destination.keystore.type",
-                "destination keystore type"}, //-deststoretype
-        {"distinguished.name",
-                "distinguished name"}, //-dname
-        {"X.509.extension",
-                "X.509 extension"}, //-ext
-        {"output.file.name",
-                "output file name"}, //-file and -outfile
-        {"input.file.name",
-                "input file name"}, //-file and -infile
-        {"key.algorithm.name",
-                "key algorithm name"}, //-keyalg
-        {"key.password",
-                "key password"}, //-keypass
-        {"key.bit.size",
-                "key bit size"}, //-keysize
-        {"keystore.name",
-                "keystore name"}, //-keystore
-        {"new.password",
-                "new password"}, //-new
-        {"do.not.prompt",
-                "do not prompt"}, //-noprompt
-        {"password.through.protected.mechanism",
-                "password through protected mechanism"}, //-protected
-        {"provider.argument",
-                "provider argument"}, //-providerarg
-        {"provider.class.name",
-                "provider class name"}, //-providerclass
-        {"provider.name",
-                "provider name"}, //-providername
-        {"provider.classpath",
-                "provider classpath"}, //-providerpath
-        {"output.in.RFC.style",
-                "output in RFC style"}, //-rfc
-        {"signature.algorithm.name",
-                "signature algorithm name"}, //-sigalg
-        {"source.alias",
-                "source alias"}, //-srcalias
-        {"source.key.password",
-                "source key password"}, //-srckeypass
-        {"source.keystore.name",
-                "source keystore name"}, //-srckeystore
-        {"source.keystore.password.protected",
-                "source keystore password protected"}, //-srcprotected
-        {"source.keystore.provider.name",
-                "source keystore provider name"}, //-srcprovidername
-        {"source.keystore.password",
-                "source keystore password"}, //-srcstorepass
-        {"source.keystore.type",
-                "source keystore type"}, //-srcstoretype
-        {"SSL.server.host.and.port",
-                "SSL server host and port"}, //-sslserver
-        {"signed.jar.file",
-                "signed jar file"}, //=jarfile
-        {"certificate.validity.start.date.time",
-                "certificate validity start date/time"}, //-startdate
-        {"keystore.password",
-                "keystore password"}, //-storepass
-        {"keystore.type",
-                "keystore type"}, //-storetype
-        {"trust.certificates.from.cacerts",
-                "trust certificates from cacerts"}, //-trustcacerts
-        {"verbose.output",
-                "verbose output"}, //-v
-        {"validity.number.of.days",
-                "validity number of days"}, //-validity
-        {"Serial.ID.of.cert.to.revoke",
-                 "Serial ID of cert to revoke"}, //-id
-        // keytool: Running part
-        {"keytool.error.", "keytool error: "},
-        {"Illegal.option.", "Illegal option:  "},
-        {"Illegal.value.", "Illegal value: "},
-        {"Unknown.password.type.", "Unknown password type: "},
-        {"Cannot.find.environment.variable.",
-                "Cannot find environment variable: "},
-        {"Cannot.find.file.", "Cannot find file: "},
-        {"Command.option.flag.needs.an.argument.", "Command option {0} needs an argument."},
-        {"Warning.Different.store.and.key.passwords.not.supported.for.PKCS12.KeyStores.Ignoring.user.specified.command.value.",
-                "Warning:  Different store and key passwords not supported for PKCS12 KeyStores. Ignoring user-specified {0} value."},
-        {".keystore.must.be.NONE.if.storetype.is.{0}",
-                "-keystore must be NONE if -storetype is {0}"},
-        {"Too.many.retries.program.terminated",
-                 "Too many retries, program terminated"},
-        {".storepasswd.and.keypasswd.commands.not.supported.if.storetype.is.{0}",
-                "-storepasswd and -keypasswd commands not supported if -storetype is {0}"},
-        {".keypasswd.commands.not.supported.if.storetype.is.PKCS12",
-                "-keypasswd commands not supported if -storetype is PKCS12"},
-        {".keypass.and.new.can.not.be.specified.if.storetype.is.{0}",
-                "-keypass and -new can not be specified if -storetype is {0}"},
-        {"if.protected.is.specified.then.storepass.keypass.and.new.must.not.be.specified",
-                "if -protected is specified, then -storepass, -keypass, and -new must not be specified"},
-        {"if.srcprotected.is.specified.then.srcstorepass.and.srckeypass.must.not.be.specified",
-                "if -srcprotected is specified, then -srcstorepass and -srckeypass must not be specified"},
-        {"if.keystore.is.not.password.protected.then.storepass.keypass.and.new.must.not.be.specified",
-                "if keystore is not password protected, then -storepass, -keypass, and -new must not be specified"},
-        {"if.source.keystore.is.not.password.protected.then.srcstorepass.and.srckeypass.must.not.be.specified",
-                "if source keystore is not password protected, then -srcstorepass and -srckeypass must not be specified"},
-        {"Illegal.startdate.value", "Illegal startdate value"},
-        {"Validity.must.be.greater.than.zero",
-                "Validity must be greater than zero"},
-        {"provName.not.a.provider", "{0} not a provider"},
-        {"Usage.error.no.command.provided", "Usage error: no command provided"},
-        {"Source.keystore.file.exists.but.is.empty.", "Source keystore file exists, but is empty: "},
-        {"Please.specify.srckeystore", "Please specify -srckeystore"},
-        {"Must.not.specify.both.v.and.rfc.with.list.command",
-                "Must not specify both -v and -rfc with 'list' command"},
-        {"Key.password.must.be.at.least.6.characters",
-                "Key password must be at least 6 characters"},
-        {"New.password.must.be.at.least.6.characters",
-                "New password must be at least 6 characters"},
-        {"Keystore.file.exists.but.is.empty.",
-                "Keystore file exists, but is empty: "},
-        {"Keystore.file.does.not.exist.",
-                "Keystore file does not exist: "},
-        {"Must.specify.destination.alias", "Must specify destination alias"},
-        {"Must.specify.alias", "Must specify alias"},
-        {"Keystore.password.must.be.at.least.6.characters",
-                "Keystore password must be at least 6 characters"},
-        {"Enter.keystore.password.", "Enter keystore password:  "},
-        {"Enter.source.keystore.password.", "Enter source keystore password:  "},
-        {"Enter.destination.keystore.password.", "Enter destination keystore password:  "},
-        {"Keystore.password.is.too.short.must.be.at.least.6.characters",
-         "Keystore password is too short - must be at least 6 characters"},
-        {"Unknown.Entry.Type", "Unknown Entry Type"},
-        {"Too.many.failures.Alias.not.changed", "Too many failures. Alias not changed"},
-        {"Entry.for.alias.alias.successfully.imported.",
-                 "Entry for alias {0} successfully imported."},
-        {"Entry.for.alias.alias.not.imported.", "Entry for alias {0} not imported."},
-        {"Problem.importing.entry.for.alias.alias.exception.Entry.for.alias.alias.not.imported.",
-                 "Problem importing entry for alias {0}: {1}.\nEntry for alias {0} not imported."},
-        {"Import.command.completed.ok.entries.successfully.imported.fail.entries.failed.or.cancelled",
-                 "Import command completed:  {0} entries successfully imported, {1} entries failed or cancelled"},
-        {"Warning.Overwriting.existing.alias.alias.in.destination.keystore",
-                 "Warning: Overwriting existing alias {0} in destination keystore"},
-        {"Existing.entry.alias.alias.exists.overwrite.no.",
-                 "Existing entry alias {0} exists, overwrite? [no]:  "},
-        {"Too.many.failures.try.later", "Too many failures - try later"},
-        {"Certification.request.stored.in.file.filename.",
-                "Certification request stored in file <{0}>"},
-        {"Submit.this.to.your.CA", "Submit this to your CA"},
-        {"if.alias.not.specified.destalias.srckeypass.and.destkeypass.must.not.be.specified",
-            "if alias not specified, destalias, srckeypass, and destkeypass must not be specified"},
-        {"Certificate.stored.in.file.filename.",
-                "Certificate stored in file <{0}>"},
-        {"Certificate.reply.was.installed.in.keystore",
-                "Certificate reply was installed in keystore"},
-        {"Certificate.reply.was.not.installed.in.keystore",
-                "Certificate reply was not installed in keystore"},
-        {"Certificate.was.added.to.keystore",
-                "Certificate was added to keystore"},
-        {"Certificate.was.not.added.to.keystore",
-                "Certificate was not added to keystore"},
-        {".Storing.ksfname.", "[Storing {0}]"},
-        {"alias.has.no.public.key.certificate.",
-                "{0} has no public key (certificate)"},
-        {"Cannot.derive.signature.algorithm",
-                "Cannot derive signature algorithm"},
-        {"Alias.alias.does.not.exist",
-                "Alias <{0}> does not exist"},
-        {"Alias.alias.has.no.certificate",
-                "Alias <{0}> has no certificate"},
-        {"Key.pair.not.generated.alias.alias.already.exists",
-                "Key pair not generated, alias <{0}> already exists"},
-        {"Generating.keysize.bit.keyAlgName.key.pair.and.self.signed.certificate.sigAlgName.with.a.validity.of.validality.days.for",
-                "Generating {0} bit {1} key pair and self-signed certificate ({2}) with a validity of {3} days\n\tfor: {4}"},
-        {"Enter.key.password.for.alias.", "Enter key password for <{0}>"},
-        {".RETURN.if.same.as.keystore.password.",
-                "\t(RETURN if same as keystore password):  "},
-        {"Key.password.is.too.short.must.be.at.least.6.characters",
-                "Key password is too short - must be at least 6 characters"},
-        {"Too.many.failures.key.not.added.to.keystore",
-                "Too many failures - key not added to keystore"},
-        {"Destination.alias.dest.already.exists",
-                "Destination alias <{0}> already exists"},
-        {"Password.is.too.short.must.be.at.least.6.characters",
-                "Password is too short - must be at least 6 characters"},
-        {"Too.many.failures.Key.entry.not.cloned",
-                "Too many failures. Key entry not cloned"},
-        {"key.password.for.alias.", "key password for <{0}>"},
-        {"Keystore.entry.for.id.getName.already.exists",
-                "Keystore entry for <{0}> already exists"},
-        {"Creating.keystore.entry.for.id.getName.",
-                "Creating keystore entry for <{0}> ..."},
-        {"No.entries.from.identity.database.added",
-                "No entries from identity database added"},
-        {"Alias.name.alias", "Alias name: {0}"},
-        {"Creation.date.keyStore.getCreationDate.alias.",
-                "Creation date: {0,date}"},
-        {"alias.keyStore.getCreationDate.alias.",
-                "{0}, {1,date}, "},
-        {"alias.", "{0}, "},
-        {"Entry.type.type.", "Entry type: {0}"},
-        {"Certificate.chain.length.", "Certificate chain length: "},
-        {"Certificate.i.1.", "Certificate[{0,number,integer}]:"},
-        {"Certificate.fingerprint.SHA1.", "Certificate fingerprint (SHA1): "},
-        {"Keystore.type.", "Keystore type: "},
-        {"Keystore.provider.", "Keystore provider: "},
-        {"Your.keystore.contains.keyStore.size.entry",
-                "Your keystore contains {0,number,integer} entry"},
-        {"Your.keystore.contains.keyStore.size.entries",
-                "Your keystore contains {0,number,integer} entries"},
-        {"Failed.to.parse.input", "Failed to parse input"},
-        {"Empty.input", "Empty input"},
-        {"Not.X.509.certificate", "Not X.509 certificate"},
-        {"alias.has.no.public.key", "{0} has no public key"},
-        {"alias.has.no.X.509.certificate", "{0} has no X.509 certificate"},
-        {"New.certificate.self.signed.", "New certificate (self-signed):"},
-        {"Reply.has.no.certificates", "Reply has no certificates"},
-        {"Certificate.not.imported.alias.alias.already.exists",
-                "Certificate not imported, alias <{0}> already exists"},
-        {"Input.not.an.X.509.certificate", "Input not an X.509 certificate"},
-        {"Certificate.already.exists.in.keystore.under.alias.trustalias.",
-                "Certificate already exists in keystore under alias <{0}>"},
-        {"Do.you.still.want.to.add.it.no.",
-                "Do you still want to add it? [no]:  "},
-        {"Certificate.already.exists.in.system.wide.CA.keystore.under.alias.trustalias.",
-                "Certificate already exists in system-wide CA keystore under alias <{0}>"},
-        {"Do.you.still.want.to.add.it.to.your.own.keystore.no.",
-                "Do you still want to add it to your own keystore? [no]:  "},
-        {"Trust.this.certificate.no.", "Trust this certificate? [no]:  "},
-        {"YES", "YES"},
-        {"New.prompt.", "New {0}: "},
-        {"Passwords.must.differ", "Passwords must differ"},
-        {"Re.enter.new.prompt.", "Re-enter new {0}: "},
-        {"Re.enter.new.password.", "Re-enter new password: "},
-        {"They.don.t.match.Try.again", "They don't match. Try again"},
-        {"Enter.prompt.alias.name.", "Enter {0} alias name:  "},
-        {"Enter.new.alias.name.RETURN.to.cancel.import.for.this.entry.",
-                 "Enter new alias name\t(RETURN to cancel import for this entry):  "},
-        {"Enter.alias.name.", "Enter alias name:  "},
-        {".RETURN.if.same.as.for.otherAlias.",
-                "\t(RETURN if same as for <{0}>)"},
-        {".PATTERN.printX509Cert",
-                "Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t MD5:  {5}\n\t SHA1: {6}\n\t SHA256: {7}\n\t Signature algorithm name: {8}\n\t Version: {9}"},
-        {"What.is.your.first.and.last.name.",
-                "What is your first and last name?"},
-        {"What.is.the.name.of.your.organizational.unit.",
-                "What is the name of your organizational unit?"},
-        {"What.is.the.name.of.your.organization.",
-                "What is the name of your organization?"},
-        {"What.is.the.name.of.your.City.or.Locality.",
-                "What is the name of your City or Locality?"},
-        {"What.is.the.name.of.your.State.or.Province.",
-                "What is the name of your State or Province?"},
-        {"What.is.the.two.letter.country.code.for.this.unit.",
-                "What is the two-letter country code for this unit?"},
-        {"Is.name.correct.", "Is {0} correct?"},
-        {"no", "no"},
-        {"yes", "yes"},
-        {"y", "y"},
-        {".defaultValue.", "  [{0}]:  "},
-        {"Alias.alias.has.no.key",
-                "Alias <{0}> has no key"},
-        {"Alias.alias.references.an.entry.type.that.is.not.a.private.key.entry.The.keyclone.command.only.supports.cloning.of.private.key",
-                 "Alias <{0}> references an entry type that is not a private key entry.  The -keyclone command only supports cloning of private key entries"},
-
-        {".WARNING.WARNING.WARNING.",
-            "*****************  WARNING WARNING WARNING  *****************"},
-        {"Signer.d.", "Signer #%d:"},
-        {"Timestamp.", "Timestamp:"},
-        {"Signature.", "Signature:"},
-        {"CRLs.", "CRLs:"},
-        {"Certificate.owner.", "Certificate owner: "},
-        {"Not.a.signed.jar.file", "Not a signed jar file"},
-        {"No.certificate.from.the.SSL.server",
-                "No certificate from the SSL server"},
-
-        {".The.integrity.of.the.information.stored.in.your.keystore.",
-            "* The integrity of the information stored in your keystore  *\n" +
-            "* has NOT been verified!  In order to verify its integrity, *\n" +
-            "* you must provide your keystore password.                  *"},
-        {".The.integrity.of.the.information.stored.in.the.srckeystore.",
-            "* The integrity of the information stored in the srckeystore*\n" +
-            "* has NOT been verified!  In order to verify its integrity, *\n" +
-            "* you must provide the srckeystore password.                *"},
-
-        {"Certificate.reply.does.not.contain.public.key.for.alias.",
-                "Certificate reply does not contain public key for <{0}>"},
-        {"Incomplete.certificate.chain.in.reply",
-                "Incomplete certificate chain in reply"},
-        {"Certificate.chain.in.reply.does.not.verify.",
-                "Certificate chain in reply does not verify: "},
-        {"Top.level.certificate.in.reply.",
-                "Top-level certificate in reply:\n"},
-        {".is.not.trusted.", "... is not trusted. "},
-        {"Install.reply.anyway.no.", "Install reply anyway? [no]:  "},
-        {"NO", "NO"},
-        {"Public.keys.in.reply.and.keystore.don.t.match",
-                "Public keys in reply and keystore don't match"},
-        {"Certificate.reply.and.certificate.in.keystore.are.identical",
-                "Certificate reply and certificate in keystore are identical"},
-        {"Failed.to.establish.chain.from.reply",
-                "Failed to establish chain from reply"},
-        {"n", "n"},
-        {"Wrong.answer.try.again", "Wrong answer, try again"},
-        {"Secret.key.not.generated.alias.alias.already.exists",
-                "Secret Key not generated, alias <{0}> already exists"},
-        {"Please.provide.keysize.for.secret.key.generation",
-                "Please provide -keysize for secret key generation"},
-
-        {"Extensions.", "Extensions: "},
-        {".Empty.value.", "(Empty value)"},
-        {"Extension.Request.", "Extension Request:"},
-        {"PKCS.10.Certificate.Request.Version.1.0.Subject.s.Public.Key.s.format.s.key.",
-                "PKCS #10 Certificate Request (Version 1.0)\n" +
-                "Subject: %s\nPublic Key: %s format %s key\n"},
-        {"Unknown.keyUsage.type.", "Unknown keyUsage type: "},
-        {"Unknown.extendedkeyUsage.type.", "Unknown extendedkeyUsage type: "},
-        {"Unknown.AccessDescription.type.", "Unknown AccessDescription type: "},
-        {"Unrecognized.GeneralName.type.", "Unrecognized GeneralName type: "},
-        {"This.extension.cannot.be.marked.as.critical.",
-                 "This extension cannot be marked as critical. "},
-        {"Odd.number.of.hex.digits.found.", "Odd number of hex digits found: "},
-        {"Unknown.extension.type.", "Unknown extension type: "},
-        {"command.{0}.is.ambiguous.", "command {0} is ambiguous:"},
-
-        // policytool
-        {"Warning.A.public.key.for.alias.signers.i.does.not.exist.Make.sure.a.KeyStore.is.properly.configured.",
-                "Warning: A public key for alias {0} does not exist.  Make sure a KeyStore is properly configured."},
-        {"Warning.Class.not.found.class", "Warning: Class not found: {0}"},
-        {"Warning.Invalid.argument.s.for.constructor.arg",
-                "Warning: Invalid argument(s) for constructor: {0}"},
-        {"Illegal.Principal.Type.type", "Illegal Principal Type: {0}"},
-        {"Illegal.option.option", "Illegal option: {0}"},
-        {"Usage.policytool.options.", "Usage: policytool [options]"},
-        {".file.file.policy.file.location",
-                "  [-file <file>]    policy file location"},
-        {"New", "New"},
-        {"Open", "Open"},
-        {"Save", "Save"},
-        {"Save.As", "Save As"},
-        {"View.Warning.Log", "View Warning Log"},
-        {"Exit", "Exit"},
-        {"Add.Policy.Entry", "Add Policy Entry"},
-        {"Edit.Policy.Entry", "Edit Policy Entry"},
-        {"Remove.Policy.Entry", "Remove Policy Entry"},
-        {"Edit", "Edit"},
-        {"Retain", "Retain"},
-
-        {"Warning.File.name.may.include.escaped.backslash.characters.It.is.not.necessary.to.escape.backslash.characters.the.tool.escapes",
-            "Warning: File name may include escaped backslash characters. " +
-                        "It is not necessary to escape backslash characters " +
-                        "(the tool escapes characters as necessary when writing " +
-                        "the policy contents to the persistent store).\n\n" +
-                        "Click on Retain to retain the entered name, or click on " +
-                        "Edit to edit the name."},
-
-        {"Add.Public.Key.Alias", "Add Public Key Alias"},
-        {"Remove.Public.Key.Alias", "Remove Public Key Alias"},
-        {"File", "File"},
-        {"KeyStore", "KeyStore"},
-        {"Policy.File.", "Policy File:"},
-        {"Could.not.open.policy.file.policyFile.e.toString.",
-                "Could not open policy file: {0}: {1}"},
-        {"Policy.Tool", "Policy Tool"},
-        {"Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.",
-                "Errors have occurred while opening the policy configuration.  View the Warning Log for more information."},
-        {"Error", "Error"},
-        {"OK", "OK"},
-        {"Status", "Status"},
-        {"Warning", "Warning"},
-        {"Permission.",
-                "Permission:                                                       "},
-        {"Principal.Type.", "Principal Type:"},
-        {"Principal.Name.", "Principal Name:"},
-        {"Target.Name.",
-                "Target Name:                                                    "},
-        {"Actions.",
-                "Actions:                                                             "},
-        {"OK.to.overwrite.existing.file.filename.",
-                "OK to overwrite existing file {0}?"},
-        {"Cancel", "Cancel"},
-        {"CodeBase.", "CodeBase:"},
-        {"SignedBy.", "SignedBy:"},
-        {"Add.Principal", "Add Principal"},
-        {"Edit.Principal", "Edit Principal"},
-        {"Remove.Principal", "Remove Principal"},
-        {"Principals.", "Principals:"},
-        {".Add.Permission", "  Add Permission"},
-        {".Edit.Permission", "  Edit Permission"},
-        {"Remove.Permission", "Remove Permission"},
-        {"Done", "Done"},
-        {"KeyStore.URL.", "KeyStore URL:"},
-        {"KeyStore.Type.", "KeyStore Type:"},
-        {"KeyStore.Provider.", "KeyStore Provider:"},
-        {"KeyStore.Password.URL.", "KeyStore Password URL:"},
-        {"Principals", "Principals"},
-        {".Edit.Principal.", "  Edit Principal:"},
-        {".Add.New.Principal.", "  Add New Principal:"},
-        {"Permissions", "Permissions"},
-        {".Edit.Permission.", "  Edit Permission:"},
-        {".Add.New.Permission.", "  Add New Permission:"},
-        {"Signed.By.", "Signed By:"},
-        {"Cannot.Specify.Principal.with.a.Wildcard.Class.without.a.Wildcard.Name",
-            "Cannot Specify Principal with a Wildcard Class without a Wildcard Name"},
-        {"Cannot.Specify.Principal.without.a.Name",
-            "Cannot Specify Principal without a Name"},
-        {"Permission.and.Target.Name.must.have.a.value",
-                "Permission and Target Name must have a value"},
-        {"Remove.this.Policy.Entry.", "Remove this Policy Entry?"},
-        {"Overwrite.File", "Overwrite File"},
-        {"Policy.successfully.written.to.filename",
-                "Policy successfully written to {0}"},
-        {"null.filename", "null filename"},
-        {"Save.changes.", "Save changes?"},
-        {"Yes", "Yes"},
-        {"No", "No"},
-        {"Policy.Entry", "Policy Entry"},
-        {"Save.Changes", "Save Changes"},
-        {"No.Policy.Entry.selected", "No Policy Entry selected"},
-        {"Unable.to.open.KeyStore.ex.toString.",
-                "Unable to open KeyStore: {0}"},
-        {"No.principal.selected", "No principal selected"},
-        {"No.permission.selected", "No permission selected"},
-        {"name", "name"},
-        {"configuration.type", "configuration type"},
-        {"environment.variable.name", "environment variable name"},
-        {"library.name", "library name"},
-        {"package.name", "package name"},
-        {"policy.type", "policy type"},
-        {"property.name", "property name"},
-        {"Principal.List", "Principal List"},
-        {"Permission.List", "Permission List"},
-        {"Code.Base", "Code Base"},
-        {"KeyStore.U.R.L.", "KeyStore U R L:"},
-        {"KeyStore.Password.U.R.L.", "KeyStore Password U R L:"},
-
-
         // javax.security.auth.PrivateCredentialPermission
         {"invalid.null.input.s.", "invalid null input(s)"},
         {"actions.can.only.be.read.", "actions can only be 'read'"},
@@ -561,6 +58,7 @@
         {"provided.null.OID.map", "provided null OID map"},
 
         // javax.security.auth.Subject
+        {"NEWLINE", "\n"},
         {"invalid.null.AccessControlContext.provided",
                 "invalid null AccessControlContext provided"},
         {"invalid.null.action.provided", "invalid null action provided"},
@@ -629,6 +127,8 @@
         {"multiple.Codebase.expressions",
                 "multiple Codebase expressions"},
         {"multiple.SignedBy.expressions","multiple SignedBy expressions"},
+        {"duplicate.keystore.domain.name","duplicate keystore domain name: {0}"},
+        {"duplicate.keystore.name","duplicate keystore name: {0}"},
         {"SignedBy.has.empty.alias","SignedBy has empty alias"},
         {"can.not.specify.Principal.with.a.wildcard.class.without.a.wildcard.name",
                 "can not specify Principal with a wildcard class without a wildcard name"},
@@ -664,6 +164,7 @@
      *
      * @return the contents of this <code>ResourceBundle</code>.
      */
+    @Override
     public Object[][] getContents() {
         return contents;
     }
diff --git a/ojluni/src/main/java/sun/security/util/SecurityConstants.java b/ojluni/src/main/java/sun/security/util/SecurityConstants.java
index adad3fa..39fabcf 100644
--- a/ojluni/src/main/java/sun/security/util/SecurityConstants.java
+++ b/ojluni/src/main/java/sun/security/util/SecurityConstants.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -71,35 +71,6 @@
     public static final AllPermission ALL_PERMISSION = new AllPermission();
 
     /**
-     * Permission type used when AWT is not present.
-     */
-    /* ----- BEGIN android -----
-    private static class FakeAWTPermission extends BasicPermission {
-        private static final long serialVersionUID = -1L;
-        public FakeAWTPermission(String name) {
-            super(name);
-        }
-        public String toString() {
-            return "(\"java.awt.AWTPermission\" \"" + getName() + "\")";
-        }
-    }
-    ----- END android ----- */
-
-    /**
-     * Permission factory used when AWT is not present.
-     */
-    /* ----- BEGIN android -----
-    private static class FakeAWTPermissionFactory
-        implements PermissionFactory<FakeAWTPermission>
-    {
-        @Override
-        public FakeAWTPermission newPermission(String name) {
-            return new FakeAWTPermission(name);
-        }
-    }
-    ----- END android ----- */
-
-    /**
      * AWT Permissions used in the JDK.
      */
     /* ----- BEGIN android -----
@@ -109,38 +80,28 @@
         // The class name of the factory to create java.awt.AWTPermission objects.
         private static final String AWTFactory = "sun.awt.AWTPermissionFactory";
 
-         // The PermissionFactory to create AWT permissions (or fake permissions
-         // if AWT is not present).
+        // The PermissionFactory to create AWT permissions (or null if AWT is
+        // not present)
         private static final PermissionFactory<?> factory = permissionFactory();
 
         private static PermissionFactory<?> permissionFactory() {
-            Class<?> c = AccessController
-                .doPrivileged(new PrivilegedAction<Class<?>>() {
-                    public Class<?> run() {
-                        try {
-                           return Class.forName(AWTFactory, true, null);
-                        } catch (ClassNotFoundException e) {
-                            // not available
-                            return null;
-                        }
-                    }});
-            if (c != null) {
-                // AWT present
-                try {
-                    return (PermissionFactory<?>)c.newInstance();
-                } catch (InstantiationException x) {
-                    throw new InternalError(x.getMessage());
-                } catch (IllegalAccessException x) {
-                    throw new InternalError(x.getMessage());
-                }
-            } else {
-                // AWT not present
-                return new FakeAWTPermissionFactory();
+            Class<?> c;
+            try {
+                c = Class.forName(AWTFactory, false, AWT.class.getClassLoader());
+            } catch (ClassNotFoundException e) {
+                // not available
+                return null;
+            }
+            // AWT present
+            try {
+                return (PermissionFactory<?>)c.newInstance();
+            } catch (ReflectiveOperationException x) {
+                throw new InternalError(x);
             }
         }
 
         private static Permission newAWTPermission(String name) {
-            return factory.newPermission(name);
+            return (factory == null) ? null : factory.newPermission(name);
         }
 
         // java.lang.SecurityManager
@@ -259,5 +220,5 @@
 
     // java.lang.SecurityManager
     public static final SocketPermission LOCAL_LISTEN_PERMISSION =
-        new SocketPermission("localhost:1024-", SOCKET_LISTEN_ACTION);
+        new SocketPermission("localhost:0", SOCKET_LISTEN_ACTION);
 }
diff --git a/openjdk_java_files.mk b/openjdk_java_files.mk
index 5818d65..d045ac1 100644
--- a/openjdk_java_files.mk
+++ b/openjdk_java_files.mk
@@ -22,6 +22,7 @@
     ojluni/src/main/java/java/io/DataInputStream.java \
     ojluni/src/main/java/java/io/DataOutput.java \
     ojluni/src/main/java/java/io/DataOutputStream.java \
+    ojluni/src/main/java/java/io/DefaultFileSystem.java \
     ojluni/src/main/java/java/io/DeleteOnExitHook.java \
     ojluni/src/main/java/java/io/EOFException.java \
     ojluni/src/main/java/java/io/ExpiringCache.java \
@@ -1163,6 +1164,7 @@
     ojluni/src/main/java/sun/misc/FloatingDecimal.java \
     ojluni/src/main/java/java/lang/invoke/LambdaConversionException.java \
     ojluni/src/main/java/java/lang/invoke/MethodHandle.java \
+    ojluni/src/main/java/java/lang/invoke/MethodHandles.java \
     ojluni/src/main/java/java/lang/invoke/MethodHandleImpl.java \
     ojluni/src/main/java/java/lang/invoke/MethodHandleInfo.java \
     ojluni/src/main/java/java/lang/invoke/MethodHandleStatics.java \
@@ -1188,6 +1190,7 @@
     ojluni/src/main/java/sun/invoke/empty/Empty.java \
     ojluni/src/main/java/sun/invoke/util/BytecodeDescriptor.java \
     ojluni/src/main/java/sun/invoke/util/Wrapper.java \
+    ojluni/src/main/java/sun/invoke/util/VerifyAccess.java \
     ojluni/src/main/java/sun/misc/ASCIICaseInsensitiveComparator.java \
     ojluni/src/main/java/sun/misc/BASE64Decoder.java \
     ojluni/src/main/java/sun/misc/BASE64Encoder.java \
@@ -1613,22 +1616,24 @@
     ojluni/src/main/java/sun/util/logging/PlatformLogger.java \
     ojluni/src/main/java/sun/util/ResourceBundleEnumeration.java \
     ojluni/src/main/java/sun/util/resources/OpenListResourceBundle.java \
-    $(openjdk_javadoc_files)
+    $(openjdk_javadoc_files) \
+    $(openjdk_lambda_stub_files)
 
 # Stubs needed to satisfy javac's dependencies when compiling lambda code. These are
 # not used on Android devices or required by the Jack compiler.
 #
-# The stub files in openjdk_lambda_duplicate_stub_files are present in core-oj as
-# well, and need to be included here to support compiling against older SDKs and the
-# like. This additional bit of ugliness if required to avoid a circular dependency
-# between core-all and these stubs. Eventually, all of these stubs will become
-# "duplicates" and then that list can be renamed to "openjdk_lambda_stub_files".
+# On aosp/master:
+# openjdk_lambda_stub_files : These are included in core-oj as stubs
+# openjdk_lambda_duplicate_stub_files : These contain complete implementations in core-oj.
+#
+# On older platforms : Both sets of stub files are used and core-oj does not contain
+# any of these classes.
 openjdk_lambda_stub_files := \
     ojluni/src/lambda/java/java/lang/invoke/CallSite.java \
     ojluni/src/lambda/java/java/lang/invoke/LambdaMetafactory.java \
-    ojluni/src/lambda/java/java/lang/invoke/MethodHandles.java \
     ojluni/src/lambda/java/java/lang/invoke/SerializedLambda.java
 openjdk_lambda_duplicate_stub_files := \
+    ojluni/src/lambda/java/java/lang/invoke/MethodHandles.java \
     ojluni/src/lambda/java/java/lang/invoke/LambdaConversionException.java \
     ojluni/src/lambda/java/java/lang/invoke/MethodHandle.java \
     ojluni/src/lambda/java/java/lang/invoke/MethodType.java \
diff --git a/support/src/test/java/libcore/java/security/StandardNames.java b/support/src/test/java/libcore/java/security/StandardNames.java
index c9546e2..f78f24c 100644
--- a/support/src/test/java/libcore/java/security/StandardNames.java
+++ b/support/src/test/java/libcore/java/security/StandardNames.java
@@ -230,7 +230,10 @@
         provide("MessageDigest", "SHA-384");
         provide("MessageDigest", "SHA-512");
         provide("Policy", "JavaPolicy");
-        provide("SSLContext", "SSLv3");
+        // Android does not support SSLv3
+        if (IS_RI) {
+            provide("SSLContext", "SSLv3");
+        }
         provide("SSLContext", "TLSv1");
         provide("SSLContext", "TLSv1.1");
         provide("SSLContext", "TLSv1.2");
@@ -580,8 +583,6 @@
             provideSslContextEnabledProtocols("TLSv1.2", TLSVersion.SSLv3, TLSVersion.TLSv12);
             provideSslContextEnabledProtocols("Default", TLSVersion.SSLv3, TLSVersion.TLSv1);
         } else {
-            provideSslContextEnabledProtocols("SSL", TLSVersion.SSLv3, TLSVersion.TLSv12);
-            provideSslContextEnabledProtocols("SSLv3", TLSVersion.SSLv3, TLSVersion.TLSv12);
             provideSslContextEnabledProtocols("TLS", TLSVersion.TLSv1, TLSVersion.TLSv12);
             provideSslContextEnabledProtocols("TLSv1", TLSVersion.TLSv1, TLSVersion.TLSv12);
             provideSslContextEnabledProtocols("TLSv1.1", TLSVersion.TLSv1, TLSVersion.TLSv12);
@@ -593,9 +594,6 @@
     public static final String SSL_CONTEXT_PROTOCOLS_DEFAULT = "Default";
     public static final Set<String> SSL_CONTEXT_PROTOCOLS = new HashSet<String>(Arrays.asList(
         SSL_CONTEXT_PROTOCOLS_DEFAULT,
-        "SSL",
-        // "SSLv2",
-        "SSLv3",
         "TLS",
         "TLSv1",
         "TLSv1.1",
@@ -619,8 +617,6 @@
     }
 
     public static final Set<String> SSL_SOCKET_PROTOCOLS = new HashSet<String>(Arrays.asList(
-        // "SSLv2",
-        "SSLv3",
         "TLSv1",
         "TLSv1.1",
         "TLSv1.2"));