< prev index next >

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

Print this page
rev 54588 : 8212975: ClassDesc should have a full name method
Reviewed-by: vromero


 164      * Returns the method type descriptor string.
 165      *
 166      * @return the method type descriptor string
 167      * @jvms 4.3.3 Method Descriptors
 168      */
 169     default String descriptorString() {
 170         return String.format("(%s)%s",
 171                              Stream.of(parameterArray())
 172                                    .map(ClassDesc::descriptorString)
 173                                    .collect(Collectors.joining()),
 174                              returnType().descriptorString());
 175     }
 176 
 177     /**
 178      * Returns a human-readable descriptor for this method type, using the
 179      * canonical names for parameter and return types.
 180      *
 181      * @return the human-readable descriptor for this method type
 182      */
 183     default String displayDescriptor() {












 184         return String.format("(%s)%s",
 185                              Stream.of(parameterArray())
 186                                    .map(ClassDesc::displayName)
 187                                    .collect(Collectors.joining(",")),
 188                              returnType().displayName());
 189     }
 190 
 191     /**
 192      * Compares the specified object with this descriptor for equality.  Returns
 193      * {@code true} if and only if the specified object is also a
 194      * {@linkplain MethodTypeDesc} both have the same arity, their return types
 195      * are equal, and each pair of corresponding parameter types are equal.
 196      *
 197      * @param o the other object
 198      * @return whether this descriptor is equal to the other object
 199      */
 200     boolean equals(Object o);
 201 }


 164      * Returns the method type descriptor string.
 165      *
 166      * @return the method type descriptor string
 167      * @jvms 4.3.3 Method Descriptors
 168      */
 169     default String descriptorString() {
 170         return String.format("(%s)%s",
 171                              Stream.of(parameterArray())
 172                                    .map(ClassDesc::descriptorString)
 173                                    .collect(Collectors.joining()),
 174                              returnType().descriptorString());
 175     }
 176 
 177     /**
 178      * Returns a human-readable descriptor for this method type, using the
 179      * canonical names for parameter and return types.
 180      *
 181      * @return the human-readable descriptor for this method type
 182      */
 183     default String displayDescriptor() {
 184         return displayDescriptor(false);
 185     }
 186 
 187     /**
 188      * Returns a human-readable descriptor for this method type, using the
 189      * canonical names for parameter and return types.
 190      *
 191      * @param detail  if true displays class names in full
 192      *
 193      * @return the human-readable descriptor for this method type
 194      */
 195     default String displayDescriptor(boolean detail) {
 196         return String.format("(%s)%s",
 197                 Stream.of(parameterArray())
 198                         .map(cd -> cd.displayName(detail))
 199                         .collect(Collectors.joining(",")),
 200                 returnType().displayName(detail));
 201     }
 202 
 203     /**
 204      * Compares the specified object with this descriptor for equality.  Returns
 205      * {@code true} if and only if the specified object is also a
 206      * {@linkplain MethodTypeDesc} both have the same arity, their return types
 207      * are equal, and each pair of corresponding parameter types are equal.
 208      *
 209      * @param o the other object
 210      * @return whether this descriptor is equal to the other object
 211      */
 212     boolean equals(Object o);
 213 }
< prev index next >