< prev index next >

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

Print this page

        

@@ -26,10 +26,12 @@
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 
+import jdk.internal.lang.annotation.Foldable;
+
 import static java.lang.constant.ConstantDescs.CD_void;
 import static java.lang.constant.DirectMethodHandleDesc.Kind.CONSTRUCTOR;
 
 /**
  * A <a href="package-summary.html#nominal">nominal descriptor</a> for a

@@ -41,11 +43,11 @@
  * {@linkplain MethodHandleDesc} directly.
  *
  * @since 12
  */
 public interface MethodHandleDesc
-        extends ConstantDesc {
+        extends ConstantDesc, Constable {
 
     /**
      * Creates a {@linkplain MethodHandleDesc} corresponding to an invocation of a
      * declared method, invocation of a constructor, or access to a field.
      *

@@ -73,10 +75,11 @@
      * @jvms 4.4.8 The CONSTANT_MethodHandle_info Structure
      * @jvms 4.2.2 Unqualified Names
      * @jvms 4.3.2 Field Descriptors
      * @jvms 4.3.3 Method Descriptors
      */
+    @Foldable
     static DirectMethodHandleDesc of(DirectMethodHandleDesc.Kind kind,
                                      ClassDesc owner,
                                      String name,
                                      String lookupDescriptor) {
         switch (kind) {

@@ -113,10 +116,11 @@
      * @throws NullPointerException if any non-ignored arguments are null
      * @throws IllegalArgumentException if the {@code name} has the incorrect
      * format, or the kind is invalid
      * @jvms 4.2.2 Unqualified Names
      */
+    @Foldable
     static DirectMethodHandleDesc ofMethod(DirectMethodHandleDesc.Kind kind,
                                            ClassDesc owner,
                                            String name,
                                            MethodTypeDesc lookupMethodType) {
         switch (kind) {

@@ -151,10 +155,11 @@
      * @throws NullPointerException if any of the arguments are null
      * @throws IllegalArgumentException if the {@code kind} is not one of the
      * valid values or if the field name is not valid
      * @jvms 4.2.2 Unqualified Names
      */
+    @Foldable
     static DirectMethodHandleDesc ofField(DirectMethodHandleDesc.Kind kind,
                                           ClassDesc owner,
                                           String fieldName,
                                           ClassDesc fieldType) {
         MethodTypeDesc mtr;

@@ -177,10 +182,11 @@
      * @param paramTypes {@link ClassDesc}s describing the parameter types of
      *                   the constructor
      * @return the {@linkplain MethodHandleDesc}
      * @throws NullPointerException if any of the arguments are null
      */
+    @Foldable
     static DirectMethodHandleDesc ofConstructor(ClassDesc owner,
                                                 ClassDesc... paramTypes) {
         return MethodHandleDesc.ofMethod(CONSTRUCTOR, owner, ConstantDescs.DEFAULT_NAME,
                                          MethodTypeDesc.of(CD_void, paramTypes));
     }

@@ -190,10 +196,11 @@
      * adapted to a different type, as if by {@link MethodHandle#asType(MethodType)}.
      *
      * @param type a {@link MethodHandleDesc} describing the new method type
      * @return a {@linkplain MethodHandleDesc} for the adapted method handle
      */
+    @Foldable
     default MethodHandleDesc asType(MethodTypeDesc type) {
         return (invocationType().equals(type)) ? this : new AsTypeMethodHandleDesc(this, type);
     }
 
     /**

@@ -202,10 +209,11 @@
      * describes the full set of stack values that are consumed by the invocation
      * (including the receiver, if any).
      *
      * @return a {@linkplain MethodHandleDesc} describing the method handle type
      */
+    @Foldable
     MethodTypeDesc invocationType();
 
     /**
      * Compares the specified object with this descriptor for equality.  Returns
      * {@code true} if and only if the specified object is also a
< prev index next >