Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8309755

MethodTypeDesc::descriptorString no longer provides the default implementation

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • core-libs
    • None
    • minimal
    • Making a default method in a sealed interface abstract does not affect user code.
    • Java API
    • SE

      Summary

      Make MethodTypeDesc::descriptorString an abstract method and no longer provides the default implementation.

      Problem

      The implementation of MethodTypeDesc::descriptorString needs lazy cache for better performance and done in MethodTypeDescImpl class. The default implementation of MethodTypeDesc::descriptorString is redundant since MethodTypeDescImpl is the only implementation class of MethodTypeDesc sealed interface.

      Solution

      Move the implementation of descriptorString into MethodTypeDescImpl, and make MethodTypeDesc::descriptorString abstract.

      Specification

      @@ -195,13 +195,7 @@ public sealed interface MethodTypeDesc
            * @return the method type descriptor string
            * @jvms 4.3.3 Method Descriptors
            */
      -    default String descriptorString() {
      -        return String.format("(%s)%s",
      -                             Stream.of(parameterArray())
      -                                   .map(ClassDesc::descriptorString)
      -                                   .collect(Collectors.joining()),
      -                             returnType().descriptorString());
      -    }
      +    String descriptorString();
      
           /**
            * Returns a human-readable descriptor for this method type, using the

            liach Chen Liang
            liach Chen Liang
            Mandy Chung
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: