< prev index next >

src/java.base/share/classes/java/lang/constant/ConstantDescs.java

Print this page
rev 52749 : Bootstrap method consolidation
* clean up and simplify JDK support code for BSM invocation
* simplify JVM bootstrap handshake: use BootstrapCallInfo only
* remove unused JVM paths and data fields
* move bootstrap argument processing from MethodHandleNatives to ConstantPool
* remove ConstantGroup; merge argument access into BootstrapCallInfo
* adjust BSM argument access: remove copyArguments, add argumentRef API
* add metadata-free BSM modes, including symbolic arguments from CP

@@ -56,10 +56,26 @@
      * constructor, or the invocation name of a dynamic constant or dynamic
      * callsite when the bootstrap is known to ignore the invocation name.
      */
     public static final String DEFAULT_NAME = "_";
 
+    /** Invocation name to use with a no-metadata expression mode bootstrap method.
+     * The effect of resolving a dynamic constant with this name is to call
+     * the bootstrap method on the arguments, but not on the lookup, name, or type.
+     * The arguments are resolved.
+     */
+    public static final String INVOKE_NAME = "invoke";
+
+    /** Invocation name to use with a no-metadata expression mode bootstrap method.
+     * The effect of resolving a dynamic constant with this name is to call
+     * the bootstrap method on the arguments, but not on the lookup, name, or type.
+     * In addition, formal parameters which are of a supertype of {@link ConstantDesc}
+     * are not resolved, but are passed as unresolved {@link ConstantDesc} values
+     * derived directly from the constant pool.
+     */
+    public static final String SYMBOLIC_NAME = "symbolic";
+
     // Don't change the order of these declarations!
 
     /** {@link ClassDesc} representing {@link Object} */
     public static final ClassDesc CR_Object = ClassDesc.of("java.lang.Object");
 

@@ -247,37 +263,25 @@
     public static final ConstantDesc<?> NULL
             = 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());
-
-    static final DirectMethodHandleDesc MHR_DYNAMICCONSTANTDESC_NAMED_FACTORY
-            = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_DynamicConstantDesc, "ofNamed",
-                                  CR_DynamicConstantDesc, CR_DirectMethodHandleDesc, CR_String, CR_String, CR_ConstantDesc.arrayType());
+    static final DirectMethodHandleDesc MHR_CONSTANTDESC_IDENTITY
+            = MethodHandleDesc.of(DirectMethodHandleDesc.Kind.STATIC, CR_ConstantBootstraps, "constantDesc",
+                                  CR_ConstantDesc, CR_ConstantDesc);
 
     /** {@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);

@@ -294,21 +298,10 @@
     /** {@link MethodHandleDesc} representing {@link VarHandleDesc#ofArray(ClassDesc)} */
     public static final DirectMethodHandleDesc MHR_VARHANDLEDESC_OFARRAY
             = 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
      * parameter types are {@code Lookup}, {@code String}, and {@code MethodType}.
      *
< prev index next >