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


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

Re: how actually string store in java machine

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
From Jan Burse <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject Re: how actually string store in java machine
Date Wed, 26 Mar 2014 09:03:41 +0100
Organization albasani.net
Lines 61
Message-ID <lgu1kt$ti$1@news.albasani.net> (permalink)
References <8f7d9272-4b25-44c9-8c31-93ea754be4cb@googlegroups.com> <lgsflf$pua$1@dont-email.me> <lgslfc$k81$1@news.albasani.net> <lgslj6$k81$2@news.albasani.net> <b9f4j99knq24nqdmi1ultckkm82ecem7v6@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.albasani.net i9/kGAZIcySqLLJnugYyWrPOnyRgpFMlLT3K2CKRLdIuMi2EilbezSHx/lR37Bapl8xTpeEyftbf63cyCOVoxg==
NNTP-Posting-Date Wed, 26 Mar 2014 08:03:41 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="K8Az7mVNlgeK/nYP+A5uBOMnM+01W4oa5m36ELv1bS0utSpgSspycttiMyUBSpgEfd/4P1rJn1VIcD9W9IO16eslrm41J2AfCwnA2nE6HCSLYjNzBL8h728SedbN2RBM"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:28.0) Gecko/20100101 Firefox/28.0 SeaMonkey/2.25
In-Reply-To <b9f4j99knq24nqdmi1ultckkm82ecem7v6@4ax.com>
Cancel-Lock sha1:OB0yAQRub9aaO85GEEQVimA7920=
Xref csiph.com comp.lang.java.programmer:27873

Show key headers only | View raw


Roedy Green schrieb:
>> http://stackoverflow.com/questions/16690815/shared-constant-pool
> I was under the impression all string constants lived in the same pool
> along with the interned strings. That would imply a shared constant
> pool since day 1.  Have I had this wrong since Java 1.0?

Yeah, probably the answer is not a good one. Blurring
the compiletime format of byte code with the runtime
representation of a string.

But I guess there is a difference between Hotspot
and Dalvik in compiletime, the Hotspot Bytecode has
different pools per class, and the Dalvik has a single
pool.

What this implies for the runtime, I don't know. I
even don't know whether the constants from the pools
go into memory via intern(). The constant pool can
also have floats etc.. And there are complications
such as:

"Class data sharing (CDS) is a feature introduced in J2SE 5.0 that is 
intended to reduce the startup time for Java programming language 
applications, in particular smaller applications, as well as reduce 
footprint. When the JRE is installed on 32-bit platforms using the Sun 
provided installer, the installer loads a set of classes from the system 
jar file into a private internal representation, and dumps that 
representation to a file, called a “shared archive”. If the Sun JRE 
installer is not being used, this can be done manually, as explained 
below. During subsequent JVM invocations, the shared archive is 
memory-mapped in, saving the cost of loading those classes and allowing 
much of the JVM's metadata for these classes to be shared among multiple 
JVM processes. etc.."
http://openjdk.java.net/groups/hotspot/docs/RuntimeOverview.html#VM%20Class%20Loading|outline

Possibly the best idea is to say it is implementation
dependent what happens with the Strings in the constant
pool. You can try the following test code:

     class A {
         String t = "hello";
     }

     class B {
         String t = "hello";
     }

     if (A.t == B.t) {
        System.out.println("yes");
     } else {
        System.out.println("no");
     }

The bottom line could be, that we are not in position to
say what the above program does alone from the Java
Language Specification, since it is JVM implementation
dependent. But I might be wrong.

Bye

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


Thread

how actually string store in java machine Rishipal Singh <95rishipal@gmail.com> - 2014-03-25 09:56 -0700
  Re: how actually string store in java machine Roedy Green <see_website@mindprod.com.invalid> - 2014-03-25 10:32 -0700
  Re: how actually string store in java machine Roedy Green <see_website@mindprod.com.invalid> - 2014-03-25 10:33 -0700
  Re: how actually string store in java machine Jeff Higgins <jeff@invalid.invalid> - 2014-03-25 13:49 -0400
    Re: how actually string store in java machine Jan Burse <janburse@fastmail.fm> - 2014-03-25 20:29 +0100
      Re: how actually string store in java machine Jan Burse <janburse@fastmail.fm> - 2014-03-25 20:31 +0100
        Re: how actually string store in java machine Roedy Green <see_website@mindprod.com.invalid> - 2014-03-25 19:37 -0700
          Re: how actually string store in java machine Jan Burse <janburse@fastmail.fm> - 2014-03-26 09:03 +0100
            Re: how actually string store in java machine Jan Burse <janburse@fastmail.fm> - 2014-03-26 09:11 +0100
            Re: how actually string store in java machine Jan Burse <janburse@fastmail.fm> - 2014-03-27 10:27 +0100
          Re: how actually string store in java machine markspace <markspace@nospam.nospam> - 2014-03-26 08:32 -0700
            Re: how actually string store in java machine Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-03-26 13:54 -0400
              Re: how actually string store in java machine taqmcg@gmail.com - 2014-03-26 12:57 -0700
              Re: how actually string store in java machine markspace <markspace@nospam.nospam> - 2014-03-26 16:37 -0700
                Re: how actually string store in java machine Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-03-27 08:54 -0400
                Re: how actually string store in java machine taqmcg@gmail.com - 2014-03-27 08:23 -0700
                Re: how actually string store in java machine Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-03-27 11:50 -0400
                Re: how actually string store in java machine taqmcg@gmail.com - 2014-03-28 06:58 -0700
                Re: how actually string store in java machine Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-03-28 11:02 -0400
                Re: how actually string store in java machine taqmcg@gmail.com - 2014-04-02 05:47 -0700
                Re: how actually string store in java machine Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-02 10:15 -0400
                Re: how actually string store in java machine taqmcg@gmail.com - 2014-04-03 08:58 -0700
            Re: how actually string store in java machine Roedy Green <see_website@mindprod.com.invalid> - 2014-03-26 17:07 -0700
      Re: how actually string store in java machine Jeff Higgins <jeff@invalid.invalid> - 2014-03-25 16:07 -0400
        Re: how actually string store in java machine Jeff Higgins <jeff@invalid.invalid> - 2014-03-25 16:16 -0400
          Re: how actually string store in java machine Jeff Higgins <jeff@invalid.invalid> - 2014-03-25 16:19 -0400
            Re: how actually string store in java machine markspace <markspace@nospam.nospam> - 2014-03-25 14:00 -0700
              Re: how actually string store in java machine Jeff Higgins <jeff@invalid.invalid> - 2014-03-25 17:21 -0400
                Re: how actually string store in java machine Jeff Higgins <jeff@invalid.invalid> - 2014-03-26 11:40 -0400
                Re: how actually string store in java machine Roedy Green <see_website@mindprod.com.invalid> - 2014-03-26 17:46 -0700
  Re: how actually string store in java machine Lew <lewbloch@gmail.com> - 2014-03-25 15:07 -0700

csiph-web