should CharSequence have getChars default method?

Martin Buchholz martinrb at
Wed Aug 21 14:14:54 PDT 2013

I tried to do this, and got pushback, but still have a pending change.
 Check archives of core-libs-dev.  The issue is that is makes it easier to
pass internal arrays to untrusted code.

On Wed, Aug 21, 2013 at 2:07 PM, Per Bothner <per at> wrote:

> It is tempting to move many of String's methods to
> CharSequence.  A dumb default implementation: of CharSequence#t
> based on String#T:
>     public default T M(args) { return this.toString().M(args); }
> If the return type is String, perhaps the return type (in CharSequence)
> should be CharSequence:
>     public default CharSequence M(args) { return this.toString().M(args); }
> Of course this loses because of the toString.  However, in many cases
> the implementation from String could be plugged in easily.
> Specifically getChars is defined for both String, StringBuilder,
> and StringBuffer.  It seems such a method should be moved up in the
> hierarchy.
> I realize time is limited, and this isn't very high priority.
> Once you look into the details of each method, and how they're
> implemented in String, there will be lots of little decisions.
> Still, at least something to consider for Java 9.
> --
>         --Per Bothner
> per at

More information about the lambda-dev mailing list