< prev index next >

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

Print this page

        

@@ -22,16 +22,21 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 package java.lang.constant;
 
+import jdk.internal.lang.annotation.Foldable;
+
+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.
  *
  * @apiNote In the future, if the Java language permits, {@linkplain MethodTypeDesc}

@@ -41,10 +46,11 @@
  *
  * @since 12
  */
 public interface MethodTypeDesc
         extends ConstantDesc,
+                Constable,
                 TypeDescriptor.OfMethod<ClassDesc, MethodTypeDesc> {
     /**
      * Creates a {@linkplain MethodTypeDesc} given a method descriptor string.
      *
      * @param descriptor a method descriptor string

@@ -52,10 +58,11 @@
      * @throws NullPointerException if any argument is {@code null}
      * @throws IllegalArgumentException if the descriptor string is not a valid
      * method descriptor
      * @jvms 4.3.3 Method Descriptors
      */
+    @Foldable
     static MethodTypeDesc ofDescriptor(String descriptor) {
         return MethodTypeDescImpl.ofDescriptor(descriptor);
     }
 
     /**

@@ -65,26 +72,29 @@
      * @param returnDesc a {@linkplain ClassDesc} describing the return type
      * @param paramDescs {@linkplain ClassDesc}s describing the argument types
      * @return a {@linkplain MethodTypeDesc} describing the desired method type
      * @throws NullPointerException if any argument is {@code null}
      */
+    @Foldable
     static MethodTypeDesc of(ClassDesc returnDesc, ClassDesc... paramDescs) {
         return new MethodTypeDescImpl(returnDesc, paramDescs);
     }
 
     /**
      * Gets the return type of the method type described by this {@linkplain MethodTypeDesc}.
      *
      * @return a {@link ClassDesc} describing the return type of the method type
      */
+    @Foldable
     ClassDesc returnType();
 
     /**
      * Returns the number of parameters of the method type described by
      * this {@linkplain MethodTypeDesc}.
      * @return the number of parameters
      */
+    @Foldable
     int parameterCount();
 
     /**
      * Returns the parameter type of the {@code index}'th parameter of the method type
      * described by this {@linkplain MethodTypeDesc}.

@@ -92,10 +102,11 @@
      * @param index the index of the parameter to retrieve
      * @return a {@link ClassDesc} describing the desired parameter type
      * @throws IndexOutOfBoundsException if the index is outside the half-open
      * range {[0, parameterCount())}
      */
+    @Foldable
     ClassDesc parameterType(int index);
 
     /**
      * Returns the parameter types as an immutable {@link List}.
      *

@@ -116,10 +127,11 @@
      *
      * @param returnType a {@link ClassDesc} describing the new return type
      * @return a {@linkplain MethodTypeDesc} describing the desired method type
      * @throws NullPointerException if any argument is {@code null}
      */
+    @Foldable
     MethodTypeDesc changeReturnType(ClassDesc returnType);
 
     /**
      * Returns a {@linkplain MethodTypeDesc} that is identical to this one,
      * except that a single parameter type has been changed to the specified type.

@@ -129,10 +141,11 @@
      * @return a {@linkplain MethodTypeDesc} describing the desired method type
      * @throws NullPointerException if any argument is {@code null}
      * @throws IndexOutOfBoundsException if the index is outside the half-open
      * range {[0, parameterCount)}
      */
+    @Foldable
     MethodTypeDesc changeParameterType(int index, ClassDesc paramType);
 
     /**
      * Returns a {@linkplain MethodTypeDesc} that is identical to this one,
      * except that a range of parameter types have been removed.

@@ -142,10 +155,11 @@
      * @return a {@linkplain MethodTypeDesc} describing the desired method type
      * @throws IndexOutOfBoundsException if {@code start} is outside the half-open
      * range {[0, parameterCount)}, or {@code end} is outside the closed range
      * {@code [0, parameterCount]}
      */
+    @Foldable
     MethodTypeDesc dropParameterTypes(int start, int end);
 
     /**
      * Returns a {@linkplain MethodTypeDesc} that is identical to this one,
      * except that a range of additional parameter types have been inserted.

@@ -156,10 +170,11 @@
      * @return a {@linkplain MethodTypeDesc} describing the desired method type
      * @throws NullPointerException if any argument is {@code null}
      * @throws IndexOutOfBoundsException if {@code pos} is outside the closed
      * range {[0, parameterCount]}
      */
+    @Foldable
     MethodTypeDesc insertParameterTypes(int pos, ClassDesc... paramTypes);
 
     /**
      * Returns the method type descriptor string.
      *
< prev index next >