changeset 52751:0bcf1413c14f jep-334

Remove implements-Constable from XxxDesc lcasses, will come back when symbolic-mode BSMs are available
author briangoetz
date Mon, 01 Oct 2018 12:06:29 -0400
parents a748603468bb
children e8be92b72e89
files src/java.base/share/classes/java/lang/Enum.java src/java.base/share/classes/java/lang/constant/AsTypeMethodHandleDesc.java src/java.base/share/classes/java/lang/constant/ClassDesc.java src/java.base/share/classes/java/lang/constant/ConstantDescs.java src/java.base/share/classes/java/lang/constant/ConstantUtils.java src/java.base/share/classes/java/lang/constant/DirectMethodHandleDesc.java src/java.base/share/classes/java/lang/constant/DirectMethodHandleDescImpl.java src/java.base/share/classes/java/lang/constant/DynamicConstantDesc.java src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java src/java.base/share/classes/java/lang/constant/MethodTypeDescImpl.java src/java.base/share/classes/java/lang/constant/PrimitiveClassDescImpl.java src/java.base/share/classes/java/lang/constant/ReferenceClassDescImpl.java src/java.base/share/classes/java/lang/invoke/VarHandle.java test/jdk/java/lang/constant/SymbolicDescTest.java test/jdk/java/lang/constant/boottest/java.base/java/lang/constant/ConstantUtilsTest.java
diffstat 16 files changed, 13 insertions(+), 258 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Enum.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/Enum.java	Mon Oct 01 12:06:29 2018 -0400
@@ -32,14 +32,11 @@
 import java.io.Serializable;
 import java.lang.constant.ClassDesc;
 import java.lang.constant.Constable;
-import java.lang.constant.ConstantDesc;
 import java.lang.constant.ConstantDescs;
 import java.lang.constant.DynamicConstantDesc;
 import java.lang.invoke.MethodHandles;
 import java.util.Optional;
 
-import static java.lang.constant.ConstantDescs.BSM_INVOKE;
-import static java.lang.constant.ConstantDescs.MHR_ENUMDESC_FACTORY;
 import static java.util.Objects.requireNonNull;
 
 /**
@@ -313,23 +310,6 @@
             return new EnumDesc<>(enumClass, constantName);
         }
 
-        /**
-         * Return a nominal descriptor for the specified {@code enum} class and
-         * name, where the class is specified as a descriptor string.
-         *
-         * @param <E> the type of the enum constant
-         * @param enumClass a field descriptor string, as per JVMS 4.3.2,
-         *                  describing the {@code enum} class
-         * @param constantName the name of the enum constant, as per JVMS 4.2.2
-         * @return the nominal descriptor
-         * @throws NullPointerException if any argument is null
-         * @jvms 4.2.2 Unqualified Names
-         */
-        public static<E extends Enum<E>> EnumDesc<E> ofDescriptor(String enumClass,
-                                                                  String constantName) {
-            return EnumDesc.of(ClassDesc.ofDescriptor(enumClass), constantName);
-        }
-
         @Override
         @SuppressWarnings("unchecked")
         public E resolveConstantDesc(MethodHandles.Lookup lookup)
@@ -338,11 +318,6 @@
         }
 
         @Override
-        public Optional<? extends ConstantDesc<ConstantDesc<E>>> describeConstable() {
-            return Optional.of(DynamicConstantDesc.of(BSM_INVOKE, MHR_ENUMDESC_FACTORY, constantType().descriptorString(), constantName()));
-        }
-
-        @Override
         public String toString() {
             return String.format("EnumDesc[%s.%s]", constantType().displayName(), constantName());
         }
--- a/src/java.base/share/classes/java/lang/constant/AsTypeMethodHandleDesc.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/AsTypeMethodHandleDesc.java	Mon Oct 01 12:06:29 2018 -0400
@@ -27,7 +27,6 @@
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
-import java.util.Optional;
 
 import static java.lang.constant.ConstantDescs.BSM_INVOKE;
 import static java.lang.constant.ConstantDescs.CR_MethodHandle;
@@ -65,12 +64,6 @@
     }
 
     @Override
-    public Optional<? extends ConstantDesc<ConstantDesc<MethodHandle>>> describeConstable() {
-        return ConstantUtils.symbolizeHelper(ConstantDescs.MHR_METHODHANDLEDESC_ASTYPE, ConstantDescs.CR_MethodHandleDesc,
-                                             underlying, type);
-    }
-
-    @Override
     public String toString() {
         return  String.format("%s.asType%s", underlying.toString(), type.displayDescriptor());
     }
--- a/src/java.base/share/classes/java/lang/constant/ClassDesc.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/ClassDesc.java	Mon Oct 01 12:06:29 2018 -0400
@@ -24,7 +24,6 @@
  */
 package java.lang.constant;
 
-import java.lang.invoke.MethodHandles;
 import java.lang.invoke.TypeDescriptor;
 import java.util.stream.Stream;
 
@@ -58,7 +57,6 @@
  */
 public interface ClassDesc
         extends ConstantDesc<Class<?>>,
-                Constable<ConstantDesc<Class<?>>>,
                 TypeDescriptor.OfField<ClassDesc> {
 
     /**
--- a/src/java.base/share/classes/java/lang/constant/ConstantDescs.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/ConstantDescs.java	Mon Oct 01 12:06:29 2018 -0400
@@ -248,27 +248,14 @@
             = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_NULL_CONSTANT,
                                           DEFAULT_NAME, ConstantDescs.CR_Object);
 
-    // Used by XxxDesc classes, but need to be here to avoid bootstrap cycles
-    static final DirectMethodHandleDesc MHR_METHODTYPEDESC_FACTORY
-            = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_MethodTypeDesc, "ofDescriptor",
-                                  CR_MethodTypeDesc, CR_String);
-
     static final DirectMethodHandleDesc MHR_CLASSDESC_FACTORY
             = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_ClassDesc, "ofDescriptor",
                                   CR_ClassDesc, CR_String);
 
-    static final DirectMethodHandleDesc MHR_METHODHANDLEDESC_FACTORY
-            = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_DirectMethodHandleDesc, "ofDescriptor",
-                                  CR_DirectMethodHandleDesc, CR_String, CR_String, CR_String, CR_String);
-
     static final DirectMethodHandleDesc MHR_METHODHANDLE_ASTYPE
             = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.VIRTUAL, CR_MethodHandle, "asType",
                                   CR_MethodHandle, CR_MethodType);
 
-    static final DirectMethodHandleDesc MHR_METHODHANDLEDESC_ASTYPE
-            = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.VIRTUAL, CR_MethodHandleDesc, "asType",
-                                  CR_MethodHandleDesc, CR_MethodTypeDesc);
-
     static final DirectMethodHandleDesc MHR_DYNAMICCONSTANTDESC_FACTORY
             = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_DynamicConstantDesc, "of",
                                   CR_DynamicConstantDesc, CR_DirectMethodHandleDesc, CR_ConstantDesc.arrayType());
@@ -277,15 +264,11 @@
             = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_DynamicConstantDesc, "ofNamed",
                                   CR_DynamicConstantDesc, CR_DirectMethodHandleDesc, CR_String, CR_String, CR_ConstantDesc.arrayType());
 
-    /** {@link MethodHandleDesc} representing {@link EnumDesc#ofDescriptor(String, String)} */
-    public static final DirectMethodHandleDesc MHR_ENUMDESC_FACTORY
-            = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_EnumDesc, "ofDescriptor",
-                                  CR_EnumDesc, CR_String, CR_String);
-
     /** {@link MethodHandleDesc} representing {@link VarHandleDesc#ofField(ClassDesc, String, ClassDesc)} */
     public static final DirectMethodHandleDesc MHR_VARHANDLEDESC_OFFIELD
             = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_VarHandleDesc, "ofField",
                                   CR_VarHandleDesc, CR_ClassDesc, CR_String, CR_ClassDesc);
+
     /** {@link MethodHandleDesc} representing {@link VarHandleDesc#ofStaticField(ClassDesc, String, ClassDesc)} */
     public static final DirectMethodHandleDesc MHR_VARHANDLEDESC_OFSTATIC
             = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_VarHandleDesc, "ofStaticField",
@@ -296,17 +279,6 @@
             = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_VarHandleDesc, "ofArray",
                                   CR_VarHandleDesc, CR_ClassDesc);
 
-    static final DirectMethodHandleDesc BSM_METHODHANDLEDESC
-            = ConstantDescs.ofConstantBootstrap(CR_DirectMethodHandleDesc,
-                                                "constantBootstrap", CR_DirectMethodHandleDesc,
-                                                CR_String, CR_String, CR_String, CR_String);
-
-    static final DirectMethodHandleDesc BSM_DYNAMICCONSTANTDESC
-            = ConstantDescs.ofConstantBootstrap(CR_DynamicConstantDesc,
-                                                "constantBootstrap",
-                                                CR_DynamicConstantDesc,
-                                                CR_DirectMethodHandleDesc, CR_String, CR_String, CR_ConstantDesc.arrayType());
-
     /**
      * Return a {@link MethodHandleDesc} corresponding to a bootstrap method for
      * an {@code invokedynamic} callsite, which is a static method whose leading
--- a/src/java.base/share/classes/java/lang/constant/ConstantUtils.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/ConstantUtils.java	Mon Oct 01 12:06:29 2018 -0400
@@ -26,8 +26,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Optional;
 import java.util.Set;
 
 import static java.util.Objects.requireNonNull;
@@ -101,38 +99,6 @@
     }
 
     /**
-     * Produce an {@code Optional<DynamicConstantDesc<T>>} describing the invocation
-     * of the specified bootstrap with the specified arguments.  The arguments will
-     * be converted to nominal descriptors using the provided lookup.  Helper
-     * method for implementing {@link Constable#describeConstable()}.
-     *
-     * @param <T> the type of the resulting constant
-     * @param bootstrap nominal descriptor for the bootstrap method
-     * @param type nominal descriptor for the type of the resulting constant
-     * @param args nominal descriptors for the bootstrap arguments
-     * @return the nominal descriptor for the dynamic constant
-     */
-    public static<T> Optional<DynamicConstantDesc<T>> symbolizeHelper(MethodHandleDesc bootstrap,
-                                                                      ClassDesc type,
-                                                                      Constable<?>... args) {
-        requireNonNull(bootstrap);
-        requireNonNull(type);
-        requireNonNull(args);
-        try {
-            ConstantDesc<?>[] quotedArgs = new ConstantDesc<?>[args.length + 1];
-            quotedArgs[0] = bootstrap;
-            for (int i=0; i<args.length; i++)
-                quotedArgs[i+1] = args[i].describeConstable().orElseThrow();
-            return Optional.of(DynamicConstantDesc.ofNamed(ConstantDescs.BSM_INVOKE,
-                                                           ConstantDescs.DEFAULT_NAME,
-                                                           type, quotedArgs));
-        }
-        catch (NoSuchElementException e) {
-            return Optional.empty();
-        }
-    }
-
-    /**
      * Parse a method descriptor string, and return a list of field descriptor
      * strings, return type first, then parameter types
      *
--- a/src/java.base/share/classes/java/lang/constant/DirectMethodHandleDesc.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/DirectMethodHandleDesc.java	Mon Oct 01 12:06:29 2018 -0400
@@ -26,7 +26,6 @@
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandleInfo;
-import java.lang.invoke.MethodHandles;
 
 import static java.lang.invoke.MethodHandleInfo.REF_getField;
 import static java.lang.invoke.MethodHandleInfo.REF_getStatic;
@@ -135,30 +134,4 @@
      * @return the method type
      */
     MethodTypeDesc methodType();
-
-    /**
-     * Create a {@linkplain DirectMethodHandleDesc} given descriptor strings
-     * for its components.  Suitable for use as a constant bootstrap method
-     * for representing a {@linkplain DirectMethodHandleDesc} in the constant
-     * pool of a classfile.
-     *
-     * @param bsmKindName The name of an {@code enum} constant from {@link Kind}
-     * @param memberOwner A field type descriptor for the class declaring the
-     *                 method, field, or constructor, as per JVMS 4.3.2
-     * @param memberName The name of the method or field, as per JVMS 4.2.2
-     * @param memberType A method type descriptor for the method handle being
-     *                described, as per JVMS 4.3.3
-     * @return the {@linkplain MethodHandleDesc}
-     * @jvms 4.2.2 Unqualified Names
-     * @jvms 4.3.2 Field Descriptors
-     * @jvms 4.3.3 Method Descriptors
-     */
-    static DirectMethodHandleDesc ofDescriptor(String bsmKindName,
-                                               String memberOwner,
-                                               String memberName,
-                                               String memberType) {
-        return MethodHandleDesc.of(Kind.valueOf(bsmKindName),
-                                   ClassDesc.ofDescriptor(memberOwner), memberName,
-                                   MethodTypeDesc.ofDescriptor(memberType));
-    }
 }
--- a/src/java.base/share/classes/java/lang/constant/DirectMethodHandleDescImpl.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/DirectMethodHandleDescImpl.java	Mon Oct 01 12:06:29 2018 -0400
@@ -28,14 +28,7 @@
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.util.Objects;
-import java.util.Optional;
 
-import static java.lang.constant.ConstantDescs.BSM_INVOKE;
-import static java.lang.constant.ConstantDescs.BSM_METHODHANDLEDESC;
-import static java.lang.constant.ConstantDescs.CR_DirectMethodHandleDesc;
-import static java.lang.constant.ConstantDescs.DEFAULT_NAME;
-import static java.lang.constant.ConstantDescs.MHR_METHODHANDLEDESC_FACTORY;
-import static java.lang.constant.ConstantDescs.MHR_METHODTYPEDESC_FACTORY;
 import static java.lang.constant.ConstantUtils.validateClassOrInterface;
 import static java.lang.constant.ConstantUtils.validateMemberName;
 import static java.lang.constant.DirectMethodHandleDesc.Kind.CONSTRUCTOR;
@@ -164,15 +157,6 @@
     }
 
     @Override
-    public Optional<? extends ConstantDesc<ConstantDesc<MethodHandle>>> describeConstable() {
-        return Optional.of(DynamicConstantDesc.of(BSM_INVOKE, MHR_METHODHANDLEDESC_FACTORY,
-                                                  kind.toString(),
-                                                  owner.descriptorString(),
-                                                  name,
-                                                  type.descriptorString()));
-    }
-
-    @Override
     public boolean equals(Object o) {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
--- a/src/java.base/share/classes/java/lang/constant/DynamicConstantDesc.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/DynamicConstantDesc.java	Mon Oct 01 12:06:29 2018 -0400
@@ -33,17 +33,12 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Optional;
 import java.util.function.Function;
 import java.util.stream.Stream;
 
-import static java.lang.constant.ConstantDescs.BSM_DYNAMICCONSTANTDESC;
-import static java.lang.constant.ConstantDescs.BSM_INVOKE;
 import static java.lang.constant.ConstantDescs.CR_Class;
 import static java.lang.constant.ConstantDescs.CR_VarHandle;
 import static java.lang.constant.ConstantDescs.DEFAULT_NAME;
-import static java.lang.constant.ConstantDescs.MHR_DYNAMICCONSTANTDESC_FACTORY;
-import static java.lang.constant.ConstantDescs.MHR_DYNAMICCONSTANTDESC_NAMED_FACTORY;
 import static java.lang.constant.ConstantUtils.EMPTY_CONSTANTDESC;
 import static java.lang.constant.ConstantUtils.validateMemberName;
 import static java.util.Objects.requireNonNull;
@@ -60,7 +55,7 @@
  * @param <T> the type of the dynamic constant
  */
 public abstract class DynamicConstantDesc<T>
-        implements ConstantDesc<T>, Constable<ConstantDesc<T>> {
+        implements ConstantDesc<T> {
 
     private final DirectMethodHandleDesc bootstrapMethod;
     private final ConstantDesc<?>[] bootstrapArgs;
@@ -180,35 +175,6 @@
     }
 
     /**
-     * Return a nominal descriptor for a dynamic constant.
-     *
-     * @param <T> the type of the dynamic constant
-     * @param bootstrapMethod a {@link DirectMethodHandleDescImpl} describing the
-     *                        bootstrap method for the constant
-     * @param constantName The name that would appear in the {@code NameAndType}
-     *                     operand of the {@code LDC} for this constant, as per
-     *                     JVMS 4.2.2
-     * @param constantTypeDescriptor a field descriptor string for the type
-     *                     that would appear in the {@code NameAndType} operand
-     *                     of the {@code LDC} for this constant
-     * @param bootstrapArgs {@link ConstantDesc}s describing the static arguments
-     *                      to the bootstrap, that would appear in the
-     *                      {@code BootstrapMethods} attribute
-     * @return the nominal descriptor
-     * @throws NullPointerException if any argument is null
-     * @throws IllegalArgumentException if the {@code name} has the incorrect
-     * format
-     * @jvms 4.2.2 Unqualified Names
-     */
-
-    public static<T> DynamicConstantDesc<T> ofNamed(DirectMethodHandleDesc bootstrapMethod,
-                                                    String constantName,
-                                                    String constantTypeDescriptor,
-                                                    ConstantDesc<?>... bootstrapArgs) {
-        return ofNamed(bootstrapMethod, constantName, ClassDesc.ofDescriptor(constantTypeDescriptor), bootstrapArgs);
-    }
-
-    /**
      * Return a nominal descriptor for a dynamic constant whose name parameter
      * is {@link ConstantDescs#DEFAULT_NAME}, and whose type parameter is always
      * the same as the bootstrap method return type.
@@ -319,28 +285,6 @@
         }
     }
 
-    @Override
-    public Optional<? extends ConstantDesc<ConstantDesc<T>>> describeConstable() {
-        ConstantDesc<?>[] args;
-        if (constantName.equals(DEFAULT_NAME) && constantType.equals(bootstrapMethod.methodType().returnType())) {
-            args = new ConstantDesc<?>[bootstrapArgs.length + 2];
-            args[0] = MHR_DYNAMICCONSTANTDESC_FACTORY;
-            args[1] = bootstrapMethod.describeConstable().orElseThrow();
-            for (int i = 0; i < bootstrapArgs.length; i++)
-                args[i + 2] = (ConstantDesc<?>) ((Constable) bootstrapArgs[i]).describeConstable().orElseThrow();
-        }
-        else {
-            args = new ConstantDesc<?>[bootstrapArgs.length + 4];
-            args[0] = MHR_DYNAMICCONSTANTDESC_NAMED_FACTORY;
-            args[1] = bootstrapMethod.describeConstable().orElseThrow();
-            args[2] = constantName;
-            args[3] = constantType().descriptorString();
-            for (int i = 0; i < bootstrapArgs.length; i++)
-                args[i + 4] = (ConstantDesc<?>) ((Constable) bootstrapArgs[i]).describeConstable().orElseThrow();
-        }
-        return Optional.of(DynamicConstantDesc.of(BSM_INVOKE, args));
-    }
-
     private ConstantDesc<T> tryCanonicalize() {
         Function<DynamicConstantDesc<?>, ConstantDesc<?>> f = canonicalMap.get(bootstrapMethod);
         if (f != null) {
--- a/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java	Mon Oct 01 12:06:29 2018 -0400
@@ -40,7 +40,7 @@
  * {@linkplain MethodHandleDesc} directly.
  */
 public interface MethodHandleDesc
-        extends ConstantDesc<MethodHandle>, Constable<ConstantDesc<MethodHandle>> {
+        extends ConstantDesc<MethodHandle> {
 
     /**
      * Create a {@linkplain MethodHandleDesc} corresponding to an invocation of a
--- a/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java	Mon Oct 01 12:06:29 2018 -0400
@@ -24,15 +24,12 @@
  */
 package java.lang.constant;
 
-import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.lang.invoke.TypeDescriptor;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static java.util.Objects.requireNonNull;
-
 /**
  * A <a href="package-summary.html#nominal">nominal descriptor</a> for a
  * {@linkplain MethodType} constant.
@@ -44,7 +41,6 @@
  */
 public interface MethodTypeDesc
         extends ConstantDesc<MethodType>,
-                Constable<ConstantDesc<MethodType>>,
                 TypeDescriptor.OfMethod<ClassDesc, MethodTypeDesc> {
     /**
      * Create a {@linkplain MethodTypeDesc} given a method descriptor string
--- a/src/java.base/share/classes/java/lang/constant/MethodTypeDescImpl.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/MethodTypeDescImpl.java	Mon Oct 01 12:06:29 2018 -0400
@@ -28,10 +28,7 @@
 import java.lang.invoke.MethodType;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Optional;
 
-import static java.lang.constant.ConstantDescs.BSM_INVOKE;
-import static java.lang.constant.ConstantDescs.MHR_METHODTYPEDESC_FACTORY;
 import static java.util.Objects.requireNonNull;
 
 /**
@@ -141,11 +138,6 @@
     }
 
     @Override
-    public Optional<? extends ConstantDesc<ConstantDesc<MethodType>>> describeConstable() {
-        return Optional.of(DynamicConstantDesc.of(BSM_INVOKE, MHR_METHODTYPEDESC_FACTORY, descriptorString()));
-    }
-
-    @Override
     public boolean equals(Object o) {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
--- a/src/java.base/share/classes/java/lang/constant/PrimitiveClassDescImpl.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/PrimitiveClassDescImpl.java	Mon Oct 01 12:06:29 2018 -0400
@@ -25,12 +25,9 @@
 package java.lang.constant;
 
 import java.lang.invoke.MethodHandles;
-import java.util.Optional;
 
 import sun.invoke.util.Wrapper;
 
-import static java.lang.constant.ConstantDescs.BSM_INVOKE;
-import static java.lang.constant.ConstantDescs.MHR_CLASSDESC_FACTORY;
 import static java.util.Objects.requireNonNull;
 
 /**
@@ -71,11 +68,6 @@
     }
 
     @Override
-    public Optional<? extends ConstantDesc<ConstantDesc<Class<?>>>> describeConstable() {
-        return Optional.of(DynamicConstantDesc.of(BSM_INVOKE, MHR_CLASSDESC_FACTORY, descriptor));
-    }
-
-    @Override
     public String toString() {
         return String.format("PrimitiveClassDesc[%s]", displayName());
     }
--- a/src/java.base/share/classes/java/lang/constant/ReferenceClassDescImpl.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/constant/ReferenceClassDescImpl.java	Mon Oct 01 12:06:29 2018 -0400
@@ -25,10 +25,7 @@
 package java.lang.constant;
 
 import java.lang.invoke.MethodHandles;
-import java.util.Optional;
 
-import static java.lang.constant.ConstantDescs.BSM_INVOKE;
-import static java.lang.constant.ConstantDescs.MHR_CLASSDESC_FACTORY;
 import static java.lang.constant.ConstantUtils.dropFirstAndLastChar;
 import static java.lang.constant.ConstantUtils.internalToBinary;
 import static java.util.Objects.requireNonNull;
@@ -84,11 +81,6 @@
     }
 
     @Override
-    public Optional<? extends ConstantDesc<ConstantDesc<Class<?>>>> describeConstable() {
-        return Optional.of(DynamicConstantDesc.of(BSM_INVOKE, MHR_CLASSDESC_FACTORY, descriptor));
-    }
-
-    @Override
     public boolean equals(Object o) {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
--- a/src/java.base/share/classes/java/lang/invoke/VarHandle.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/src/java.base/share/classes/java/lang/invoke/VarHandle.java	Mon Oct 01 12:06:29 2018 -0400
@@ -2128,8 +2128,7 @@
      * A <a href="package-summary.html#nominal">nominal descriptor</a> for a
      * {@link VarHandle} constant.
      */
-    public static final class VarHandleDesc extends DynamicConstantDesc<VarHandle>
-            implements Constable<ConstantDesc<VarHandle>> {
+    public static final class VarHandleDesc extends DynamicConstantDesc<VarHandle> {
 
         /**
          * Kinds of variable handle descs
--- a/test/jdk/java/lang/constant/SymbolicDescTest.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/test/jdk/java/lang/constant/SymbolicDescTest.java	Mon Oct 01 12:06:29 2018 -0400
@@ -97,15 +97,18 @@
     }
 
     private static<T> void testSymbolicDesc(ConstantDesc<T> ref, boolean forwardOnly) throws ReflectiveOperationException {
+        // Round trip sym -> resolve -> toSymbolicDesc
+        Constable<ConstantDesc<T>> constable = (Constable<ConstantDesc<T>>) ref.resolveConstantDesc(LOOKUP);
+        Optional<? extends ConstantDesc<ConstantDesc<T>>> described = constable.describeConstable();
         if (!forwardOnly) {
-            // Round trip sym -> resolve -> toSymbolicDesc
-            ConstantDesc<? super ConstantDesc<T>> s = ((Constable<ConstantDesc<T>>) ref.resolveConstantDesc(LOOKUP)).describeConstable().orElseThrow();
-            assertEquals(ref, s);
+            assertEquals(ref, described.orElseThrow());
         }
 
         // Round trip sym -> quoted sym -> resolve
-        Optional<ConstantDesc<ConstantDesc<T>>> opt = (Optional<ConstantDesc<ConstantDesc<T>>>) ((Constable) ref).describeConstable();
-        ConstantDesc<T> sr = opt.orElseThrow().resolveConstantDesc(LOOKUP);
-        assertEquals(sr, ref);
+        if (ref instanceof Constable) {
+            Optional<ConstantDesc<ConstantDesc<T>>> opt = (Optional<ConstantDesc<ConstantDesc<T>>>) ((Constable) ref).describeConstable();
+            ConstantDesc<T> sr = opt.orElseThrow().resolveConstantDesc(LOOKUP);
+            assertEquals(sr, ref);
+        }
     }
 }
--- a/test/jdk/java/lang/constant/boottest/java.base/java/lang/constant/ConstantUtilsTest.java	Thu Sep 27 22:04:49 2018 +0200
+++ b/test/jdk/java/lang/constant/boottest/java.base/java/lang/constant/ConstantUtilsTest.java	Mon Oct 01 12:06:29 2018 -0400
@@ -68,28 +68,4 @@
             }
         }
     }
-
-    public void testSymbolizeHelper() {
-        DirectMethodHandleDesc mh = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.VIRTUAL, ConstantDescs.CR_String, "isEmpty", "()Z");
-        try {
-            ConstantUtils.symbolizeHelper(mh, null, "");
-            fail("");
-        } catch (NullPointerException e) {
-            // good
-        }
-
-        try {
-            ConstantUtils.symbolizeHelper(null, ConstantDescs.CR_ClassDesc, "");
-            fail("");
-        } catch (NullPointerException e) {
-            // good
-        }
-
-        try {
-            ConstantUtils.symbolizeHelper(null, null, "");
-            fail("");
-        } catch (NullPointerException e) {
-            // good
-        }
-    }
 }