Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21307

Re: Substring changes (JDK 1.7)

From Jan Burse <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject Re: Substring changes (JDK 1.7)
Date 2013-01-10 20:08 +0100
Organization albasani.net
Message-ID <kcn3ir$fak$1@news.albasani.net> (permalink)
References <kcmg8p$7ee$1@news.albasani.net>

Show all headers | View raw


Jan Burse schrieb:
> Dear All,
>
>  > Recent versions of the JDK do not reuse the backing char[].
>  > The reason is that the offset and length fields have been
>  > removed from String to save memory.
>
> Did this affect some of your code?
>
> Bye

Its from JDK 1.7 Update 10

Look see:

C:\Users\Jan Burse>java -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

rt.jar:

public final class String
     implements java.io.Serializable, Comparable<String>, CharSequence {
     /** The value is used for character storage. */
     private final char value[];

     /** Cache the hash code for the string */
     private int hash; // Default to 0

     /** use serialVersionUID from JDK 1.0.2 for interoperability */
     private static final long serialVersionUID = -6849794470754667710L;

-- and --

     public String substring(int beginIndex, int endIndex) {
         if (beginIndex < 0) {
             throw new StringIndexOutOfBoundsException(beginIndex);
         }
         if (endIndex > value.length) {
             throw new StringIndexOutOfBoundsException(endIndex);
         }
         int subLen = endIndex - beginIndex;
         if (subLen < 0) {
             throw new StringIndexOutOfBoundsException(subLen);
         }
         return ((beginIndex == 0) && (endIndex == value.length)) ? this
                 : new String(value, beginIndex, subLen);
     }

-- and --

     public String(char value[], int offset, int count) {
         if (offset < 0) {
             throw new StringIndexOutOfBoundsException(offset);
         }
         if (count < 0) {
             throw new StringIndexOutOfBoundsException(count);
         }
         // Note: offset or count might be near -1>>>1.
         if (offset > value.length - count) {
             throw new StringIndexOutOfBoundsException(offset + count);
         }
         this.value = Arrays.copyOfRange(value, offset, offset+count);
     }

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-10 14:38 +0100
  Re: Substring changes (JDK 1.7) markspace <markspace@nospam.nospam> - 2013-01-10 08:15 -0800
    Re: Substring changes (JDK 1.7) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2013-01-10 10:48 -0600
      Re: Substring changes (JDK 1.7) markspace <markspace@nospam.nospam> - 2013-01-10 09:22 -0800
        Re: Substring changes (JDK 1.7) Lars Enderin <lars.enderin@telia.com> - 2013-01-10 19:35 +0100
  Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-10 20:08 +0100
    Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-10 20:12 +0100
  Re: Substring changes (JDK 1.7) Roedy Green <see_website@mindprod.com.invalid> - 2013-01-10 12:22 -0800
    Re: Substring changes (JDK 1.7) Robert Klemme <shortcutter@googlemail.com> - 2013-01-10 22:58 +0100
      Re: Substring changes (JDK 1.7) Roedy Green <see_website@mindprod.com.invalid> - 2013-01-10 15:20 -0800
      Re: Substring changes (JDK 1.7) Robert Klemme <shortcutter@googlemail.com> - 2013-01-11 07:29 +0100
        Re: Substring changes (JDK 1.7) Roedy Green <see_website@mindprod.com.invalid> - 2013-01-10 23:19 -0800
          Re: Substring changes (JDK 1.7) Robert Klemme <shortcutter@googlemail.com> - 2013-01-12 17:50 +0100
            Re: Substring changes (JDK 1.7) markspace <markspace@nospam.nospam> - 2013-01-12 09:59 -0800
              Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-12 19:14 +0100
                Re: Substring changes (JDK 1.7) markspace <markspace@nospam.nospam> - 2013-01-12 10:36 -0800
                Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-13 12:09 +0100
    Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-11 09:23 +0100
      Re: Substring changes (JDK 1.7) "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-11 08:29 +0000
        Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-11 10:56 +0100
          Re: Substring changes (JDK 1.7) Jan Burse <janburse@fastmail.fm> - 2013-01-11 14:30 +0100

csiph-web