--- old/src/java.base/share/classes/java/lang/invoke/MethodType.java 2020-04-13 21:03:54.000000000 -0700 +++ new/src/java.base/share/classes/java/lang/invoke/MethodType.java 2020-04-13 21:03:54.000000000 -0700 @@ -99,6 +99,36 @@ * all classes named in the descriptor must be accessible, and will be loaded. * (But the classes need not be initialized, as is the case with a {@code CONSTANT_Class}.) * This loading may occur at any time before the {@code MethodType} object is first derived. + *
+ * Nominal Descriptors + *
+ * A {@code MethodType} can be described in {@linkplain MethodTypeDesc nominal form} + * if and only if all of the parameter types and return type can be described + * with a {@link Class#describeConstable() nominal descriptor} represented by + * {@link ClassDesc}. If a method type can be described norminally, then: + *
+ * If any of the parameter types or return type cannot be described + * nominally, i.e. {@link Class#describeConstable() Class::describeConstable} + * returns an empty optional for that type, + * then the method type cannot be described in nominal form: + *
* Note that this is not a strict inverse of {@link #fromMethodDescriptorString fromMethodDescriptorString}. * Two distinct classes which share a common name but have different class loaders @@ -1149,7 +1181,9 @@ * generate bytecodes that process method handles and {@code invokedynamic}. * {@link #fromMethodDescriptorString(java.lang.String, java.lang.ClassLoader) fromMethodDescriptorString}, * because the latter requires a suitable class loader argument. - * @return the bytecode type descriptor representation + * @return the descriptor string for this method type + * @jvms 4.3.3 Method Descriptors + * @see Nominal Descriptor for {@code MethodType} */ public String toMethodDescriptorString() { String desc = methodDescriptor; @@ -1161,11 +1195,28 @@ } /** - * Return a field type descriptor string for this type + * Returns a descriptor string for this method type. + * + *
+ * If this method type can be described nominally, + * then the result is a method type descriptor string (JVMS {@jvms 4.3.3}). + * {@link MethodTypeDesc MethodTypeDesc} for this method type + * can be produced by calling {@link MethodTypeDesc#ofDescriptor(String) + * MethodTypeDesc::ofDescriptor} with the result descriptor string. + *
+ * If this method type cannot be described nominally + * and the result is a string of the form: + *
{@code "(+ * where {@code) "}