changeset 47437:cb0d4a1e5256 condy-folding

Update ConstantRef API
author briangoetz
date Tue, 17 Oct 2017 17:40:22 -0400
parents ef9146cce88c
children 81de38607f5d
files make/CompileJavaModules.gmk src/java.base/share/classes/java/lang/invoke/ClassRef.java src/java.base/share/classes/java/lang/invoke/MethodHandleRef.java test/jdk/java/lang/invoke/ConstablesTest.java test/jdk/java/lang/invoke/IntrinsicsTest.java test/langtools/tools/javac/specialConstantFolding/CondyCodeGenerationTest.java test/langtools/tools/javac/specialConstantFolding/DontCompileIfSymbolCantBeFoundTest.java test/langtools/tools/javac/specialConstantFolding/EffectivelyFinalTestNeg.java test/langtools/tools/javac/specialConstantFolding/IndyCodeGenerationTest.java test/langtools/tools/javac/specialConstantFolding/IndyCrashTest.java test/langtools/tools/javac/specialConstantFolding/IndyLinkageErrorTest.java test/langtools/tools/javac/specialConstantFolding/IndyNegativeTest01.java test/langtools/tools/javac/specialConstantFolding/MultipleBSMEntriesTest.java test/langtools/tools/javac/specialConstantFolding/ReportIncorrectMHForIndyTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/ConstantFoldingOfMethodTypeDiffContextsTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/EffectivelyFinalTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindConstructorTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindGetterTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindMethodWithGenericArgumentsTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindSetterTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticGetterTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticSetterTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticTest.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindVirtualTest01.java test/langtools/tools/javac/specialConstantFolding/harness/tests/FindVirtualTest02.java
diffstat 25 files changed, 236 insertions(+), 465 deletions(-) [+]
line wrap: on
line diff
--- a/make/CompileJavaModules.gmk	Tue Oct 17 14:20:47 2017 -0700
+++ b/make/CompileJavaModules.gmk	Tue Oct 17 17:40:22 2017 -0400
@@ -42,7 +42,7 @@
 
 ################################################################################
 
-java.base_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline
+java.base_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*,-java.lang.invoke' -XDstringConcat=inline
 java.base_COPY += .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties
 java.base_CLEAN += intrinsic.properties
 
--- a/src/java.base/share/classes/java/lang/invoke/ClassRef.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/ClassRef.java	Tue Oct 17 17:40:22 2017 -0400
@@ -27,9 +27,12 @@
 import java.lang.annotation.TrackableConstant;
 import java.lang.reflect.Array;
 import java.util.regex.Pattern;
+import java.util.stream.Stream;
 
 import sun.invoke.util.Wrapper;
 
+import static java.util.stream.Collectors.joining;
+
 /**
  * A descriptor for a {@linkplain Class} constant.
  */
@@ -88,6 +91,8 @@
 
     /**  ClassRef representing the class java.lang.invoke.VarHandle */
     @TrackableConstant public static final ClassRef CR_VarHandle = ClassRef.of("java.lang.invoke.VarHandle");
+    /**  ClassRef representing the class java.lang.invoke.MethodHandles */
+    @TrackableConstant public static final ClassRef CR_MethodHandles = ClassRef.of("java.lang.invoke.MethodHandles");
     /**  ClassRef representing the class java.lang.invoke.MethodHandle */
     @TrackableConstant public static final ClassRef CR_MethodHandle = ClassRef.of("java.lang.invoke.MethodHandle");
     /**  ClassRef representing the class java.lang.invoke.MethodType */
@@ -95,7 +100,7 @@
     /**  ClassRef representing the class java.lang.invoke.CallSite */
     @TrackableConstant public static final ClassRef CR_CallSite = ClassRef.of("java.lang.invoke.CallSite");
     /**  ClassRef representing the class java.lang.invoke.MethodHandles.Lookup */
-    @TrackableConstant public static final ClassRef CR_Lookup = ClassRef.of("java.lang.invoke.MethodHandles$Lookup");
+    @TrackableConstant public static final ClassRef CR_Lookup = CR_MethodHandles.inner("Lookup");
 
     /**  ClassRef representing the interface java.util.Collection */
     @TrackableConstant public static final ClassRef CR_Collection = ClassRef.of("java.util.Collection");
@@ -115,88 +120,6 @@
     }
 
     /**
-     * Create a {@code ClassRef} for the primitive type {@code int}
-     * @return the {@code ClassRef}
-     */
-    @TrackableConstant
-    public static ClassRef ofInt() {
-        return CR_int;
-    }
-
-    /**
-     * Create a {@code ClassRef} for the primitive type {@code long}
-     * @return the {@code ClassRef}
-     */
-    @TrackableConstant
-    public static ClassRef ofLong() {
-        return CR_long;
-    }
-
-    /**
-     * Create a {@code ClassRef} for the primitive type {@code short}
-     * @return the {@code ClassRef}
-     */
-    @TrackableConstant
-    public static ClassRef ofShort() {
-        return CR_short;
-    }
-
-    /**
-     * Create a {@code ClassRef} for the primitive type {@code char}
-     * @return the {@code ClassRef}
-     */
-    @TrackableConstant
-    public static ClassRef ofChar() {
-        return CR_char;
-    }
-
-    /**
-     * Create a {@code ClassRef} for the primitive type {@code byte}
-     * @return the {@code ClassRef}
-     */
-
-    @TrackableConstant
-    public static ClassRef ofByte() {
-        return CR_byte;
-    }
-
-    /**
-     * Create a {@code ClassRef} for the primitive type {@code float}
-     * @return the {@code ClassRef}
-     */
-    @TrackableConstant
-    public static ClassRef ofFloat() {
-        return CR_float;
-    }
-
-    /**
-     * Create a {@code ClassRef} for the primitive type {@code double}
-     * @return the {@code ClassRef}
-     */
-    @TrackableConstant
-    public static ClassRef ofDouble() {
-        return CR_double;
-    }
-
-    /**
-     * Create a {@code ClassRef} for the primitive type {@code boolean}
-     * @return the {@code ClassRef}
-     */
-    @TrackableConstant
-    public static ClassRef ofBoolean() {
-        return CR_boolean;
-    }
-
-    /**
-     * Create a {@code ClassRef} for the primitive type {@code void}
-     * @return the {@code ClassRef}
-     */
-    @TrackableConstant
-    public static ClassRef ofVoid() {
-        return CR_void;
-    }
-
-    /**
      * Create a {@linkplain ClassRef} from a live {@link Class} object
      *
      * @param clazz the {@code Class}
@@ -258,6 +181,32 @@
     }
 
     /**
+     * Create a {@linkplain ClassRef} describing an inner class of the
+     * non-array reference type described by this {@linkplain ClassRef}
+     */
+    @TrackableConstant
+    public ClassRef inner(String innerName) {
+        if (!descriptor.startsWith("L"))
+            throw new IllegalStateException("Outer class is not a non-array reference type");
+        return ClassRef.ofDescriptor(descriptor.substring(0, descriptor.length() - 1) + "$" + innerName + ";");
+    }
+
+    /**
+     * Create a {@linkplain ClassRef} describing an inner class of the
+     * non-array reference type described by this {@linkplain ClassRef}
+     */
+    @TrackableConstant
+    public ClassRef inner(String firstInnerName, String... moreInnerNames) {
+        if (!descriptor.startsWith("L"))
+            throw new IllegalStateException("Outer class is not a non-array reference type");
+        return moreInnerNames.length == 0
+               ? inner(firstInnerName)
+               : ClassRef.ofDescriptor(descriptor.substring(0, descriptor.length() - 1) + "$" + firstInnerName
+                                       + Stream.of(moreInnerNames).collect(joining("$", "$", "")) + ";");
+    }
+
+
+    /**
      * Returns whether this {@linkplain ClassRef}
      * describes an array type
      * @return whether this {@linkplain ClassRef}
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandleRef.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleRef.java	Tue Oct 17 17:40:22 2017 -0400
@@ -36,6 +36,7 @@
 import static java.lang.invoke.MethodHandleInfo.REF_newInvokeSpecial;
 import static java.lang.invoke.MethodHandleInfo.REF_putField;
 import static java.lang.invoke.MethodHandleInfo.REF_putStatic;
+import static java.lang.invoke.MethodHandleRef.Kind.STATIC;
 
 /**
  * A descriptor for a {@linkplain MethodHandle} constant.
@@ -48,18 +49,21 @@
                                                              ClassRef.of("java.lang.String"),
                                                              ClassRef.of("java.lang.Class") };
 
-    private enum Kind {
-        STATIC(REF_invokeStatic),
-        VIRTUAL(REF_invokeVirtual),
-        INTERFACE_VIRTUAL(REF_invokeInterface),
-        SPECIAL(REF_invokeSpecial),
-        CTOR(REF_newInvokeSpecial),
-        GETTER(REF_getField),
-        SETTER(REF_putField),
-        STATIC_GETTER(REF_getStatic),
-        STATIC_SETTER(REF_putStatic);
+    /**
+     * Kinds of method handle refs
+     */
+    public enum Kind {
+        @TrackableConstant STATIC(REF_invokeStatic),
+        @TrackableConstant VIRTUAL(REF_invokeVirtual),
+        @TrackableConstant INTERFACE_VIRTUAL(REF_invokeInterface),
+        @TrackableConstant SPECIAL(REF_invokeSpecial),
+        @TrackableConstant CONSTRUCTOR(REF_newInvokeSpecial),
+        @TrackableConstant GETTER(REF_getField),
+        @TrackableConstant SETTER(REF_putField),
+        @TrackableConstant STATIC_GETTER(REF_getStatic),
+        @TrackableConstant STATIC_SETTER(REF_putStatic);
 
-        final int refKind;
+        public final int refKind;
 
         Kind(int refKind) {
             this.refKind = refKind;
@@ -78,72 +82,57 @@
         this.type = type;
     }
 
-    // @@@ Consider special combinator: asIndyBootstrap, asCondyBootstrap, asWhizzyBootstrap
-
     /**
      * Return a {@code MethodHandleRef} corresponding to an
      * invocation of a static method
+     * @param kind One of: STATIC, VIRTUAL, INTERFACE_VIRTUAL, SPECIAL, CONSTRUCTOR
      * @param clazz the class containing the method
-     * @param name the name of the method
+     * @param name the name of the method (ignored if kind=CONSTRUCTOR)
      * @param type the method type of the method
      * @return the {@code MethodHandleRef}
      */
     @TrackableConstant
-    public static MethodHandleRef ofStatic(ClassRef clazz, String name, MethodTypeRef type) {
-        return new MethodHandleRef(Kind.STATIC, clazz, name, type);
+    public static MethodHandleRef of(Kind kind, ClassRef clazz, String name, MethodTypeRef type) {
+        switch (kind) {
+            case STATIC:
+            case VIRTUAL:
+            case INTERFACE_VIRTUAL:
+            case SPECIAL:
+                return new MethodHandleRef(kind, clazz, name, type);
+            case CONSTRUCTOR:
+                return new MethodHandleRef(kind, clazz, "<init>", type);
+            default:
+                throw new IllegalArgumentException(kind.toString());
+        }
     }
 
     /**
      * Return a {@code MethodHandleRef} corresponding to an
      * invocation of a static method
+     * @param kind One of: STATIC, VIRTUAL, INTERFACE_VIRTUAL, SPECIAL, CONSTRUCTOR
      * @param clazz the class containing the method
-     * @param name the name of the method
+     * @param name the name of the method (ignored if kind=CONSTRUCTOR)
      * @param descriptorString descriptor string of the method
      * @return the {@code MethodHandleRef}
      */
     @TrackableConstant
-    public static MethodHandleRef ofStatic(ClassRef clazz, String name, String descriptorString) {
-        return ofStatic(clazz, name, MethodTypeRef.ofDescriptor(descriptorString));
+    public static MethodHandleRef of(Kind kind, ClassRef clazz, String name, String descriptorString) {
+        return of(kind, clazz, name, MethodTypeRef.ofDescriptor(descriptorString));
     }
 
     /**
      * Return a {@code MethodHandleRef} corresponding to an
      * invocation of a static method
+     * @param kind One of: STATIC, VIRTUAL, INTERFACE_VIRTUAL, SPECIAL, CONSTRUCTOR
      * @param clazz the class containing the method
-     * @param name the name of the method
+     * @param name the name of the method (ignored if kind=CONSTRUCTOR)
      * @param returnType the return type of the method
      * @param paramTypes the parameter types of the method
      * @return the {@code MethodHandleRef}
      */
     @TrackableConstant
-    public static MethodHandleRef ofStatic(ClassRef clazz, String name, ClassRef returnType, ClassRef... paramTypes) {
-        return ofStatic(clazz, name, MethodTypeRef.of(returnType, paramTypes));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to an invokedynamic bootstrap,
-     * which is a static method whose leading arguments are {@code Lookup}, {@code String}, and {@code MethodType}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param type the method type of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofIndyBootstrap(ClassRef clazz, String name, MethodTypeRef type) {
-        return ofStatic(clazz, name, type.insertParameterTypes(0, INDY_BOOTSTRAP_ARGS));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to an invokedynamic bootstrap,
-     * which is a static method whose leading arguments are {@code Lookup}, {@code String}, and {@code MethodType}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param descriptorString the descriptor string of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofIndyBootstrap(ClassRef clazz, String name, String descriptorString) {
-        return ofIndyBootstrap(clazz, name, MethodTypeRef.ofDescriptor(descriptorString));
+    public static MethodHandleRef of(Kind kind, ClassRef clazz, String name, ClassRef returnType, ClassRef... paramTypes) {
+        return of(kind, clazz, name, MethodTypeRef.of(returnType, paramTypes));
     }
 
     /**
@@ -157,7 +146,7 @@
      */
     @TrackableConstant
     public static MethodHandleRef ofIndyBootstrap(ClassRef clazz, String name, ClassRef returnType, ClassRef... paramTypes) {
-        return ofIndyBootstrap(clazz, name, MethodTypeRef.of(returnType, paramTypes));
+        return of(STATIC, clazz, name, MethodTypeRef.of(returnType, paramTypes).insertParameterTypes(0, INDY_BOOTSTRAP_ARGS));
     }
 
     /**
@@ -165,197 +154,13 @@
      * which is a static method whose leading arguments are {@code Lookup}, {@code String}, and {@code Class}
      * @param clazz the class containing the method
      * @param name the name of the method
-     * @param type the method type of the method
-     * @return the {@code MethodHandleRef}
-     */
-
-    @TrackableConstant
-    public static MethodHandleRef ofCondyBootstrap(ClassRef clazz, String name, MethodTypeRef type) {
-        return ofStatic(clazz, name, type.insertParameterTypes(0, CONDY_BOOTSTRAP_ARGS));
-    }
-    /**
-     * Return a {@code MethodHandleRef} corresponding to a constantdynamic bootstrap,
-     * which is a static method whose leading arguments are {@code Lookup}, {@code String}, and {@code Class}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param descriptorString the descriptor string of the method
-     * @return the {@code MethodHandleRef}
-     */
-
-    @TrackableConstant
-    public static MethodHandleRef ofCondyBootstrap(ClassRef clazz, String name, String descriptorString) {
-        return ofCondyBootstrap(clazz, name, MethodTypeRef.ofDescriptor(descriptorString));
-    }
-    /**
-     * Return a {@code MethodHandleRef} corresponding to a constantdynamic bootstrap,
-     * which is a static method whose leading arguments are {@code Lookup}, {@code String}, and {@code Class}
-     * @param clazz the class containing the method
-     * @param name the name of the method
      * @param returnType the return type of the method
      * @param paramTypes the parameter types of the method
      * @return the {@code MethodHandleRef}
      */
     @TrackableConstant
     public static MethodHandleRef ofCondyBootstrap(ClassRef clazz, String name, ClassRef returnType, ClassRef... paramTypes) {
-        return ofCondyBootstrap(clazz, name, MethodTypeRef.of(returnType, paramTypes));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokevirtual}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param type the method type of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofVirtual(ClassRef clazz, String name, MethodTypeRef type) {
-        return new MethodHandleRef(Kind.VIRTUAL, clazz, name, type);
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokevirtual}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param descriptorString the descriptor string of the method
-     * @return the {@code MethodHandleRef}
-     */
-
-    @TrackableConstant
-    public static MethodHandleRef ofVirtual(ClassRef clazz, String name, String descriptorString) {
-        return ofVirtual(clazz, name, MethodTypeRef.ofDescriptor(descriptorString));
-    }
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokevirtual}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param returnType the return type of the method
-     * @param paramTypes the parameter types of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofVirtual(ClassRef clazz, String name, ClassRef returnType, ClassRef... paramTypes) {
-        return ofVirtual(clazz, name, MethodTypeRef.of(returnType, paramTypes));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokeinterface}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param type the method type of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofInterface(ClassRef clazz, String name, MethodTypeRef type) {
-        return new MethodHandleRef(Kind.INTERFACE_VIRTUAL, clazz, name, type);
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokeinterface}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param descriptorString the descriptor string of the method
-     * @return the {@code MethodHandleRef}
-     */
-
-    @TrackableConstant
-    public static MethodHandleRef ofInterface(ClassRef clazz, String name, String descriptorString) {
-        return ofInterface(clazz, name, MethodTypeRef.ofDescriptor(descriptorString));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokeinterface}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param returnType the return type of the method
-     * @param paramTypes the parameter types of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofInterface(ClassRef clazz, String name, ClassRef returnType, ClassRef... paramTypes) {
-        return ofInterface(clazz, name, MethodTypeRef.of(returnType, paramTypes));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokespecial}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param type the method type of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofSpecial(ClassRef clazz, String name, MethodTypeRef type) {
-        return new MethodHandleRef(Kind.SPECIAL, clazz, name, type);
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokespecial}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param descriptorString the descriptor string of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofSpecial(ClassRef clazz, String name, String descriptorString) {
-        return ofSpecial(clazz, name, MethodTypeRef.ofDescriptor(descriptorString));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a virtual method via {@code invokespecial}
-     * @param clazz the class containing the method
-     * @param name the name of the method
-     * @param returnType the return type of the method
-     * @param paramTypes the parameter types of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofSpecial(ClassRef clazz, String name, ClassRef returnType, ClassRef... paramTypes) {
-        return ofSpecial(clazz, name, MethodTypeRef.of(returnType, paramTypes));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a constructor
-     * @param clazz the class containing the method
-     * @param type the method type of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofConstructor(ClassRef clazz, MethodTypeRef type) {
-        return new MethodHandleRef(Kind.CTOR, clazz, "<init>", type);
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a constructor
-     * @param clazz the class containing the method
-     * @param descriptorString the descriptor string of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofConstructor(ClassRef clazz, String descriptorString) {
-        return ofConstructor(clazz, MethodTypeRef.ofDescriptor(descriptorString));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a constructor
-     * @param clazz the class containing the method
-     * @param returnType the return type of the method
-     * @param paramTypes the parameter types of the method
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofConstructor(ClassRef clazz, ClassRef returnType, ClassRef... paramTypes) {
-        return ofConstructor(clazz, MethodTypeRef.of(returnType, paramTypes));
+        return of(STATIC, clazz, name, MethodTypeRef.of(returnType, paramTypes).insertParameterTypes(0, CONDY_BOOTSTRAP_ARGS));
     }
 
     /**
@@ -367,47 +172,16 @@
      * @return the {@code MethodHandleRef}
      */
     @TrackableConstant
-    public static MethodHandleRef ofGetter(ClassRef clazz, String name, ClassRef type) {
-        return new MethodHandleRef(Kind.GETTER, clazz, name, MethodTypeRef.of(type, clazz));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of an instance field setter
-     * @param clazz the class containing the field
-     * @param name the name of the field
-     * @param type the type of the field
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofSetter(ClassRef clazz, String name, ClassRef type) {
-        return new MethodHandleRef(Kind.SETTER, clazz, name, MethodTypeRef.of(ClassRef.ofVoid(), clazz, type));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a static field getter
-     * @param clazz the class containing the field
-     * @param name the name of the field
-     * @param type the type of the field
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofStaticGetter(ClassRef clazz, String name, ClassRef type) {
-        return new MethodHandleRef(Kind.STATIC_GETTER, clazz, name, MethodTypeRef.of(type));
-    }
-
-    /**
-     * Return a {@code MethodHandleRef} corresponding to invocation
-     * of a static field setter
-     * @param clazz the class containing the field
-     * @param name the name of the field
-     * @param type the type of the field
-     * @return the {@code MethodHandleRef}
-     */
-    @TrackableConstant
-    public static MethodHandleRef ofStaticSetter(ClassRef clazz, String name, ClassRef type) {
-        return new MethodHandleRef(Kind.STATIC_SETTER, clazz, name, MethodTypeRef.of(ClassRef.ofVoid(), type));
+    public static MethodHandleRef ofField(Kind kind, ClassRef clazz, String name, ClassRef type) {
+        switch (kind) {
+            case GETTER: return new MethodHandleRef(Kind.GETTER, clazz, name, MethodTypeRef.of(type, clazz));
+            case SETTER:
+                return new MethodHandleRef(Kind.SETTER, clazz, name, MethodTypeRef.of(ClassRef.CR_void, clazz, type));
+            case STATIC_GETTER: return new MethodHandleRef(Kind.STATIC_GETTER, clazz, name, MethodTypeRef.of(type));
+            case STATIC_SETTER:
+                return new MethodHandleRef(Kind.STATIC_SETTER, clazz, name, MethodTypeRef.of(ClassRef.CR_void, type));
+            default: throw new IllegalArgumentException(kind.toString());
+        }
     }
 
     /**
@@ -423,7 +197,7 @@
             case VIRTUAL:
                 return lookup.findVirtual(owner.resolve(lookup), name, type.resolve(lookup));
             case SPECIAL: return lookup.findSpecial(owner.resolve(lookup), name, type.resolve(lookup), lookup.lookupClass());
-            case CTOR: return lookup.findConstructor(owner.resolve(lookup), type.resolve(lookup));
+            case CONSTRUCTOR: return lookup.findConstructor(owner.resolve(lookup), type.resolve(lookup));
             case GETTER: return lookup.findGetter(owner.resolve(lookup), name, type.resolve(lookup).returnType());
             case STATIC_GETTER: return lookup.findStaticGetter(owner.resolve(lookup), name, type.resolve(lookup).returnType());
             case SETTER: return lookup.findSetter(owner.resolve(lookup), name, type.resolve(lookup).parameterType(1));
--- a/test/jdk/java/lang/invoke/ConstablesTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/jdk/java/lang/invoke/ConstablesTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -38,6 +38,11 @@
 
 import org.testng.annotations.Test;
 
+import static java.lang.invoke.ClassRef.*;
+import static java.lang.invoke.MethodHandleRef.Kind.GETTER;
+import static java.lang.invoke.MethodHandleRef.Kind.SETTER;
+import static java.lang.invoke.MethodHandleRef.Kind.STATIC_GETTER;
+import static java.lang.invoke.MethodHandleRef.Kind.STATIC_SETTER;
 import static java.util.stream.Collectors.joining;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
@@ -59,15 +64,15 @@
     public static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
 
     enum Primitives {
-        INT("I", "int", int.class, int[].class, ClassRef.ofInt()),
-        LONG("J", "long", long.class, long[].class, ClassRef.ofLong()),
-        SHORT("S", "short", short.class, short[].class, ClassRef.ofShort()),
-        BYTE("B", "byte", byte.class, byte[].class, ClassRef.ofByte()),
-        CHAR("C", "char", char.class, char[].class, ClassRef.ofChar()),
-        FLOAT("F", "float", float.class, float[].class, ClassRef.ofFloat()),
-        DOUBLE("D", "double", double.class, double[].class, ClassRef.ofDouble()),
-        BOOLEAN("Z", "boolean", boolean.class, boolean[].class, ClassRef.ofBoolean()),
-        VOID("V", "void", void.class, null, ClassRef.ofVoid());
+        INT("I", "int", int.class, int[].class, CR_int),
+        LONG("J", "long", long.class, long[].class, CR_long),
+        SHORT("S", "short", short.class, short[].class, CR_short),
+        BYTE("B", "byte", byte.class, byte[].class, CR_byte),
+        CHAR("C", "char", char.class, char[].class, CR_char),
+        FLOAT("F", "float", float.class, float[].class, CR_float),
+        DOUBLE("D", "double", double.class, double[].class, CR_double),
+        BOOLEAN("Z", "boolean", boolean.class, boolean[].class, CR_boolean),
+        VOID("V", "void", void.class, null, CR_void);
 
         public final String descriptor;
         public final String name;
@@ -277,18 +282,21 @@
     }
 
     public void testMethodHandleRef() throws Throwable {
-        ClassRef testClass = ClassRef.of("ConstablesTest$TestClass");
-        ClassRef testInterface = ClassRef.of("ConstablesTest$TestInterface");
+        ClassRef thisClass = ClassRef.of("ConstablesTest");
+        ClassRef testClass = thisClass.inner("TestClass");
+        ClassRef testInterface = thisClass.inner("TestInterface");
 
         // ctor
-        MethodHandleRef ctorRef = MethodHandleRef.ofConstructor(testClass, "()V");
-        MethodHandleRef staticMethodRef = MethodHandleRef.ofStatic(testClass, "sm", "(I)I");
-        MethodHandleRef instanceMethodRef = MethodHandleRef.ofVirtual(testClass, "m", "(I)I");
-        MethodHandleRef interfaceMethodRef = MethodHandleRef.ofInterface(testInterface, "im", "(I)I");
-        MethodHandleRef staticSetterRef = MethodHandleRef.ofStaticSetter(testClass, "sf", ClassRef.ofInt());
-        MethodHandleRef staticGetterRef = MethodHandleRef.ofStaticGetter(testClass, "sf", ClassRef.ofInt());
-        MethodHandleRef setterRef = MethodHandleRef.ofSetter(testClass, "f", ClassRef.ofInt());
-        MethodHandleRef getterRef = MethodHandleRef.ofGetter(testClass, "f", ClassRef.ofInt());
+        MethodHandleRef ctorRef = MethodHandleRef.of(MethodHandleRef.Kind.CONSTRUCTOR, testClass, "<ignored!>", MethodTypeRef.ofDescriptor("()V"));
+        MethodHandleRef staticMethodRef = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, testClass, "sm", "(I)I");
+        MethodHandleRef instanceMethodRef = MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, testClass, "m", MethodTypeRef.ofDescriptor("(I)I"));
+        MethodHandleRef interfaceMethodRef = MethodHandleRef.of(MethodHandleRef.Kind.INTERFACE_VIRTUAL, testInterface, "im", MethodTypeRef.ofDescriptor("(I)I"));
+        MethodHandleRef staticSetterRef = MethodHandleRef.ofField(STATIC_SETTER, testClass, "sf", ClassRef.CR_int);
+        MethodHandleRef staticGetterRef = MethodHandleRef.ofField(STATIC_GETTER, testClass, "sf", ClassRef.CR_int);
+        MethodHandleRef setterRef = MethodHandleRef.ofField(SETTER, testClass, "f", ClassRef.CR_int);
+        MethodHandleRef getterRef = MethodHandleRef.ofField(GETTER, testClass, "f", ClassRef.CR_int);
+        MethodHandleRef privateStaticMethod = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, thisClass, "privateStaticMethod", "(I)I");
+        MethodHandleRef privateInstanceMethod = MethodHandleRef.of(MethodHandleRef.Kind.SPECIAL, thisClass, "privateMethod", "(I)I");
 
         TestClass instance = (TestClass) ctorRef.resolve(LOOKUP).invoke();
         assertTrue(instance instanceof TestClass);
@@ -305,15 +313,18 @@
 
         assertEquals(instance.f, 7);
         assertEquals(TestClass.sf, 6);
+
+        assertEquals(9, privateStaticMethod.resolve(LOOKUP).invoke(9));
+        assertEquals(10, privateInstanceMethod.resolve(LOOKUP).invoke(this, 10));
     }
 
     public void testVarHandles() throws ReflectiveOperationException {
-        ClassRef testClass = ClassRef.of("ConstablesTest$TestClass");
+        ClassRef testClass = ClassRef.of("ConstablesTest").inner("TestClass");
         TestClass instance = new TestClass();
         int[] ints = new int[3];
 
         // static varHandle
-        DynamicConstantRef<VarHandle> vhc = (DynamicConstantRef<VarHandle>) ConstantRef.staticFieldVarHandle(testClass, "sf", ClassRef.ofInt());
+        DynamicConstantRef<VarHandle> vhc = (DynamicConstantRef<VarHandle>) ConstantRef.staticFieldVarHandle(testClass, "sf", ClassRef.CR_int);
         MethodTypeRef methodTypeRef = vhc.bootstrapMethod().type();
         System.out.println(vhc.name() + " " + methodTypeRef.returnType() + " " + methodTypeRef.parameterList());
         VarHandle varHandle = vhc.resolve(LOOKUP);
@@ -323,14 +334,14 @@
         assertEquals(TestClass.sf, 8);
 
         // static varHandle
-        vhc = (DynamicConstantRef<VarHandle>) ConstantRef.fieldVarHandle(testClass, "f", ClassRef.ofInt());
+        vhc = (DynamicConstantRef<VarHandle>) ConstantRef.fieldVarHandle(testClass, "f", ClassRef.CR_int);
         varHandle = vhc.resolve(LOOKUP);
         assertEquals(varHandle.varType(), int.class);
         varHandle.set(instance, 9);
         assertEquals(9, (int) varHandle.get(instance));
         assertEquals(instance.f, 9);
 
-        vhc = (DynamicConstantRef<VarHandle>) ConstantRef.arrayVarHandle(ClassRef.ofInt().array());
+        vhc = (DynamicConstantRef<VarHandle>) ConstantRef.arrayVarHandle(ClassRef.CR_int.array());
         varHandle = vhc.resolve(LOOKUP);
         varHandle.set(ints, 0, 1);
         varHandle.set(ints, 1, 2);
@@ -363,22 +374,22 @@
 //        assertEquals(String[].class, Intrinsics.ldc(ClassRef.of(String[].class)));
 
         assertEquals(int.class, Intrinsics.ldc(ClassRef.ofDescriptor("I")));
-        assertEquals(int.class, Intrinsics.ldc(ClassRef.ofInt()));
+        assertEquals(int.class, Intrinsics.ldc(ClassRef.CR_int));
 //        assertEquals(int.class, Intrinsics.ldc(ClassRef.of(int.class)));
 
         assertEquals(int[].class, Intrinsics.ldc(ClassRef.ofDescriptor("[I")));
-        assertEquals(int[].class, Intrinsics.ldc(ClassRef.ofInt().array()));
+        assertEquals(int[].class, Intrinsics.ldc(ClassRef.CR_int.array()));
 //        assertEquals(int[].class, Intrinsics.ldc(ClassRef.of(int.class).arrayOf()));
     }
 
     public void testLdcMethodType() {
         assertEquals(MethodType.methodType(void.class), Intrinsics.ldc(MethodTypeRef.ofDescriptor("()V")));
-        assertEquals(MethodType.methodType(void.class), Intrinsics.ldc(MethodTypeRef.of(ClassRef.ofVoid())));
+        assertEquals(MethodType.methodType(void.class), Intrinsics.ldc(MethodTypeRef.of(ClassRef.CR_void)));
 
         assertEquals(MethodType.methodType(int.class, int.class),
                      Intrinsics.ldc(MethodTypeRef.ofDescriptor("(I)I")));
         assertEquals(MethodType.methodType(int.class, int.class),
-                     Intrinsics.ldc(MethodTypeRef.of(ClassRef.ofInt(), ClassRef.ofInt())));
+                     Intrinsics.ldc(MethodTypeRef.of(ClassRef.CR_int, ClassRef.CR_int)));
 
         assertEquals(MethodType.methodType(String.class, String.class),
                      Intrinsics.ldc(MethodTypeRef.ofDescriptor("(Ljava/lang/String;)Ljava/lang/String;")));
@@ -392,34 +403,47 @@
     public void testLdcMethodHandle() throws Throwable {
         ClassRef CLASS_STRING = ClassRef.of("java.lang.String");
         ClassRef CLASS_OBJECT = ClassRef.of("java.lang.Object");
-        ClassRef CLASS_INT = ClassRef.ofInt();
-        ClassRef CLASS_HELPER = ClassRef.of("ConstablesTest$TestClass");
-        ClassRef CLASS_HELPER_INTF = ClassRef.of("ConstablesTest$TestInterface");
+        ClassRef CLASS_INT = ClassRef.CR_int;
+        ClassRef CLASS_THIS = ClassRef.of("ConstablesTest");
+        ClassRef CLASS_HELPER = CLASS_THIS.inner("TestClass");
+        ClassRef CLASS_HELPER_INNER = CLASS_THIS.inner("TestClass", "Inner");
+        ClassRef CLASS_HELPER_INTF = CLASS_THIS.inner("TestInterface");
 
-        assertEquals("3", Intrinsics.ldc(MethodHandleRef.ofStatic(CLASS_STRING, "valueOf", CLASS_STRING, CLASS_OBJECT))
+        assertEquals("3", Intrinsics.ldc(MethodHandleRef.of(MethodHandleRef.Kind.STATIC, CLASS_STRING, "valueOf", CLASS_STRING, CLASS_OBJECT))
                                     .invoke(Integer.valueOf(3)));
 
-        assertEquals("foobar", Intrinsics.ldc(MethodHandleRef.ofVirtual(CLASS_STRING, "concat", CLASS_STRING, CLASS_STRING))
+        assertEquals("foobar", Intrinsics.ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, CLASS_STRING, "concat", MethodTypeRef.of(CLASS_STRING, CLASS_STRING)))
                                          .invoke("foo", "bar"));
 
-        TestClass h = (TestClass) Intrinsics.ldc(MethodHandleRef.ofConstructor(CLASS_HELPER, ClassRef.ofVoid()))
+        TestClass h = (TestClass) Intrinsics.ldc(MethodHandleRef.of(MethodHandleRef.Kind.CONSTRUCTOR, CLASS_HELPER, "<init>", MethodTypeRef.of(ClassRef.CR_void)))
                                             .invoke();
         assertTrue(h instanceof TestClass);
 
-        assertEquals(2, Intrinsics.ldc(MethodHandleRef.ofInterface(CLASS_HELPER_INTF, "im", CLASS_INT, CLASS_INT))
+        assertEquals(2, Intrinsics.ldc(MethodHandleRef.of(MethodHandleRef.Kind.INTERFACE_VIRTUAL, CLASS_HELPER_INTF, "im", MethodTypeRef.of(CLASS_INT, CLASS_INT)))
                                   .invoke(h, 2));
 
-        Intrinsics.ldc(MethodHandleRef.ofStaticSetter(CLASS_HELPER, "sf", CLASS_INT))
+        Intrinsics.ldc(MethodHandleRef.ofField(STATIC_SETTER, CLASS_HELPER, "sf", CLASS_INT))
                   .invoke(3);
         assertEquals(3, TestClass.sf);
-        assertEquals(3, (int) Intrinsics.ldc(MethodHandleRef.ofStaticGetter(CLASS_HELPER, "sf", CLASS_INT))
+        assertEquals(3, (int) Intrinsics.ldc(MethodHandleRef.ofField(STATIC_GETTER, CLASS_HELPER, "sf", CLASS_INT))
                                         .invoke());
 
-        Intrinsics.ldc(MethodHandleRef.ofSetter(CLASS_HELPER, "f", CLASS_INT))
+        Intrinsics.ldc(MethodHandleRef.ofField(SETTER, CLASS_HELPER, "f", CLASS_INT))
                   .invoke(h, 4);
         assertEquals(4, h.f);
-        assertEquals(4, (int) Intrinsics.ldc(MethodHandleRef.ofGetter(CLASS_HELPER, "f", CLASS_INT))
+        assertEquals(4, (int) Intrinsics.ldc(MethodHandleRef.ofField(GETTER, CLASS_HELPER, "f", CLASS_INT))
                                         .invoke(h));
+
+        assertEquals(9, (int) Intrinsics.ldc(MethodHandleRef.of(MethodHandleRef.Kind.STATIC, CLASS_THIS, "privateStaticMethod", "(I)I")).invoke(9));
+        assertEquals(10, (int) Intrinsics.ldc(MethodHandleRef.of(MethodHandleRef.Kind.SPECIAL, CLASS_THIS, "privateMethod", "(I)I")).invoke(this, 10));
+
+        Intrinsics.ldc(MethodHandleRef.ofField(STATIC_SETTER, CLASS_HELPER_INNER, "innerField", CLASS_INT))
+                  .invoke(12);
+        assertEquals(12, TestClass.Inner.innerField);
+        assertEquals(12, (int) Intrinsics.ldc(MethodHandleRef.ofField(STATIC_GETTER, CLASS_HELPER_INNER, "innerField", CLASS_INT))
+                                         .invoke());
+
+
     }
 
 
@@ -428,11 +452,23 @@
         return MethodType.methodType(clazz).toMethodDescriptorString().substring(2);
     }
 
+    private static int privateStaticMethod(int i) {
+        return i;
+    }
+
+    private int privateMethod(int i) {
+        return i;
+    }
+
     private static interface TestInterface {
         public int im(int x);
     }
 
     private static class TestClass implements TestInterface {
+        private static class Inner {
+            static int innerField;
+        }
+
         static int sf;
         int f;
 
--- a/test/jdk/java/lang/invoke/IntrinsicsTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/jdk/java/lang/invoke/IntrinsicsTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -52,7 +52,7 @@
  */
 @Test
 public class IntrinsicsTest {
-    static final ClassRef HELPER_CLASS = ClassRef.of("IntrinsicsTest$IntrinsicTestHelper");
+    static final ClassRef HELPER_CLASS = ClassRef.of("IntrinsicsTest").inner("IntrinsicTestHelper");
 
     static final ClassRef staticField = ClassRef.of("java.lang.String");
     final ClassRef instanceField = ClassRef.of("java.lang.String");
@@ -144,8 +144,8 @@
     }
 
     public void testMethodHandleCombinators() {
-        MethodHandleRef mhc = MethodHandleRef.ofStatic(ClassRef.CR_String, "valueOf",
-                                                       MethodTypeRef.of(ClassRef.CR_String, ClassRef.CR_Object));
+        MethodHandleRef mhc = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.CR_String, "valueOf",
+                                                 MethodTypeRef.of(ClassRef.CR_String, ClassRef.CR_Object));
         assertEquals(MethodType.methodType(String.class, Object.class),
                      Intrinsics.ldc(mhc.type()));
         assertEquals(String.class, Intrinsics.ldc(mhc.type().returnType()));
@@ -153,8 +153,8 @@
     }
 
     public void testInterfaceSpecial() throws Throwable {
-        MethodHandleRef mhr = MethodHandleRef.ofStatic(ClassRef.CR_List,
-                                                       "of", MethodTypeRef.of(ClassRef.CR_List, ClassRef.CR_Object.array()));
+        MethodHandleRef mhr = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.CR_List, "of",
+                                                 MethodTypeRef.of(ClassRef.CR_List, ClassRef.CR_Object.array()));
         MethodHandle mh = Intrinsics.ldc(mhr);
         assertEquals(List.of("a", "b"), (List<String>) mh.invoke("a", "b"));
     }
--- a/test/langtools/tools/javac/specialConstantFolding/CondyCodeGenerationTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/CondyCodeGenerationTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -41,6 +41,7 @@
 import java.util.StringJoiner;
 
 import static java.lang.invoke.Intrinsics.ldc;
+import static java.lang.invoke.MethodHandleRef.Kind.STATIC;
 
 public class CondyCodeGenerationTest {
     public static void main(String[] args) throws Throwable {
@@ -59,8 +60,8 @@
     String testNoStaticArgs() throws Throwable {
         MethodTypeRef methodTypeForMethodHandle = MethodTypeRef.of(
                 ClassRef.CR_String, ClassRef.CR_Lookup, ClassRef.CR_String, ClassRef.CR_Class);
-        MethodHandleRef mh = MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LCondyCodeGenerationTest;"),
-                                                      "testNoStaticArgsBSM", methodTypeForMethodHandle);
+        MethodHandleRef mh = MethodHandleRef.of(STATIC, ClassRef.ofDescriptor("LCondyCodeGenerationTest;"),
+                                                "testNoStaticArgsBSM", methodTypeForMethodHandle);
         BootstrapSpecifier bss = BootstrapSpecifier.of(mh);
         DynamicConstantRef<String> condyDescr = DynamicConstantRef.of(bss, "constant-name");
         return (String)ldc(condyDescr);
@@ -85,8 +86,8 @@
                 ClassRef.CR_String,
                 ClassRef.CR_MethodType,
                 ClassRef.CR_MethodHandle);
-        MethodHandleRef mh = MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LCondyCodeGenerationTest;"),
-                                                      "testWithStaticArgsBSM", methodTypeForMethodHandle);
+        MethodHandleRef mh = MethodHandleRef.of(STATIC, ClassRef.ofDescriptor("LCondyCodeGenerationTest;"),
+                                                "testWithStaticArgsBSM", methodTypeForMethodHandle);
         BootstrapSpecifier bss = BootstrapSpecifier.of(mh, 1, 2L, 3.0f, 4.0d,
                                                        ClassRef.CR_Number,
                                                        "something",
@@ -122,8 +123,8 @@
                 ClassRef.CR_Class
         );
         MethodHandleRef c_primitiveClassBSM_MH =
-                MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LCondyCodeGenerationTest;"),
-                                         "primitiveClassBSM", c_primitiveClassBSM_MT);
+                MethodHandleRef.of(STATIC, ClassRef.ofDescriptor("LCondyCodeGenerationTest;"),
+                                   "primitiveClassBSM", c_primitiveClassBSM_MT);
         BootstrapSpecifier bss0 = BootstrapSpecifier.of(c_primitiveClassBSM_MH);
         DynamicConstantRef<Class> c_primitiveClassBSM_CD = DynamicConstantRef.of(bss0, "I");
 
@@ -134,9 +135,8 @@
                 ClassRef.CR_Class,
                 ClassRef.CR_Class
         );
-        MethodHandleRef mh = MethodHandleRef.ofStatic(
-                ClassRef.ofDescriptor("LCondyCodeGenerationTest;"),
-                "testWithNestedArgBSM", methodTypeForMethodHandle);
+        MethodHandleRef mh = MethodHandleRef.of(STATIC, ClassRef.ofDescriptor("LCondyCodeGenerationTest;"),
+                                                "testWithNestedArgBSM", methodTypeForMethodHandle);
         BootstrapSpecifier bss = BootstrapSpecifier.of(mh, c_primitiveClassBSM_CD);
 
         DynamicConstantRef<String> condyDescr = DynamicConstantRef.of(bss, "constant-name");
--- a/test/langtools/tools/javac/specialConstantFolding/DontCompileIfSymbolCantBeFoundTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/DontCompileIfSymbolCantBeFoundTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -8,17 +8,21 @@
 import java.lang.invoke.*;
 
 import static java.lang.invoke.Intrinsics.*;
+import static java.lang.invoke.MethodHandleRef.Kind.GETTER;
+import static java.lang.invoke.MethodHandleRef.Kind.SETTER;
+import static java.lang.invoke.MethodHandleRef.Kind.STATIC_GETTER;
+import static java.lang.invoke.MethodHandleRef.Kind.STATIC_SETTER;
 
 public class DontCompileIfSymbolCantBeFoundTest {
     void test() {
-        final MethodHandle mhVirtual = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchMethod", "()Ljava/lang/String;"));
-        final MethodHandle mhStatic = ldc(MethodHandleRef.ofStatic(ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchMethod", "()Ljava/lang/String;"));
+        final MethodHandle mhVirtual = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchMethod", MethodTypeRef.ofDescriptor("()Ljava/lang/String;")));
+        final MethodHandle mhStatic = ldc(MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchMethod", "()Ljava/lang/String;"));
         final MethodHandle mhSpecial = ldc(MethodHandleRef.ofSpecial(ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchMethod", MethodTypeRef.ofDescriptor("()Ljava/lang/String;"), ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest")));
 
-        final MethodHandle mhStaticSetter = ldc(MethodHandleRef.ofStaticSetter(ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchField", ClassRef.CR_String));
-        final MethodHandle mhSetter = ldc(MethodHandleRef.ofSetter(ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchField", ClassRef.CR_String));
-        final MethodHandle mhGetter = ldc(MethodHandleRef.ofGetter(ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchField", ClassRef.CR_String));
-        final MethodHandle mhStaticGetter = ldc(MethodHandleRef.ofStaticGetter(ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchField", ClassRef.CR_String));
+        final MethodHandle mhStaticSetter = ldc(MethodHandleRef.ofField(STATIC_SETTER, ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchField", ClassRef.CR_String));
+        final MethodHandle mhSetter = ldc(MethodHandleRef.ofField(SETTER, ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchField", ClassRef.CR_String));
+        final MethodHandle mhGetter = ldc(MethodHandleRef.ofField(GETTER, ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchField", ClassRef.CR_String));
+        final MethodHandle mhStaticGetter = ldc(MethodHandleRef.ofField(STATIC_GETTER, ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), "noSuchField", ClassRef.CR_String));
 
         final MethodHandle mhNewFindConstructorTest = ldc(MethodHandleRef.ofConstructor(ClassRef.ofDescriptor("DontCompileIfSymbolCantBeFoundTest"), VOID, ClassRef.CR_String));
     }
--- a/test/langtools/tools/javac/specialConstantFolding/EffectivelyFinalTestNeg.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/EffectivelyFinalTestNeg.java	Tue Oct 17 17:40:22 2017 -0400
@@ -30,7 +30,7 @@
         ClassRef c = ClassRef.CR_String;
         // you can't trust m1 as it depends on c1 which is not effectively final
         MethodTypeRef mt = MethodTypeRef.of(c);
-        MethodHandle mh = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LEffectivelyFinalTestNeg;"), "foo", mt));
+        MethodHandle mh = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LEffectivelyFinalTestNeg;"), "foo", mt));
         c = null;
     }
 
@@ -38,7 +38,7 @@
         ClassRef c = ClassRef.CR_String;
         // you can't trust m1 as it depends on c1 which is not effectively final
         MethodTypeRef mt = MethodTypeRef.of(c);
-        final MethodHandle mh = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LEffectivelyFinalTestNeg;"), "foo", mt));
+        final MethodHandle mh = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LEffectivelyFinalTestNeg;"), "foo", mt));
         c = null;
     }
 
@@ -48,7 +48,7 @@
         ClassRef c = ClassRef.CR_String;
         // you can't trust m1 as it depends on c1 which is not effectively final
         MethodTypeRef mt = MethodTypeRef.of(c);
-        MethodHandle mh = ldc(MethodHandleRef.ofVirtual(cField, "foo", mt));
+        MethodHandle mh = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, cField, "foo", mt));
         c = null;
     }
 }
--- a/test/langtools/tools/javac/specialConstantFolding/IndyCodeGenerationTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/IndyCodeGenerationTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -65,8 +65,8 @@
                 ClassRef.CR_MethodType,
                 ClassRef.CR_MethodHandle
         );
-        MethodHandleRef mh = MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LIndyCodeGenerationTest;"),
-                                                      "testWithStaticArgsBSM", methodTypeForMethodHandle);
+        MethodHandleRef mh = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("LIndyCodeGenerationTest;"),
+                                                "testWithStaticArgsBSM", methodTypeForMethodHandle);
         BootstrapSpecifier bs = BootstrapSpecifier.of(mh,
                                                       1, 2L, 3.0f, 4.0d,
                                                       ClassRef.CR_int,
--- a/test/langtools/tools/javac/specialConstantFolding/IndyCrashTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/IndyCrashTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -21,7 +21,7 @@
     }
 
     public void testSimpleIndy() throws Throwable {
-        MethodHandleRef bsmMH = MethodHandleRef.ofStatic(HELPER_CLASS, "foo", "()Ljava/lang/invoke/CallSite;");
+        MethodHandleRef bsmMH = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, HELPER_CLASS, "foo", "()Ljava/lang/invoke/CallSite;");
         BootstrapSpecifier bsm = BootstrapSpecifier.of(bsmMH);
         String result = (String)Intrinsics.invokedynamic(bsm, "foo", MethodTypeRef.ofDescriptor("()Ljava/lang/String;"));
     }
--- a/test/langtools/tools/javac/specialConstantFolding/IndyLinkageErrorTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/IndyLinkageErrorTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -18,8 +18,8 @@
             ClassRef.CR_String,
             ClassRef.CR_Object.array()
         );
-        MethodHandleRef mh = MethodHandleRef.ofStatic(ClassRef.ofDescriptor("Ljava/lang/invoke/StringConcatFactory;"),
-                "makeConcatWithConstants", methodTypeForMethodHandle);
+        MethodHandleRef mh = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("Ljava/lang/invoke/StringConcatFactory;"),
+                                                "makeConcatWithConstants", methodTypeForMethodHandle);
         final String param = "" + '\u0001' + '\u0001';
         BootstrapSpecifier indyDescr = BootstrapSpecifier.of(mh, param);
         return (String)invokedynamic(indyDescr, "", x, y);
--- a/test/langtools/tools/javac/specialConstantFolding/IndyNegativeTest01.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/IndyNegativeTest01.java	Tue Oct 17 17:40:22 2017 -0400
@@ -18,8 +18,8 @@
             ClassRef.CR_String,
             ClassRef.CR_Object.array()
         );
-        MethodHandleRef mh = MethodHandleRef.ofStatic(ClassRef.ofDescriptor("Ljava/lang/invoke/StringConcatFactory;"),
-                "makeConcatWithConstants", methodTypeForMethodHandle);
+        MethodHandleRef mh = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("Ljava/lang/invoke/StringConcatFactory;"),
+                                                "makeConcatWithConstants", methodTypeForMethodHandle);
         final String param = "" + '\u0001' + '\u0001';
         BootstrapSpecifier indyDescr = BootstrapSpecifier.of(mh, param);
         // invokeName is not a constant
--- a/test/langtools/tools/javac/specialConstantFolding/MultipleBSMEntriesTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/MultipleBSMEntriesTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -44,11 +44,11 @@
     // library code starts
     static class MultiplyCallSite extends MutableCallSite {
         private static final MethodTypeRef TYPE =
-                MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/math/BigInteger;"), ClassRef.ofLong(), ClassRef.ofLong());
+                MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/math/BigInteger;"), ClassRef.CR_long, ClassRef.CR_long);
         private static final ClassRef ME = ClassRef.ofDescriptor("LMultipleBSMEntriesTest$MultiplyCallSite;");
 
-        private static final MethodHandle FAST = Intrinsics.ldc(MethodHandleRef.ofVirtual(ME, "fast", TYPE));
-        private static final MethodHandle SLOW = Intrinsics.ldc(MethodHandleRef.ofStatic(ME, "slow", TYPE));
+        private static final MethodHandle FAST = Intrinsics.ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ME, "fast", TYPE));
+        private static final MethodHandle SLOW = Intrinsics.ldc(MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ME, "slow", TYPE));
 
         MultiplyCallSite(MethodType type) {
             super(type);
@@ -71,8 +71,8 @@
     }
 
     public static final BootstrapSpecifier MULT = BootstrapSpecifier.of(
-            MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LMultipleBSMEntriesTest;"), "multiplyFactory",
-                                     ClassRef.CR_CallSite, ClassRef.CR_Lookup, ClassRef.CR_String, ClassRef.CR_MethodType));
+            MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("LMultipleBSMEntriesTest;"), "multiplyFactory",
+                               ClassRef.CR_CallSite, ClassRef.CR_Lookup, ClassRef.CR_String, ClassRef.CR_MethodType));
 
     public static CallSite multiplyFactory(MethodHandles.Lookup lookup, String name, MethodType type) {
         return new MultiplyCallSite(type);
--- a/test/langtools/tools/javac/specialConstantFolding/ReportIncorrectMHForIndyTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/ReportIncorrectMHForIndyTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -25,8 +25,8 @@
                 ClassRef.CR_String,
                 ClassRef.CR_Object.array()
         );
-        MethodHandleRef mh = MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LReportIncorrectMHForIndyTest;"),
-                "makeConcatWithConstants", methodTypeForMethodHandle);
+        MethodHandleRef mh = MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("LReportIncorrectMHForIndyTest;"),
+                                                "makeConcatWithConstants", methodTypeForMethodHandle);
         // should this call fail if the mh is incorrect?
         BootstrapSpecifier indyDescr = BootstrapSpecifier.of(mh);
         return "";
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/ConstantFoldingOfMethodTypeDiffContextsTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/ConstantFoldingOfMethodTypeDiffContextsTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -24,7 +24,7 @@
     void assignmentContext() {
         MethodType mt1 = ldc(MethodTypeRef.of(ClassRef.CR_String));
         MethodType mt2 = ldc(MethodTypeRef.of(ClassRef.CR_String, ClassRef.CR_int));
-        MethodType mt3 = ldc(MethodTypeRef.of(ClassRef.ofVoid(), ClassRef.CR_String, ClassRef.CR_int));
+        MethodType mt3 = ldc(MethodTypeRef.of(ClassRef.CR_void, ClassRef.CR_String, ClassRef.CR_int));
 //        MethodType mt4 = ldc(MethodTypeRef.of(VOID, MethodTypeRef.of(ClassRef.of("Ljava/lang/String;"), INT)));
         /*  if last argument of the method below is not null no effort is done to try to constant fold
          *  the method type
@@ -40,7 +40,7 @@
     void invocationContext1() {
         foo(ldc(MethodTypeRef.of(ClassRef.CR_String)));
         foo(ldc(MethodTypeRef.of(ClassRef.CR_String, ClassRef.CR_int)));
-        foo(ldc(MethodTypeRef.of(ClassRef.ofVoid(), ClassRef.CR_String, ClassRef.CR_int)));
+        foo(ldc(MethodTypeRef.of(ClassRef.CR_void, ClassRef.CR_String, ClassRef.CR_int)));
 //        foo(ldc(MethodTypeRef.of(VOID, MethodTypeRef.of(ClassRef.of("Ljava/lang/String;"), INT))));
         /*  if last argument of the method below is not null no effort is done to try to constant fold
          *  the method type
@@ -58,7 +58,7 @@
         foo(mt1);
         MethodType mt2 = ldc(MethodTypeRef.of(ClassRef.CR_String, ClassRef.CR_int));
         foo(mt2);
-        MethodType mt3 = ldc(MethodTypeRef.of(ClassRef.ofVoid(), ClassRef.CR_String, ClassRef.CR_int));
+        MethodType mt3 = ldc(MethodTypeRef.of(ClassRef.CR_void, ClassRef.CR_String, ClassRef.CR_int));
         foo(mt3);
 //        MethodType mt4 = ldc(MethodTypeRef.of(VOID, MethodTypeRef.of(ClassRef.of("Ljava/lang/String;"), INT)));
 //        foo(mt4);
@@ -77,7 +77,7 @@
     void castContext1() {
         Serializable s1 = (Serializable)ldc(MethodTypeRef.of(ClassRef.CR_String));
         Serializable s2 = (Serializable)ldc(MethodTypeRef.of(ClassRef.CR_String, ClassRef.CR_int));
-        Serializable s3 = (Serializable)ldc(MethodTypeRef.of(ClassRef.ofVoid(), ClassRef.CR_String, ClassRef.CR_int));
+        Serializable s3 = (Serializable)ldc(MethodTypeRef.of(ClassRef.CR_void, ClassRef.CR_String, ClassRef.CR_int));
 //        Serializable s4 = (Serializable)ldc(MethodTypeRef.of(VOID, MethodTypeRef.of(ClassRef.of("Ljava/lang/String;"), INT)));
         Serializable s5 = (Serializable)ldc(MethodTypeRef.ofDescriptor("()Ljava/lang/String;"));
     }
@@ -93,7 +93,7 @@
         Serializable s1 = (Serializable)m1;
         MethodType m2 = ldc(MethodTypeRef.of(ClassRef.CR_String, ClassRef.CR_int));
         Serializable s2 = (Serializable)m2;
-        MethodType m3 = ldc(MethodTypeRef.of(ClassRef.ofVoid(), ClassRef.CR_String, ClassRef.CR_int));
+        MethodType m3 = ldc(MethodTypeRef.of(ClassRef.CR_void, ClassRef.CR_String, ClassRef.CR_int));
         Serializable s3 = (Serializable)m3;
 //        MethodType m4 = ldc(MethodTypeRef.of(VOID, MethodTypeRef.of(ClassRef.of("Ljava/lang/String;"), INT)));
 //        Serializable s4 = (Serializable)m4;
@@ -109,7 +109,7 @@
     void cast_plus_invocationContext() {
         foo((MethodType)ldc(MethodTypeRef.of(ClassRef.CR_String)));
         foo((MethodType)ldc(MethodTypeRef.of(ClassRef.CR_String, ClassRef.CR_int)));
-        foo((MethodType)ldc(MethodTypeRef.of(ClassRef.ofVoid(), ClassRef.CR_String, ClassRef.CR_int)));
+        foo((MethodType)ldc(MethodTypeRef.of(ClassRef.CR_void, ClassRef.CR_String, ClassRef.CR_int)));
 //        foo((MethodType)ldc(MethodTypeRef.of(VOID, MethodTypeRef.of(ClassRef.of("Ljava/lang/String;"), INT))));
         /*  if last argument of the method below is not null no effort is done to try to constant fold
          *  the method type
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/EffectivelyFinalTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/EffectivelyFinalTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -36,7 +36,7 @@
     void test3(EffectivelyFinalTest f) throws Throwable {
         ClassRef c = ClassRef.ofDescriptor("Ljava/lang/String;");
         MethodTypeRef mt = MethodTypeRef.of(c);
-        MethodHandle mh = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LEffectivelyFinalTest;"), "foo", mt));
+        MethodHandle mh = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LEffectivelyFinalTest;"), "foo", mt));
         check(mh.invoke(f).toString().equals("invoking EffectivelyFinalTest.foo()"));
     }
 
@@ -44,7 +44,7 @@
     void test4(EffectivelyFinalTest f) throws Throwable {
         ClassRef c = ClassRef.ofDescriptor("Ljava/lang/String;");
         MethodTypeRef mt = MethodTypeRef.of(c);
-        final MethodHandle mh = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LEffectivelyFinalTest;"), "foo", mt));
+        final MethodHandle mh = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LEffectivelyFinalTest;"), "foo", mt));
         check(mh.invoke(f).toString().equals("invoking EffectivelyFinalTest.foo()"));
     }
 
@@ -54,7 +54,7 @@
     void test5(EffectivelyFinalTest f) throws Throwable {
         ClassRef c = ClassRef.ofDescriptor("Ljava/lang/String;");;
         MethodTypeRef mt = MethodTypeRef.of(c);
-        MethodHandle mh = ldc(MethodHandleRef.ofVirtual(cField, "foo", mt));
+        MethodHandle mh = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, cField, "foo", mt));
         check(mh.invoke(f).toString().equals("invoking EffectivelyFinalTest.foo()"));
     }
 }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindConstructorTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindConstructorTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -21,14 +21,16 @@
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_newInvokeSpecial"})
     void test1() throws Throwable {
-        final MethodHandle mhNewFindConstructorTest = ldc(MethodHandleRef.ofConstructor(ClassRef.ofDescriptor("LFindConstructorTest;"), ClassRef.ofVoid()));
+        final MethodHandle mhNewFindConstructorTest = ldc(MethodHandleRef.of(MethodHandleRef.Kind.CONSTRUCTOR, ClassRef.ofDescriptor("LFindConstructorTest;"), "<init>",
+                                                                             MethodTypeRef.of(ClassRef.CR_void)));
         FindConstructorTest foo = (FindConstructorTest) mhNewFindConstructorTest.invokeExact();
         check(foo.toString().equals("invoking FindConstructorTest.toString()"));
     }
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_newInvokeSpecial"})
     void test2() throws Throwable {
-        MethodHandle mhNewFindConstructorTest = ldc(MethodHandleRef.ofConstructor(ClassRef.ofDescriptor("LFindConstructorTest;"), ClassRef.ofVoid()));
+        MethodHandle mhNewFindConstructorTest = ldc(MethodHandleRef.of(MethodHandleRef.Kind.CONSTRUCTOR, ClassRef.ofDescriptor("LFindConstructorTest;"), "<init>",
+                                                                       MethodTypeRef.of(ClassRef.CR_void)));
         FindConstructorTest foo = (FindConstructorTest) mhNewFindConstructorTest.invokeExact();
         check(foo.toString().equals("invoking FindConstructorTest.toString()"));
     }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindGetterTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindGetterTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -3,6 +3,7 @@
 import java.lang.invoke.*;
 
 import static java.lang.invoke.Intrinsics.*;
+import static java.lang.invoke.MethodHandleRef.Kind.GETTER;
 
 public class FindGetterTest extends ConstantFoldingTest {
     String strField = "instance field";
@@ -18,13 +19,13 @@
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_getField"})
     void test1(FindGetterTest f) throws Throwable {
-        final MethodHandle mhInstanceGetter = ldc(MethodHandleRef.ofGetter(ClassRef.ofDescriptor("LFindGetterTest;"), "strField", ClassRef.ofDescriptor("Ljava/lang/String;")));
+        final MethodHandle mhInstanceGetter = ldc(MethodHandleRef.ofField(GETTER, ClassRef.ofDescriptor("LFindGetterTest;"), "strField", ClassRef.ofDescriptor("Ljava/lang/String;")));
         check(mhInstanceGetter.invoke(f).toString().equals("instance field"));
     }
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_getField"})
     void test2(FindGetterTest f) throws Throwable {
-        MethodHandle mhInstanceGetter = ldc(MethodHandleRef.ofGetter(ClassRef.ofDescriptor("LFindGetterTest;"), "strField", ClassRef.ofDescriptor("Ljava/lang/String;")));
+        MethodHandle mhInstanceGetter = ldc(MethodHandleRef.ofField(GETTER, ClassRef.ofDescriptor("LFindGetterTest;"), "strField", ClassRef.ofDescriptor("Ljava/lang/String;")));
         check(mhInstanceGetter.invoke(f).toString().equals("instance field"));
     }
 }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindMethodWithGenericArgumentsTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindMethodWithGenericArgumentsTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -10,7 +10,7 @@
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_invokeVirtual"})
     void test() {
-        MethodHandle mh2 = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LFindMethodWithGenericArgumentsTest;"),
-                "bar", ClassRef.ofVoid(), ClassRef.CR_List));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LFindMethodWithGenericArgumentsTest;"), "bar",
+                                                  MethodTypeRef.of(ClassRef.CR_void, ClassRef.CR_List)));
     }
 }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindSetterTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindSetterTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -3,6 +3,7 @@
 import java.lang.invoke.*;
 
 import static java.lang.invoke.Intrinsics.*;
+import static java.lang.invoke.MethodHandleRef.Kind.SETTER;
 
 public class FindSetterTest extends ConstantFoldingTest {
     String strField = "instance field";
@@ -17,7 +18,7 @@
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_putField"})
     void test1(FindSetterTest f) throws Throwable {
-        final MethodHandle mhSetter = ldc(MethodHandleRef.ofSetter(ClassRef.ofDescriptor("LFindSetterTest;"), "strField", ClassRef.CR_String));
+        final MethodHandle mhSetter = ldc(MethodHandleRef.ofField(SETTER, ClassRef.ofDescriptor("LFindSetterTest;"), "strField", ClassRef.CR_String));
         mhSetter.invoke(f, "new instance field value");
         check(f.strField.equals("new instance field value"));
     }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticGetterTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticGetterTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -3,6 +3,7 @@
 import java.lang.invoke.*;
 
 import static java.lang.invoke.Intrinsics.*;
+import static java.lang.invoke.MethodHandleRef.Kind.STATIC_GETTER;
 
 public class FindStaticGetterTest extends ConstantFoldingTest {
     static String staticStrField = "class field";
@@ -18,13 +19,13 @@
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_getStatic"})
     void test1() throws Throwable {
-        final MethodHandle mhStaticGetter = ldc(MethodHandleRef.ofStaticGetter(ClassRef.ofDescriptor("LFindStaticGetterTest;"), "staticStrField", ClassRef.CR_String));
+        final MethodHandle mhStaticGetter = ldc(MethodHandleRef.ofField(STATIC_GETTER, ClassRef.ofDescriptor("LFindStaticGetterTest;"), "staticStrField", ClassRef.CR_String));
         check(mhStaticGetter.invoke().toString().equals("class field"));
     }
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_getStatic"})
     void test2() throws Throwable {
-        MethodHandle mhStaticGetter = ldc(MethodHandleRef.ofStaticGetter(ClassRef.ofDescriptor("LFindStaticGetterTest;"), "staticStrField", ClassRef.CR_String));
+        MethodHandle mhStaticGetter = ldc(MethodHandleRef.ofField(STATIC_GETTER, ClassRef.ofDescriptor("LFindStaticGetterTest;"), "staticStrField", ClassRef.CR_String));
         check(mhStaticGetter.invoke().toString().equals("class field"));
     }
 }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticSetterTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticSetterTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -3,6 +3,7 @@
 import java.lang.invoke.*;
 
 import static java.lang.invoke.Intrinsics.*;
+import static java.lang.invoke.MethodHandleRef.Kind.STATIC_SETTER;
 
 public class FindStaticSetterTest extends ConstantFoldingTest {
     static String staticStrField = "class field";
@@ -18,14 +19,14 @@
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_putStatic"})
     void test1() throws Throwable {
-        final MethodHandle mhStaticSetter = ldc(MethodHandleRef.ofStaticSetter(ClassRef.ofDescriptor("LFindStaticSetterTest;"), "staticStrField", ClassRef.CR_String));
+        final MethodHandle mhStaticSetter = ldc(MethodHandleRef.ofField(STATIC_SETTER, ClassRef.ofDescriptor("LFindStaticSetterTest;"), "staticStrField", ClassRef.CR_String));
         mhStaticSetter.invoke("new class field value");
         check(FindStaticSetterTest.staticStrField.equals("new class field value"));
     }
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_putStatic"})
     void test2() throws Throwable {
-        MethodHandle mhStaticSetter = ldc(MethodHandleRef.ofStaticSetter(ClassRef.ofDescriptor("LFindStaticSetterTest;"), "staticStrField", ClassRef.CR_String));
+        MethodHandle mhStaticSetter = ldc(MethodHandleRef.ofField(STATIC_SETTER, ClassRef.ofDescriptor("LFindStaticSetterTest;"), "staticStrField", ClassRef.CR_String));
         mhStaticSetter.invoke("new class field value");
         check(FindStaticSetterTest.staticStrField.equals("new class field value"));
     }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticTest.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindStaticTest.java	Tue Oct 17 17:40:22 2017 -0400
@@ -22,20 +22,20 @@
     @InstructionInfo(bytecodePosition=13, values={"CONSTANT_MethodHandle_info", "REF_invokeStatic"})
     void test1() throws Throwable {
         final MethodTypeRef mt = MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"));
-        MethodHandle mh2 = ldc(MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LFindStaticTest;"), "foo", mt));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("LFindStaticTest;"), "foo", mt));
         check(mh2.invoke().toString().equals("invoking static method FindStaticTest.foo()"));
     }
 
     @InstructionInfo(bytecodePosition=13, values={"CONSTANT_MethodHandle_info", "REF_invokeStatic"})
     void test2() throws Throwable {
         MethodTypeRef mt = MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"));
-        MethodHandle mh2 = ldc(MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LFindStaticTest;"), "foo", mt));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("LFindStaticTest;"), "foo", mt));
         check(mh2.invoke().toString().equals("invoking static method FindStaticTest.foo()"));
     }
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_invokeStatic"})
     void test3() throws Throwable {
-        MethodHandle mh2 = ldc(MethodHandleRef.ofStatic(ClassRef.ofDescriptor("LFindStaticTest;"), "foo", MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"))));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.STATIC, ClassRef.ofDescriptor("LFindStaticTest;"), "foo", MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"))));
         check(mh2.invoke().toString().equals("invoking static method FindStaticTest.foo()"));
     }
 }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindVirtualTest01.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindVirtualTest01.java	Tue Oct 17 17:40:22 2017 -0400
@@ -31,7 +31,7 @@
     @InstructionInfo(bytecodePosition=13, values={"CONSTANT_MethodHandle_info", "REF_invokeVirtual"})
     void test1(FindVirtualTest01 f) throws Throwable {
         final MethodTypeRef mt = MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"));
-        MethodHandle mh2 = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LFindVirtualTest01;"), "foo", mt));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LFindVirtualTest01;"), "foo", mt));
         check(mh2.invoke(f).toString().equals("invoking method FindVirtualTest01.foo()"));
     }
 
@@ -39,7 +39,7 @@
     void test2(FindVirtualTest01 f) throws Throwable {
         final MethodTypeRef mt = MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"));
         final ClassRef fooClass = ClassRef.ofDescriptor("LFindVirtualTest01;");
-        MethodHandle mh2 = ldc(MethodHandleRef.ofVirtual(fooClass, "foo", mt));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, fooClass, "foo", mt));
         check(mh2.invoke(f).toString().equals("invoking method FindVirtualTest01.foo()"));
     }
 
@@ -47,26 +47,28 @@
     void test2_1(FindVirtualTest01 f) throws Throwable {
         final MethodTypeRef mt = MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"));
         final ClassRef fooClass = ClassRef.ofDescriptor("LFindVirtualTest01;");
-        MethodHandle mh2 = ldc(MethodHandleRef.ofVirtual(fooClass, "foo", mt));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, fooClass, "foo", mt));
         check(mh2.invoke(f).toString().equals("invoking method FindVirtualTest01.foo()"));
     }
 
     @InstructionInfo(bytecodePosition=13, values={"CONSTANT_MethodHandle_info", "REF_invokeVirtual"})
     void test3(FindVirtualTest01 f) throws Throwable {
         MethodTypeRef mt = MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"));
-        MethodHandle mh2 = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LFindVirtualTest01;"), "foo", mt));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LFindVirtualTest01;"), "foo", mt));
         check(mh2.invoke(f).toString().equals("invoking method FindVirtualTest01.foo()"));
     }
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_invokeVirtual"})
     void test4(FindVirtualTest01 f) throws Throwable {
-        MethodHandle mh2 = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LFindVirtualTest01;"), "foo", ClassRef.ofDescriptor("Ljava/lang/String;")));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LFindVirtualTest01;"), "foo",
+                                                  MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"))));
         check(mh2.invoke(f).toString().equals("invoking method FindVirtualTest01.foo()"));
     }
 
     @InstructionInfo(bytecodePosition=0, values={"CONSTANT_MethodHandle_info", "REF_invokeVirtual"})
     void test5(FindVirtualTest01 f) throws Throwable {
-        MethodHandle mhBar = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LFindVirtualTest01;"), "bar", ClassRef.ofDescriptor("Ljava/lang/String;"), ClassRef.ofInt()));
+        MethodHandle mhBar = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LFindVirtualTest01;"), "bar",
+                                                    MethodTypeRef.of(ClassRef.ofDescriptor("Ljava/lang/String;"), ClassRef.CR_int)));
         check(mhBar.invoke(f, 3).toString().equals("invoking method FindVirtualTest01.bar() with argument 3"));
     }
 }
--- a/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindVirtualTest02.java	Tue Oct 17 14:20:47 2017 -0700
+++ b/test/langtools/tools/javac/specialConstantFolding/harness/tests/FindVirtualTest02.java	Tue Oct 17 17:40:22 2017 -0400
@@ -23,7 +23,7 @@
     @InstructionInfo(bytecodePosition=6, values={"CONSTANT_MethodHandle_info", "REF_invokeVirtual"})
     void test1(Foo f) throws Throwable {
         final MethodTypeRef mt = MethodTypeRef.ofDescriptor("()Ljava/lang/String;");
-        MethodHandle mh2 = ldc(MethodHandleRef.ofVirtual(ClassRef.ofDescriptor("LFindVirtualTest02$Foo;"), "foo", mt));
+        MethodHandle mh2 = ldc(MethodHandleRef.of(MethodHandleRef.Kind.VIRTUAL, ClassRef.ofDescriptor("LFindVirtualTest02$Foo;"), "foo", mt));
         check(mh2.invoke(f).toString().equals("invoking method Foo.foo()"));
     }
 }