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

String::transform spec clarification

    XMLWordPrintable

Details

    • CSR
    • Status: Closed
    • P3
    • Resolution: Approved
    • 12
    • core-libs
    • None
    • behavioral
    • minimal
    • Clarification of behaviour.
    • Java API
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: