RFR: 8028757: CharSequence.subSequence improperly requires a "new" CharSequence be returned

Alan Bateman Alan.Bateman at oracle.com
Tue Dec 3 20:03:14 UTC 2013

On 03/12/2013 18:15, Stuart Marks wrote:
> Hi all,
> Please review this small change to the subSequence() method specs of 
> CharSequence and String. Essentially this removes the requirement of 
> returning a "new" character sequence at each call. This brings the 
> spec in line with String's implementation, which will return 'this' in 
> appropriate circumstances.
> No change is necessary for the other CharSequence implementations. 
> StringBuilder/Buffer still say "new" and in fact they always return 
> new String objects. CharBuffer defines its exact sharing behavior. 
> Segment returns a "new" Segment with a shared character array, which 
> is (supposedly) immutable.
Looks good and I think is the best solution for this.


More information about the core-libs-dev mailing list