JDK-8215153 : String::transform spec clarification
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 12
  • Submitted: 2018-12-10
  • Updated: 2019-01-09
  • Resolved: 2019-01-09
Related Reports
CSR :  
Relates :  
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) {
```

Comments
Moving to Approved.
09-01-2019

Moving to Provisional.
10-12-2018