Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace Newsgroups: comp.lang.java.programmer Subject: Re: Substring changes (JDK 1.7) Date: Sat, 12 Jan 2013 09:59:58 -0800 Organization: A noiseless patient Spider Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 12 Jan 2013 18:00:02 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="61282af8d6595e8d991edb5ac03d6e00"; logging-data="22157"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/I1Of6GCGH0fvO9B25WgqgGgkIBPnkpZg=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: Cancel-Lock: sha1:qTupTfnLcOzSl2brnjSDBha1qLQ= Xref: csiph.com comp.lang.java.programmer:21362 On 1/12/2013 8:50 AM, Robert Klemme wrote: > On 11.01.2013 08:19, Roedy Green wrote: >> On Fri, 11 Jan 2013 07:29:16 +0100, Robert Klemme >> wrote, quoted or indirectly quoted >> someone who said : >> >>> Well, shouldn't such a basic thing be part of the standard library? >> >> String is final and many things take a String parm and nothing else. >> You can create something similar and use it like String. > > There is no reason in what you say that it should not be part of the std > lib. javax.swing.text.Segment preserves the semantics of a shared buffer. It's not a drop-in replacement for String (many of the methods differ or are absent). But Segment is extensible, so critical missing methods could be added. I wonder if the best way to go would be to cheat and have String extended into a SharedString with the old implementation. This would violate the finality of String, but it's possible to synthesize these sorts of things if one has control of the JVM. Obviously, this needs to come from Oracle.