Re: how actually string store in java machine
On 4/2/2014 8:47 AM, taqmcg@gmail.com wrote:
On Friday, March 28, 2014 11:02:45 AM UTC-4, Eric Sosman wrote:
On 3/28/2014 9:58 AM, taqmcg@...
On Thursday, March 27, 2014 11:50:22 AM UTC-4, Eric Sosman wrote:
As I said, Java behaves more consistently across platforms than
other languages in my experience. "Write Once, Run Anywhere" was a
goal of the language, but like "Don't Be Evil" it's not a goal that
was attained in perfection. A few examples of variability:
... examples delete ...
Thanks Eric. The first is pretty close to the situation with strings. But it's interesting to note that these are all (I think) in the implementation of methods so that the documentation of these system dependencies is not in the language standard itself, but in the Javadocs for the standard library. No methods are involved in the == comparison of strings, so if it were to be system dependent, then presumably that would have to be noted in the JLS itself. Are there examples where the system dependencies are explicitly called out in the JLS, i.e., similar to allowing non-strict math results?
I dunno. In Original Java the == operator behaved the same way for
all reference types (it asked "Do these two references denote the same
instance?"), so the results of using == on two Integer references, for
example, could differ depending on how many values the particular JVM
chose to cache. But then they changed the meaning of == for the
primitive wrappers, so that difference went away (and that's why I
mentioned using System.identityHashCode() in the comparison).
It strikes me, though, that you seem to argue Java's platform
independence by progressively whittling away the dependencies that
arise. You began with "We'll just ignore strictfp" and "Oh, let's not
worry about anything involving the host environment," and now it seems
"Methods don't count, either." With an approach like this, I might
well argue that all birds are crows: We'll just agree not to consider
peacocks, and emus don't fly so they scarcely count, and finches aren't
big enough to worry with, and ... eventually I'll have proved universal
crowhood! ;-)
--
Eric Sosman
esosman@comcast-dot-net.invalid