Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: JDK 9 strings very slow Date: Mon, 27 Aug 2018 13:32:34 -0400 Organization: A noiseless patient Spider Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 27 Aug 2018 17:32:36 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="764ee0a98242e5002f726c99dcb762c5"; logging-data="9385"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wh9JKVjfAj8YWq2tXv/Gn" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cancel-Lock: sha1:pfal2Y/A2nFKznhmJDduX1CvBfI= In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:38568 On 8/27/2018 1:17 PM, j4n bur53 wrote: > But I still see some problems with this approach, > like for example. Did Java amend equals, and like > do a check alfa.value==beta.value ? > > I only find in JDK 8: > >         if (this == anObject) { >             return true; >         } >         if (anObject instanceof String) { >             String anotherString = (String)anObject; >             int n = value.length; >             if (n == anotherString.value.length) { >                 char v1[] = value; >                 char v2[] = anotherString.value; >                 int i = 0; >                 while (n-- != 0) { >                     if (v1[i] != v2[i]) >                         return false; >                     i++; >                 } >                 return true; >             } >         } >         return false; This Java source code may be somewhat misleading. I'm not certain, but here and there in the discussion-and-issue pages you'll find references to "the HotSpot VM's intrinsic string operations" -- which suggests (to me) that the JVM might have its own internal native implementations of some String methods. The visible Java code might not execute at all, or might execute only on JVM's that don't "internal-ize" quite so aggressively. Permit me to ask: Why are the internals of the JVM's String handling of such interest to you? Is it just laudable curiosity, or are you confronting a difficulty of some kind? -- esosman@comcast-dot-net.invalid Eight hundred seventy-seven days to go.