mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8306698: Add overloads to MethodTypeDesc::of
Reviewed-by: mchung
This commit is contained in:
parent
6b27dad76e
commit
8ffa264cf0
3 changed files with 53 additions and 38 deletions
|
@ -36,6 +36,7 @@ import static java.util.Objects.requireNonNull;
|
|||
class ConstantUtils {
|
||||
/** an empty constant descriptor */
|
||||
public static final ConstantDesc[] EMPTY_CONSTANTDESC = new ConstantDesc[0];
|
||||
static final ClassDesc[] EMPTY_CLASSDESC = new ClassDesc[0];
|
||||
static final Constable[] EMPTY_CONSTABLE = new Constable[0];
|
||||
static final int MAX_ARRAY_TYPE_DESC_DIMENSIONS = 255;
|
||||
|
||||
|
|
|
@ -55,6 +55,34 @@ public sealed interface MethodTypeDesc
|
|||
return MethodTypeDescImpl.ofDescriptor(descriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a {@linkplain MethodTypeDesc} with the given return type and no
|
||||
* parameter types}
|
||||
*
|
||||
* @param returnDesc a {@linkplain ClassDesc} describing the return type
|
||||
* @throws NullPointerException if {@code returnDesc} is {@code null}
|
||||
* @since 21
|
||||
*/
|
||||
static MethodTypeDesc of(ClassDesc returnDesc) {
|
||||
return new MethodTypeDescImpl(returnDesc, ConstantUtils.EMPTY_CLASSDESC);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a {@linkplain MethodTypeDesc} given the return type and a list of
|
||||
* parameter types}
|
||||
*
|
||||
* @param returnDesc a {@linkplain ClassDesc} describing the return type
|
||||
* @param paramDescs a {@linkplain List} of {@linkplain ClassDesc}s
|
||||
* describing the parameter types
|
||||
* @throws NullPointerException if any argument or its contents are {@code null}
|
||||
* @throws IllegalArgumentException if any element of {@code paramDescs} is a
|
||||
* {@link ClassDesc} for {@code void}
|
||||
* @since 21
|
||||
*/
|
||||
static MethodTypeDesc of(ClassDesc returnDesc, List<ClassDesc> paramDescs) {
|
||||
return of(returnDesc, paramDescs.toArray(ConstantUtils.EMPTY_CLASSDESC));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@linkplain MethodTypeDesc} given the return type and parameter
|
||||
* types.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue