RFR: JDK-8200377 String::strip, String::stripLeading, String::stripTrailing

Roger Riggs Roger.Riggs at Oracle.com
Fri May 11 12:58:41 UTC 2018


Hi Jim,

The implementations of the strip methods in StringLatin1 and StringUTF16 
should return
the original string if there is no  leading/trailing whitespace.  It 
will save a test for null
and replacement in java.lang.String methods.

It also seems odd that for the empty string, a new empty string is 
returned instead of the original.
Returning the original (empty) string meets the spec and saves 
finding/creating the empty string.
(Latin1:570,579,587, UTF16:890,900,909)

(Testng would DataProviders and its asserts would have made the test 
easy to write).

Regards, Roger


On 5/9/2018 10:08 AM, Jim Laskey wrote:
> This feature introduces three String instance methods for removal of white space from the beginning and end of a string. Unlike String::trim, these methods use the Unicode definition of white space. Specifically, these methods use Character.isWhitespace(int codePoint) to detect space characters.
>
> webrev: http://cr.openjdk.java.net/~jlaskey/8200377/webrev/index.html
> jbs: https://bugs.openjdk.java.net/browse/JDK-8200377
> csr: https://bugs.openjdk.java.net/browse/JDK-8200378
>



More information about the core-libs-dev mailing list