Feedback on the implementation of StringJoiner

Henry Jen henry.jen at oracle.com
Fri Dec 14 08:54:43 PST 2012


On Dec 14, 2012, at 1:31 AM, Roel Spilker <r.spilker at gmail.com> wrote:

> It is already pushed to the lambda repo: http://hg.openjdk.java.net/lambda/lambda/jdk/annotate/6fb8cefc938c/src/share/classes/java/util/StringJoiner.java
> 
> I'm not sure that that's correct. If the prefix and the first added element are both empty and the infix is not, I would expect the resulting String to start with the infix, but in this implementation it starts with the first added non-empty CharSequence.

Good catch. Will fix and add a test case.

> So I think we still need the somethingAdded field, or need to initialize the value field with null and construct the value when the first value is added.
> 
> Also, the lambda implementation still does the string concatenation in the constructor.
> 

Yes, see previous reply. I am not convinced it should be removed.

Cheers,
Henry



More information about the lambda-dev mailing list