Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Is the string pool implementation dependent?

 
Ranch Hand
Posts: 209
13
VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the behaviour, or even the very existence, of the string pool jvm implementation dependent?

I've seen several questions, where which answer is correct depends on the existence of a string pool.

For example, K&B6 p637 Q4, with a couple of comments added:



The size printed at line 15 is either 2 or 3, depending on whether line 25 is commented out.
The key point is line 23 where two "Monday" strings are tested for ==

However, if there were no string pool, the behaviour would be different. If I modify the class to ensure that the two "Monday" strings are different objects, then it doesn't matter if the line [a] is commented out or not. The size is always 3.




 
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As far as I know, the string pool is exclusively implemented in pure java code so it shouldn't be jvm dependent. I don't see what could be implemented in native OS calls in there but I could be wrong. Anyway, I am sure at least most of it is implemented in pure java ;-)
 
Why is the word "abbreviation" so long? And this ad is so short?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic