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

String::transform spec clarification

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 12
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Clarification of behaviour.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      The language of the original implementation does not include information about exceptions occurring in the supplied function.

      Solution

      Include a clarifying paragraph: "Any exception thrown by f() will be propagated to the caller."

      diff -r fcbc56748cbd src/java.base/share/classes/java/lang/String.java
      --- a/src/java.base/share/classes/java/lang/String.java Mon Dec 10 13:02:32 2018 -0400
      +++ b/src/java.base/share/classes/java/lang/String.java Mon Dec 10 14:52:09 2018 -0400
      @@ -2985,6 +2985,9 @@
            * This method allows the application of a function to {@code this}
            * string. The function should expect a single String argument
            * and produce an {@code R} result.
      +     * <p>
      +     * Any exception thrown by {@code f()} will be propagated to the
      +     * caller.
            *
            * @param f    functional interface to a apply
            *

      Specification

          /**
           * This method allows the application of a function to {@code this}
           * string. The function should expect a single String argument
           * and produce an {@code R} result.
           * <p>
           * Any exception thrown by {@code f()} will be propagated to the
           * caller.
           *
           * @param f    functional interface to a apply
           *
           * @param <R>  class of the result
           *
           * @return     the result of applying the function to this string
           *
           * @see java.util.function.Function
           *
           * @since 12
           */
          public <R> R transform(Function<? super String, ? extends R> f) {

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jlaskey Jim Laskey
                Reporter:
                dsingh Durgesh Singh (Inactive)
                Reviewed By:
                Stuart Marks
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: