RFR 8024341: j.u.regex.Pattern.splitAsStream() doesn't correspond to split() method if using an example from the spec
Alan Bateman
Alan.Bateman at oracle.com
Wed Sep 18 15:20:45 UTC 2013
On 15/09/2013 17:27, Paul Sandoz wrote:
> Hi,
>
> http://cr.openjdk.java.net/~psandoz/tl/JDK-8024341-pattern-splitAsStream/webrev/
>
> This fixes an issue with Pattern.splitAsStream reporting empty trailing elements and aligns with the functionality of Pattern.split(CharSequence input).
>
> The matching iterator passed to the stream was updated to aggressively consume and keep a count of a sequence of empty matching elements such that those elements can either be reported if not trailing, or discarded if trailing.
>
> Paul.
It make sense to adjust the spec to have it consistent with
split(CharSequence).
On the implementation then I had to read it a few times to understand
how emptyElementCount is used. I wonder if it could be done in a simpler
way, say just setting a flag when current reaches input.length? Maybe
you have tried this already.
On the test then you probably should include 8016846 in @bug tag as
otherwise it looks like it was added specifically for 8024341.
-Alan.
More information about the core-libs-dev
mailing list