L
Lew
I wondered if it is really true that intern()ed Strings can be GCed.
How could Java keep the promises specified for intern()ed Strings if
they're GCed?
Also, the String#intern() Javadocs state:
"A pool of strings, initially empty, is maintained privately by the
class String."
This apparently implies that the class 'String' keeps all references
to intern()ed Strings, which would prevent them from ever being GCed
unless the class itself were collected.
However, the article at
<http://www.javaworld.com/javaworld/javaqa/2003-12/01-qa-1212-
intern.html>
explains, and even provides evidence, that intern()ed Strings can be
and are GCed, and still maintain their semantics.
How could Java keep the promises specified for intern()ed Strings if
they're GCed?
Also, the String#intern() Javadocs state:
"A pool of strings, initially empty, is maintained privately by the
class String."
This apparently implies that the class 'String' keeps all references
to intern()ed Strings, which would prevent them from ever being GCed
unless the class itself were collected.
However, the article at
<http://www.javaworld.com/javaworld/javaqa/2003-12/01-qa-1212-
intern.html>
explains, and even provides evidence, that intern()ed Strings can be
and are GCed, and still maintain their semantics.