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

j.l.c.MethodTypeDesc.dropParameterTypes​ throws IllegalArgumentException in a non documented case

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 13
    • core-libs
    • None
    • behavioral
    • minimal
    • Java API
    • SE

    Description

      Summary

      Method j.l.c.MethodTypeDesc.dropParameterTypes​ should specify IndexOutOfBoundsException in a case not documented by its specification. The specification must be updated.

      Problem

      Interface java.lang.constant.MethodTypeDesc extends interface: java.lang.invoke.TypeDescriptor.OfMethod. But there is a mismatch between the specification of method java.lang.invoke.TypeDescriptor.OfMethod::dropParameterTypes and its implementation at java.lang.constant.MethodTypeDescImpl::dropParameterTypes.

      The reason for the mismatch is that an unspecified exception is being thrown. Also the specification of method java.lang.constant.MethodTypeDesc::dropParameterTypes differs from that of java.lang.invoke.TypeDescriptor.OfMethod::dropParameterTypes. The one in the subinterface should be in sync with the one in the superinterface, java.lang.invoke.TypeDescriptor.OfMethod.

      Solution

      Update implementation at java.lang.constant.MethodTypeDescImpl::dropParameterTypes so that it doesn't throw any unspecified exception and sync the specification of java.lang.constant.MethodTypeDesc::dropParameterTypes with that of java.lang.invoke.TypeDescriptor.OfMethod

      Specification

      diff -r 5d8c5c7bca95 -r 4d3de18055c8 src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java
      --- a/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java        Tue May 14 21:36:09 2019 +0300
      +++ b/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java        Tue May 14 16:22:04 2019 -0400
      @@ -141,8 +141,8 @@
            * @param end the index after the last parameter to remove
            * @return a {@linkplain MethodTypeDesc} describing the desired method type
            * @throws IndexOutOfBoundsException if {@code start} is outside the half-open
      -     * range {[0, parameterCount)}, or {@code end} is outside the closed range
      -     * {@code [0, parameterCount]}
      +     * range {@code [0, parameterCount)}, or {@code end} is outside the closed range
      +     * {@code [0, parameterCount]}, or if {@code start > end}
            */
           MethodTypeDesc dropParameterTypes(int start, int end);

      Attachments

        Issue Links

          Activity

            People

              vromero Vicente Arturo Romero Zaldivar
              lkuskov Leonid Kuskov
              Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: