java.lang.invoke: Add a concrete subclass of MethodHandle.

For plain vanilla method handles that refer to an art field or a method
and do not specify any transformations.

bug: 30550796

Change-Id: Ia902fbd95cd3ef03f6f04d784bd50b7045c2f808
diff --git a/ojluni/src/main/java/java/lang/invoke/MethodHandle.java b/ojluni/src/main/java/java/lang/invoke/MethodHandle.java
index ffbc401..dfc7021 100644
--- a/ojluni/src/main/java/java/lang/invoke/MethodHandle.java
+++ b/ojluni/src/main/java/java/lang/invoke/MethodHandle.java
@@ -446,6 +446,20 @@
     private final MethodType type;
     /*private*/ MethodHandle asTypeCache;
     // asTypeCache is not private so that invokers can easily fetch it
+    // Used by the runtime.
+
+    // The kind of this method handle (used by the runtime). This is a well defined
+    // mapping from the MethodHandleInfo.REF_* constants, but is not intended for
+    // public use.
+    private final int handleKind;
+    // The ArtMethod* or ArtField* associated with this method handle (used by the runtime).
+    private final long artFieldOrMethod;
+
+    protected MethodHandle(long artFieldOrMethod, int handleKind, MethodType type) {
+        this.artFieldOrMethod = artFieldOrMethod;
+        this.handleKind = handleKind;
+        this.type = type;
+    }
 
     /**
      * Reports the type of this method handle.
@@ -457,19 +471,6 @@
     }
 
     /**
-     * Package-private constructor for the method handle implementation hierarchy.
-     * Method handle inheritance will be contained completely within
-     * the {@code java.lang.invoke} package.
-     */
-    // @param type type (permanently assigned) of the new method handle
-    /*non-public*/ MethodHandle(MethodType type) {
-        type.getClass();  // explicit NPE
-        this.type = type;
-
-        // Android-changed: No LambdaForms associated with this MH.
-    }
-
-    /**
      * Invokes the method handle, allowing any caller type descriptor, but requiring an exact type match.
      * The symbolic type descriptor at the call site of {@code invokeExact} must
      * exactly match this method handle's {@link #type type}.
diff --git a/ojluni/src/main/java/java/lang/invoke/MethodHandleImpl.java b/ojluni/src/main/java/java/lang/invoke/MethodHandleImpl.java
new file mode 100644
index 0000000..06ff553
--- /dev/null
+++ b/ojluni/src/main/java/java/lang/invoke/MethodHandleImpl.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * 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.  Google designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Google 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.
+ */
+
+package java.lang.invoke;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+/**
+ * A method handle that's directly associated with an ArtField or an ArtMethod and
+ * specifies no additional transformations.
+ *
+ * @hide
+ */
+public class MethodHandleImpl extends MethodHandle {
+
+    MethodHandleImpl(long artFieldOrMethod, int handleKind, MethodType type) {
+        super(artFieldOrMethod, handleKind, type);
+    }
+}
diff --git a/openjdk_java_files.mk b/openjdk_java_files.mk
index f1e425e..bf4126a 100644
--- a/openjdk_java_files.mk
+++ b/openjdk_java_files.mk
@@ -1163,6 +1163,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/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 \