changeset 50730:f44721e1c901 jep-334

Minor spec and API touch-ups
author briangoetz
date Wed, 23 May 2018 13:56:40 -0400
parents d8ea829882ad
children 38d5f419e20c
files src/java.base/share/classes/java/lang/invoke/constant/AsTypeMethodHandleDesc.java src/java.base/share/classes/java/lang/invoke/constant/ClassDesc.java src/java.base/share/classes/java/lang/invoke/constant/Constable.java src/java.base/share/classes/java/lang/invoke/constant/ConstantDesc.java src/java.base/share/classes/java/lang/invoke/constant/ConstantDescs.java src/java.base/share/classes/java/lang/invoke/constant/DynamicCallSiteDesc.java src/java.base/share/classes/java/lang/invoke/constant/DynamicConstantDesc.java src/java.base/share/classes/java/lang/invoke/constant/PrimitiveClassDesc.java
diffstat 8 files changed, 28 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/invoke/constant/AsTypeMethodHandleDesc.java	Wed May 23 10:50:48 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/constant/AsTypeMethodHandleDesc.java	Wed May 23 13:56:40 2018 -0400
@@ -74,6 +74,4 @@
     public String toString() {
         return  String.format("%s.asType%s", underlying.toString(), type.displayDescriptor());
     }
-
-    // @@@ canonical support -- detect DCR with BSM=MHR_METHODHANDLEDESC_ASTYPE
 }
--- a/src/java.base/share/classes/java/lang/invoke/constant/ClassDesc.java	Wed May 23 10:50:48 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/constant/ClassDesc.java	Wed May 23 13:56:40 2018 -0400
@@ -251,7 +251,7 @@
     }
 
     /**
-     * Return the descriptor string for this type, as per JVMS 4.3.2
+     * Return a field type descriptor string for this type, as per JVMS 4.3.2
      *
      * @return the descriptor string
      */
--- a/src/java.base/share/classes/java/lang/invoke/constant/Constable.java	Wed May 23 10:50:48 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/constant/Constable.java	Wed May 23 13:56:40 2018 -0400
@@ -36,8 +36,8 @@
  * nominally as a {@link ConstantDesc}.
  *
  * <p>Some constable types have a native representation in the constant pool:
- * ({@link String}, {@link Integer}, {@link Long}, {@link Float},
- * {@link Double}, {@link Class}, {@link MethodType}, and {@link MethodHandle}).
+ * {@link String}, {@link Integer}, {@link Long}, {@link Float},
+ * {@link Double}, {@link Class}, {@link MethodType}, and {@link MethodHandle}.
  * The types {@link String}, {@link Integer}, {@link Long}, {@link Float},
  * and {@link Double} serve as their own nominal descriptors; {@link Class},
  * {@link MethodType}, and {@link MethodHandle} have corresponding nominal
--- a/src/java.base/share/classes/java/lang/invoke/constant/ConstantDesc.java	Wed May 23 10:50:48 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/constant/ConstantDesc.java	Wed May 23 13:56:40 2018 -0400
@@ -52,9 +52,6 @@
  * dynamic constants and {@code invokedynamic} instructions, and other
  * bytecodes or classfile structures that make use of the constant pool.
  *
- * <p>The {@linkplain ConstantDesc} types are also used by Intrinsics
- * to express {@code ldc} instructions.
- *
  * <p>Constants describing various common constants (such as {@link ClassDesc}
  * instances for platform types) can be found in {@link ConstantDescs}.
  *
@@ -71,12 +68,12 @@
  *
  * @apiNote In the future, if the Java language permits, {@linkplain ConstantDesc}
  * may become a {@code sealed} interface, which would prohibit subclassing except by
- * explicitly permitted types.  Bytecode libraries can assume that the following
- * is an exhaustive set of direct subtypes: {@link String}, {@link Integer},
- * {@link Long}, {@link Float}, {@link Double}, {@link ClassDesc},
- * {@link MethodTypeDesc}, {@link MethodHandleDesc}, and {@link DynamicConstantDesc};
- * this list may be extended to reflect future changes to the constant pool format
- * as defined in JVMS 4.4.
+ * explicitly permitted types.  Clients can assume that the following
+ * set of concrete subtypes is exhaustive: {@link String}, {@link Integer},
+ * {@link Long}, {@link Float}, {@link Double}, {@link ConstantClassDesc},
+ * {@link ConstantMethodTypeDesc}, {@link ConstantMethodHandleDesc}, and
+ * {@link DynamicConstantDesc}; this list may be extended to reflect future
+ * changes to the constant pool format as defined in JVMS 4.4.
  *
  * @see Constable
  * @see ConstantDescs
--- a/src/java.base/share/classes/java/lang/invoke/constant/ConstantDescs.java	Wed May 23 10:50:48 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/constant/ConstantDescs.java	Wed May 23 13:56:40 2018 -0400
@@ -137,49 +137,49 @@
     public static final ClassDesc CR_Map = ClassDesc.of("java.util.Map");
 
     /** {@link ClassDesc} representing {@link ConstantDesc} */
-    static final ClassDesc CR_ConstantDesc = ClassDesc.of("java.lang.invoke.constant.ConstantDesc");
+    public static final ClassDesc CR_ConstantDesc = ClassDesc.of("java.lang.invoke.constant.ConstantDesc");
 
     /** {@link ClassDesc} representing {@link ClassDesc} */
-    static final ClassDesc CR_ClassDesc = ClassDesc.of("java.lang.invoke.constant.ClassDesc");
+    public static final ClassDesc CR_ClassDesc = ClassDesc.of("java.lang.invoke.constant.ClassDesc");
 
     /** {@link ClassDesc} representing {@link EnumDesc} */
-    static final ClassDesc CR_EnumDesc = ClassDesc.of("java.lang.invoke.constant.EnumDesc");
+    public static final ClassDesc CR_EnumDesc = ClassDesc.of("java.lang.invoke.constant.EnumDesc");
 
     /** {@link ClassDesc} representing {@link MethodTypeDesc} */
-    static final ClassDesc CR_MethodTypeDesc = ClassDesc.of("java.lang.invoke.constant.MethodTypeDesc");
+    public static final ClassDesc CR_MethodTypeDesc = ClassDesc.of("java.lang.invoke.constant.MethodTypeDesc");
 
     /** {@link ClassDesc} representing {@link ConstantMethodTypeDesc} */
-    static final ClassDesc CR_ConstantMethodTypeDesc = ClassDesc.of("java.lang.invoke.constant.ConstantMethodTypeDesc");
+    public static final ClassDesc CR_ConstantMethodTypeDesc = ClassDesc.of("java.lang.invoke.constant.ConstantMethodTypeDesc");
 
     /** {@link ClassDesc} representing {@link MethodHandleDesc} */
-    static final ClassDesc CR_MethodHandleDesc = ClassDesc.of("java.lang.invoke.constant.MethodHandleDesc");
+    public static final ClassDesc CR_MethodHandleDesc = ClassDesc.of("java.lang.invoke.constant.MethodHandleDesc");
 
     /** {@link ClassDesc} representing {@link ConstantMethodHandleDesc} */
-    static final ClassDesc CR_ConstantMethodHandleDesc = ClassDesc.of("java.lang.invoke.constant.ConstantMethodHandleDesc");
+    public static final ClassDesc CR_ConstantMethodHandleDesc = ClassDesc.of("java.lang.invoke.constant.ConstantMethodHandleDesc");
 
     /** {@link ClassDesc} representing {@link VarHandleDesc} */
-    static final ClassDesc CR_VarHandleDesc = ClassDesc.of("java.lang.invoke.constant.VarHandleDesc");
+    public static final ClassDesc CR_VarHandleDesc = ClassDesc.of("java.lang.invoke.constant.VarHandleDesc");
 
     /** {@link ClassDesc} representing {@link MethodHandleDesc.Kind} */
-    static final ClassDesc CR_MethodHandleDesc_Kind = CR_MethodHandleDesc.inner("Kind");
+    public static final ClassDesc CR_MethodHandleDesc_Kind = CR_MethodHandleDesc.inner("Kind");
 
     /** {@link ClassDesc} representing {@link DynamicConstantDesc} */
-    static final ClassDesc CR_DynamicConstantDesc = ClassDesc.of("java.lang.invoke.constant.DynamicConstantDesc");
+    public static final ClassDesc CR_DynamicConstantDesc = ClassDesc.of("java.lang.invoke.constant.DynamicConstantDesc");
 
     /** {@link ClassDesc} representing {@link DynamicCallSiteDesc} */
-    static final ClassDesc CR_DynamicCallSiteDesc = ClassDesc.of("java.lang.invoke.constant.DynamicCallSiteDesc");
+    public static final ClassDesc CR_DynamicCallSiteDesc = ClassDesc.of("java.lang.invoke.constant.DynamicCallSiteDesc");
 
     /** {@link ClassDesc} representing {@link ConstantBootstraps} */
-    static final ClassDesc CR_ConstantBootstraps = ClassDesc.of("java.lang.invoke.ConstantBootstraps");
+    public static final ClassDesc CR_ConstantBootstraps = ClassDesc.of("java.lang.invoke.ConstantBootstraps");
 
     // Used by MethodHandleDesc, but initialized here before reference to
     // MethodHandleDesc to avoid static initalization circularities
-    static final ClassDesc[] INDY_BOOTSTRAP_ARGS = {
+    /* non-public */ static final ClassDesc[] INDY_BOOTSTRAP_ARGS = {
             ConstantDescs.CR_MethodHandles_Lookup,
             ConstantDescs.CR_String,
             ConstantDescs.CR_MethodType };
 
-    static final ClassDesc[] CONDY_BOOTSTRAP_ARGS = {
+    /* non-public */ static final ClassDesc[] CONDY_BOOTSTRAP_ARGS = {
             ConstantDescs.CR_MethodHandles_Lookup,
             ConstantDescs.CR_String,
             ConstantDescs.CR_Class };
@@ -251,7 +251,7 @@
             = DynamicConstantDesc.of(ConstantDescs.BSM_NULL_CONSTANT,
                                      ConstantDescs.CR_Object);
 
-    // Used by XxxDesc classes, but need to be hear to avoid bootstrap cycles
+    // Used by XxxDesc classes, but need to be here to avoid bootstrap cycles
     static final ConstantMethodHandleDesc MHR_METHODTYPEDESC_FACTORY
             = MethodHandleDesc.of(MethodHandleDesc.Kind.STATIC, CR_MethodTypeDesc, "ofDescriptor",
                                   CR_MethodTypeDesc, CR_String);
--- a/src/java.base/share/classes/java/lang/invoke/constant/DynamicCallSiteDesc.java	Wed May 23 10:50:48 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/constant/DynamicCallSiteDesc.java	Wed May 23 13:56:40 2018 -0400
@@ -44,7 +44,6 @@
  * <p>Concrete subtypes of {@linkplain DynamicCallSiteDesc} must be
  * <a href="../doc-files/ValueBased.html">value-based</a>.
  */
-@SuppressWarnings("rawtypes")
 public class DynamicCallSiteDesc {
 
     private final ConstantMethodHandleDesc bootstrapMethod;
--- a/src/java.base/share/classes/java/lang/invoke/constant/DynamicConstantDesc.java	Wed May 23 10:50:48 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/constant/DynamicConstantDesc.java	Wed May 23 13:56:40 2018 -0400
@@ -465,6 +465,8 @@
         return VarHandleDesc.ofArray((ClassDesc) desc.bootstrapArgs[0]);
     }
 
+    // @@@ To eventually support in canonicalization: DCR with BSM=MHR_METHODHANDLEDESC_ASTYPE becomes AsTypeMHDesc
+
     @Override
     public final boolean equals(Object o) {
         if (this == o) return true;
--- a/src/java.base/share/classes/java/lang/invoke/constant/PrimitiveClassDesc.java	Wed May 23 10:50:48 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/constant/PrimitiveClassDesc.java	Wed May 23 13:56:40 2018 -0400
@@ -32,7 +32,8 @@
 import static java.util.Objects.requireNonNull;
 
 /**
- * PrimitiveClassDesc
+ * A <a href="package-summary.html#nominal">nominal descriptor</a> for the class
+ * constant corresponding to a primitive type (e.g., {@code int.class}).
  */
 final class PrimitiveClassDesc
         extends DynamicConstantDesc<Class<?>> implements ClassDesc {