< prev index next >

src/java.base/share/classes/java/lang/invoke/MethodType.java

Print this page




  75  * All factory methods may cache values, though caching is not guaranteed.
  76  * Some factory methods are static, while others are virtual methods which
  77  * modify precursor method types, e.g., by changing a selected parameter.
  78  * <p>
  79  * Factory methods which operate on groups of parameter types
  80  * are systematically presented in two versions, so that both Java arrays and
  81  * Java lists can be used to work with groups of parameter types.
  82  * The query methods {@code parameterArray} and {@code parameterList}
  83  * also provide a choice between arrays and lists.
  84  * <p>
  85  * {@code MethodType} objects are sometimes derived from bytecode instructions
  86  * such as {@code invokedynamic}, specifically from the type descriptor strings associated
  87  * with the instructions in a class file's constant pool.
  88  * <p>
  89  * Like classes and strings, method types can also be represented directly
  90  * in a class file's constant pool as constants.
  91  * A method type may be loaded by an {@code ldc} instruction which refers
  92  * to a suitable {@code CONSTANT_MethodType} constant pool entry.
  93  * The entry refers to a {@code CONSTANT_Utf8} spelling for the descriptor string.
  94  * (For full details on method type constants,
  95  * see sections 4.4.8 and 5.4.3.5 of the Java Virtual Machine Specification.)
  96  * <p>
  97  * When the JVM materializes a {@code MethodType} from a descriptor string,
  98  * all classes named in the descriptor must be accessible, and will be loaded.
  99  * (But the classes need not be initialized, as is the case with a {@code CONSTANT_Class}.)
 100  * This loading may occur at any time before the {@code MethodType} object is first derived.
 101  * @author John Rose, JSR 292 EG
 102  * @since 1.7
 103  */
 104 public final
 105 class MethodType
 106         implements Constable,
 107                    TypeDescriptor.OfMethod<Class<?>, MethodType>,
 108                    java.io.Serializable {
 109     @java.io.Serial
 110     private static final long serialVersionUID = 292L;  // {rtype, {ptype...}}
 111 
 112     // The rtype and ptypes fields define the structural identity of the method type:
 113     private final @Stable Class<?>   rtype;
 114     private final @Stable Class<?>[] ptypes;
 115 




  75  * All factory methods may cache values, though caching is not guaranteed.
  76  * Some factory methods are static, while others are virtual methods which
  77  * modify precursor method types, e.g., by changing a selected parameter.
  78  * <p>
  79  * Factory methods which operate on groups of parameter types
  80  * are systematically presented in two versions, so that both Java arrays and
  81  * Java lists can be used to work with groups of parameter types.
  82  * The query methods {@code parameterArray} and {@code parameterList}
  83  * also provide a choice between arrays and lists.
  84  * <p>
  85  * {@code MethodType} objects are sometimes derived from bytecode instructions
  86  * such as {@code invokedynamic}, specifically from the type descriptor strings associated
  87  * with the instructions in a class file's constant pool.
  88  * <p>
  89  * Like classes and strings, method types can also be represented directly
  90  * in a class file's constant pool as constants.
  91  * A method type may be loaded by an {@code ldc} instruction which refers
  92  * to a suitable {@code CONSTANT_MethodType} constant pool entry.
  93  * The entry refers to a {@code CONSTANT_Utf8} spelling for the descriptor string.
  94  * (For full details on method type constants,
  95  * see sections {@jvms 4.4.8} and {@jvms 5.4.3.5} of the Java Virtual Machine Specification.)
  96  * <p>
  97  * When the JVM materializes a {@code MethodType} from a descriptor string,
  98  * all classes named in the descriptor must be accessible, and will be loaded.
  99  * (But the classes need not be initialized, as is the case with a {@code CONSTANT_Class}.)
 100  * This loading may occur at any time before the {@code MethodType} object is first derived.
 101  * @author John Rose, JSR 292 EG
 102  * @since 1.7
 103  */
 104 public final
 105 class MethodType
 106         implements Constable,
 107                    TypeDescriptor.OfMethod<Class<?>, MethodType>,
 108                    java.io.Serializable {
 109     @java.io.Serial
 110     private static final long serialVersionUID = 292L;  // {rtype, {ptype...}}
 111 
 112     // The rtype and ptypes fields define the structural identity of the method type:
 113     private final @Stable Class<?>   rtype;
 114     private final @Stable Class<?>[] ptypes;
 115 


< prev index next >