< prev index next >

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

Print this page

        

*** 22,37 **** --- 22,42 ---- * 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,50 **** --- 46,56 ---- * * @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,61 **** --- 58,68 ---- * @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,90 **** --- 72,100 ---- * @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,101 **** --- 102,112 ---- * @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,125 **** --- 127,137 ---- * * @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,138 **** --- 141,151 ---- * @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,151 **** --- 155,165 ---- * @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,165 **** --- 170,180 ---- * @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 >