Merge "MethodHandles: Unhide java.lang.invoke.*"
diff --git a/ojluni/src/main/java/java/lang/invoke/MethodHandle.java b/ojluni/src/main/java/java/lang/invoke/MethodHandle.java
index 25ee9b8..2882686 100644
--- a/ojluni/src/main/java/java/lang/invoke/MethodHandle.java
+++ b/ojluni/src/main/java/java/lang/invoke/MethodHandle.java
@@ -38,7 +38,7 @@
  * {@linkplain #asType conversion},
  * {@linkplain #bindTo insertion},
  * {@linkplain java.lang.invoke.MethodHandles#dropArguments deletion},
- * and {@linkplain java.lang.invoke.MethodHandles#filterArguments substitution}.
+ * and {@code java.lang.invoke.MethodHandles#filterArguments substitution}.
  *
  * <h1>Method handle contents</h1>
  * Method handles are dynamically and strongly typed according to their parameter and return types.
@@ -418,6 +418,7 @@
  * @see MethodHandles
  * @author John Rose, JSR 292 EG
  */
+// TODO: Change @code to @link once filterArguments is unhidden.
 public abstract class MethodHandle {
     // Android-changed:
     //
@@ -435,10 +436,12 @@
     /**
      * Internal marker interface which distinguishes (to the Java compiler)
      * those methods which are <a href="MethodHandle.html#sigpoly">signature polymorphic</a>.
+     *
+     * @hide
      */
     @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD})
     @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
-    @interface PolymorphicSignature { }
+    public @interface PolymorphicSignature { }
 
     /**
      * The type of this method handle, this corresponds to the exact type of the method
@@ -485,11 +488,12 @@
 
     // The kind of this method handle (used by the runtime). This is one of the INVOKE_*
     // constants or SGET/SPUT, IGET/IPUT.
-    protected final int handleKind;
+    /** @hide */ protected final int handleKind;
 
     // The ArtMethod* or ArtField* associated with this method handle (used by the runtime).
-    protected final long artFieldOrMethod;
+    /** @hide */ protected final long artFieldOrMethod;
 
+    /** @hide */
     protected MethodHandle(long artFieldOrMethod, int handleKind, MethodType type) {
         this.artFieldOrMethod = artFieldOrMethod;
         this.handleKind = handleKind;
@@ -622,9 +626,11 @@
      * @throws WrongMethodTypeException if the target's type cannot be adjusted to take the given number of {@code Object} arguments
      * @throws Throwable anything thrown by the target method invocation
      * @see MethodHandles#spreadInvoker
+     *
+     * @hide
      */
     public Object invokeWithArguments(Object... arguments) throws Throwable {
-        // TODO(narayan): Implement invokeWithArguments.
+        // TODO(narayan): Implement invokeWithArguments, remove @hide.
         throw new UnsupportedOperationException("invokeWithArguments(Object...)");
     }
 
@@ -852,11 +858,13 @@
      *         <a href="MethodHandle.html#maxarity">too many parameters</a>
      * @throws WrongMethodTypeException if the implied {@code asType} call fails
      * @see #asCollector
+     *
+     * @hide
      */
     public MethodHandle asSpreader(Class<?> arrayType, int arrayLength) {
         MethodType postSpreadType = asSpreaderChecks(arrayType, arrayLength);
 
-        // Android-changed, TODO(narayan): Not implemented yet.
+        // Android-changed, TODO(narayan): Implement asSpreader, remove @hide.
         throw new UnsupportedOperationException("asSpreader(Class<?>, int)");
     }
 
@@ -974,11 +982,13 @@
      * @throws WrongMethodTypeException if the implied {@code asType} call fails
      * @see #asSpreader
      * @see #asVarargsCollector
+     *
+     * @hide
      */
     public MethodHandle asCollector(Class<?> arrayType, int arrayLength) {
         asCollectorChecks(arrayType, arrayLength);
 
-        // Android-changed, TODO(narayan): Not implemented yet.
+        // Android-changed, TODO(narayan): Implement asCollector, remove @hide.
         throw new UnsupportedOperationException("asCollector(Class<?>, int)");
     }
 
@@ -1018,7 +1028,7 @@
      * When called with {@link #invokeExact invokeExact}, the adapter invokes
      * the target with no argument changes.
      * (<em>Note:</em> This behavior is different from a
-     * {@linkplain #asCollector fixed arity collector},
+     * {@code #asCollector fixed arity collector},
      * since it accepts a whole array of indeterminate length,
      * rather than a fixed number of arguments.)
      * <p>
@@ -1055,7 +1065,7 @@
      * In all cases, what the target eventually returns is returned unchanged by the adapter.
      * <p>
      * In the final case, it is exactly as if the target method handle were
-     * temporarily adapted with a {@linkplain #asCollector fixed arity collector}
+     * temporarily adapted with a {@code #asCollector fixed arity collector}
      * to the arity required by the caller type.
      * (As with {@code asCollector}, if the array length is zero,
      * a shared constant may be used instead of a new array.
@@ -1084,7 +1094,7 @@
      * <p>
      * In order to create a collecting adapter which collects a predetermined
      * number of arguments, and whose type reflects this predetermined number,
-     * use {@link #asCollector asCollector} instead.
+     * use {@code #asCollector asCollector} instead.
      * <p>
      * No method handle transformations produce new method handles with
      * variable arity, unless they are documented as doing so.
@@ -1147,6 +1157,7 @@
      * @see #isVarargsCollector
      * @see #asFixedArity
      */
+    // TODO: Change @code to @link once asCollector is unhidden.
     public MethodHandle asVarargsCollector(Class<?> arrayType) {
         arrayType.getClass(); // explicit NPE
         boolean lastMatch = asCollectorChecks(arrayType, 0);
@@ -1287,12 +1298,15 @@
         return handleKind;
     }
 
+    /** @hide */
     protected void transform(EmulatedStackFrame arguments) throws Throwable {
         throw new AssertionError("MethodHandle.transform should never be called.");
     }
 
     /**
      * Creates a copy of this method handle, copying all relevant data.
+     *
+     * @hide
      */
     protected MethodHandle duplicate() {
         try {
diff --git a/ojluni/src/main/java/java/lang/invoke/MethodHandleInfo.java b/ojluni/src/main/java/java/lang/invoke/MethodHandleInfo.java
index b821f63..a1cc6c6 100644
--- a/ojluni/src/main/java/java/lang/invoke/MethodHandleInfo.java
+++ b/ojluni/src/main/java/java/lang/invoke/MethodHandleInfo.java
@@ -33,7 +33,7 @@
 /**
  * A symbolic reference obtained by cracking a direct method handle
  * into its consitutent symbolic parts.
- * To crack a direct method handle, call {@link Lookup#revealDirect Lookup.revealDirect}.
+ * To crack a direct method handle, call {@code Lookup#revealDirect Lookup.revealDirect}.
  * <h1><a name="directmh"></a>Direct Method Handles</h1>
  * A <em>direct method handle</em> represents a method, constructor, or field without
  * any intervening argument bindings or other transformations.
@@ -74,7 +74,7 @@
  * The requirement of lookup object matching provides a "fast fail" behavior
  * for programs which may otherwise trust erroneous revelation of a method
  * handle with symbolic information (or caller binding) from an unexpected scope.
- * Use {@link java.lang.invoke.MethodHandles#reflectAs} to override this limitation.
+ * Use {@code java.lang.invoke.MethodHandles#reflectAs} to override this limitation.
  *
  * <h1><a name="refkinds"></a>Reference kinds</h1>
  * The <a href="MethodHandles.Lookup.html#lookups">Lookup Factory Methods</a>
@@ -121,6 +121,7 @@
  * </table>
  * @since 1.8
  */
+// TODO: Change @code to @link once reflectAs / revealDirect are unhidden.
 public
 interface MethodHandleInfo {
     /**
diff --git a/ojluni/src/main/java/java/lang/invoke/MethodHandles.java b/ojluni/src/main/java/java/lang/invoke/MethodHandles.java
index f990fd8..9ef4cae 100644
--- a/ojluni/src/main/java/java/lang/invoke/MethodHandles.java
+++ b/ojluni/src/main/java/java/lang/invoke/MethodHandles.java
@@ -132,9 +132,12 @@
      * @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
+     *
+     * @hide
      */
     public static <T extends Member> T
     reflectAs(Class<T> expected, MethodHandle target) {
+        // TODO: Implement reflectAs, remove @hide.
         throw new UnsupportedOperationException("MethodHandles.reflectAs is not implemented.");
     }
 
@@ -149,7 +152,7 @@
      * 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.
+     * {@link #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
@@ -365,10 +368,10 @@
      * 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}
+     * For example, the {@link #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}
+     * The caller sensitive method {@link #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
@@ -467,7 +470,7 @@
      * differently behaving method handles.
      * <p>
      * In cases where the lookup object is
-     * {@link MethodHandles#publicLookup() publicLookup()},
+     * {@link #publicLookup publicLookup()},
      * or some other lookup object without
      * <a href="MethodHandles.Lookup.html#privacc">private access</a>,
      * the lookup class is disregarded.
@@ -496,6 +499,8 @@
      * Nearly all other methods in the JSR 292 API rely on lookup
      * objects to check access requests.
      */
+    // Android-changed: Change link targets from MethodHandles#[public]Lookup to
+    // #[public]Lookup to work around complaints from javadoc.
     public static final
     class Lookup {
         /** The class on behalf of whom the lookup is being performed. */
@@ -1542,9 +1547,11 @@
          * @exception NullPointerException if the target is {@code null}
          * @see MethodHandleInfo
          * @since 1.8
+         *
+         * @hide
          */
         public MethodHandleInfo revealDirect(MethodHandle target) {
-            // TODO(narayan): Implement this method.
+            // TODO(narayan): Implement revealDirect, remove @hide.
             //
             // Notes: Only works for direct method handles. Must check access.
             //
@@ -1684,14 +1691,14 @@
         return new Transformers.ReferenceArrayElementGetter(arrayClass);
     }
 
-    public static byte arrayElementGetter(byte[] array, int i) { return array[i]; }
-    public static boolean arrayElementGetter(boolean[] array, int i) { return array[i]; }
-    public static char arrayElementGetter(char[] array, int i) { return array[i]; }
-    public static short arrayElementGetter(short[] array, int i) { return array[i]; }
-    public static int arrayElementGetter(int[] array, int i) { return array[i]; }
-    public static long arrayElementGetter(long[] array, int i) { return array[i]; }
-    public static float arrayElementGetter(float[] array, int i) { return array[i]; }
-    public static double arrayElementGetter(double[] array, int i) { return array[i]; }
+    /** @hide */ public static byte arrayElementGetter(byte[] array, int i) { return array[i]; }
+    /** @hide */ public static boolean arrayElementGetter(boolean[] array, int i) { return array[i]; }
+    /** @hide */ public static char arrayElementGetter(char[] array, int i) { return array[i]; }
+    /** @hide */ public static short arrayElementGetter(short[] array, int i) { return array[i]; }
+    /** @hide */ public static int arrayElementGetter(int[] array, int i) { return array[i]; }
+    /** @hide */ public static long arrayElementGetter(long[] array, int i) { return array[i]; }
+    /** @hide */ public static float arrayElementGetter(float[] array, int i) { return array[i]; }
+    /** @hide */ public static double arrayElementGetter(double[] array, int i) { return array[i]; }
 
     /**
      * Produces a method handle giving write access to elements of an array.
@@ -1723,13 +1730,21 @@
         return new Transformers.ReferenceArrayElementSetter(arrayClass);
     }
 
+    /** @hide */
     public static void arrayElementSetter(byte[] array, int i, byte val) { array[i] = val; }
+    /** @hide */
     public static void arrayElementSetter(boolean[] array, int i, boolean val) { array[i] = val; }
+    /** @hide */
     public static void arrayElementSetter(char[] array, int i, char val) { array[i] = val; }
+    /** @hide */
     public static void arrayElementSetter(short[] array, int i, short val) { array[i] = val; }
+    /** @hide */
     public static void arrayElementSetter(int[] array, int i, int val) { array[i] = val; }
+    /** @hide */
     public static void arrayElementSetter(long[] array, int i, long val) { array[i] = val; }
+    /** @hide */
     public static void arrayElementSetter(float[] array, int i, float val) { array[i] = val; }
+    /** @hide */
     public static void arrayElementSetter(double[] array, int i, double val) { array[i] = val; }
 
 
@@ -1780,6 +1795,8 @@
      *                  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>
+     *
+     * @hide
      */
     static public
     MethodHandle spreadInvoker(MethodType type, int leadingArgCount) {
@@ -1788,7 +1805,7 @@
         type = type.asSpreaderType(Object[].class, type.parameterCount() - leadingArgCount);
         // return type.invokers().spreadInvoker(leadingArgCount);
 
-        // TODO(narayan): Implement this method.
+        // TODO(narayan): Implement spreadInvoker, remove @hide.
         throw new UnsupportedOperationException("MethodHandles.spreadInvoker is not implemented");
     }
 
@@ -1923,6 +1940,8 @@
      * @throws NullPointerException if either argument is null
      * @throws WrongMethodTypeException if the conversion cannot be made
      * @see MethodHandle#asType
+     *
+     * @hide
      */
     public static
     MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) {
@@ -1935,7 +1954,7 @@
         }
 
         // return MethodHandleImpl.makePairwiseConvert(target, newType, false);
-        // TODO(narayan): Implement this method.
+        // TODO(narayan): Implement explicitCastArguments, remove @hide.
         throw new UnsupportedOperationException("MethodHandles.explicitCastArguments is not implemented");
     }
 
@@ -2091,14 +2110,14 @@
         return new Transformers.ReferenceIdentity(type);
     }
 
-    public static byte identity(byte val) { return val; }
-    public static boolean identity(boolean val) { return val; }
-    public static char identity(char val) { return val; }
-    public static short identity(short val) { return val; }
-    public static int identity(int val) { return val; }
-    public static long identity(long val) { return val; }
-    public static float identity(float val) { return val; }
-    public static double identity(double val) { return val; }
+    /** @hide */ public static byte identity(byte val) { return val; }
+    /** @hide */ public static boolean identity(boolean val) { return val; }
+    /** @hide */ public static char identity(char val) { return val; }
+    /** @hide */ public static short identity(short val) { return val; }
+    /** @hide */ public static int identity(int val) { return val; }
+    /** @hide */ public static long identity(long val) { return val; }
+    /** @hide */ public static float identity(float val) { return val; }
+    /** @hide */ public static double identity(double val) { return val; }
 
     /**
      * Provides a target method handle with one or more <em>bound arguments</em>
@@ -2129,6 +2148,8 @@
      *         before calling the original method handle
      * @throws NullPointerException if the target or the {@code values} array is null
      * @see MethodHandle#bindTo
+     *
+     * @hide
      */
     public static
     MethodHandle insertArguments(MethodHandle target, int pos, Object... values) {
@@ -2149,7 +2170,7 @@
         // }
         // return result;
 
-        // TODO(narayan): Implement this method.
+        // TODO(narayan): Implement insertArguments, remove @hide.
         throw new UnsupportedOperationException("MethodHandles.insertArguments is not implemented");
     }
 
@@ -2363,6 +2384,8 @@
      *          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>
+     *
+     * @hide
      */
     public static
     MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) {
@@ -2389,7 +2412,7 @@
         // result = result.copyWithExtendL(newType, lform, filter);
         // return result;
 
-        // TODO(narayan): Implement this method.
+        // TODO(narayan): Implement filterArguments, remove @hide.
         throw new UnsupportedOperationException("MethodHandles.filterArgument is not implemented");
     }
 
@@ -2513,6 +2536,8 @@
      * @see MethodHandles#foldArguments
      * @see MethodHandles#filterArguments
      * @see MethodHandles#filterReturnValue
+     *
+     * @hide
      */
     public static
     MethodHandle collectArguments(MethodHandle target, int pos, MethodHandle filter) {
@@ -2530,7 +2555,7 @@
         // lform = result.editor().collectArgumentsForm(1 + pos, collectorType.basicType());
         // return result.copyWithExtendL(newType, lform, filter);
 
-        // TODO(narayan): Implement this method.
+        // TODO(narayan): Implement collectArguments, remove @hide.
         throw new UnsupportedOperationException("MethodHandles.collectArguments is not implemented");
     }
 
@@ -2698,6 +2723,8 @@
      *          of the target
      *          (skipping one matching the {@code combiner}'s return type)
      *          are not identical with the argument types of {@code combiner}
+     *
+     * @hide
      */
     public static
     MethodHandle foldArguments(MethodHandle target, MethodHandle combiner) {
@@ -2706,7 +2733,7 @@
         MethodType combinerType = combiner.type();
         Class<?> rtype = foldArgumentChecks(foldPos, targetType, combinerType);
 
-        // TODO(narayan): Implement this method.
+        // TODO(narayan): Implement foldArguments, remove @hide.
         throw new UnsupportedOperationException("MethodHandles.foldArguments is not implemented");
     }
 
diff --git a/openjdk_java_files.mk b/openjdk_java_files.mk
index 58b256d..a38fa4d 100644
--- a/openjdk_java_files.mk
+++ b/openjdk_java_files.mk
@@ -239,6 +239,17 @@
     ojluni/src/main/java/java/lang/VerifyError.java \
     ojluni/src/main/java/java/lang/VirtualMachineError.java \
     ojluni/src/main/java/java/lang/Void.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 \
+    ojluni/src/main/java/java/lang/invoke/MethodType.java \
+    ojluni/src/main/java/java/lang/invoke/MethodTypeForm.java \
+    ojluni/src/main/java/java/lang/invoke/Stable.java \
+    ojluni/src/main/java/java/lang/invoke/Transformers.java \
+    ojluni/src/main/java/java/lang/invoke/WrongMethodTypeException.java \
     ojluni/src/main/java/java/net/AbstractPlainDatagramSocketImpl.java \
     ojluni/src/main/java/java/net/AbstractPlainSocketImpl.java \
     ojluni/src/main/java/java/net/Authenticator.java \
@@ -1341,17 +1352,6 @@
     ojluni/src/main/java/java/time/zone/ZoneRulesProvider.java \
     ojluni/src/main/java/sun/misc/FDBigInteger.java \
     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 \
-    ojluni/src/main/java/java/lang/invoke/MethodType.java \
-    ojluni/src/main/java/java/lang/invoke/MethodTypeForm.java \
-    ojluni/src/main/java/java/lang/invoke/Stable.java \
-    ojluni/src/main/java/java/lang/invoke/Transformers.java \
-    ojluni/src/main/java/java/lang/invoke/WrongMethodTypeException.java \
     ojluni/src/main/java/jdk/net/ExtendedSocketOptions.java \
     ojluni/src/main/java/jdk/net/NetworkPermission.java \
     ojluni/src/main/java/jdk/net/SocketFlow.java \