From: Godmar Back (gback@marker.cs.utah.edu)
Date: Sun Dec 20 1998 - 23:26:59 EST
This should answer some of our questions....
5.4 String Resolution
A constant pool entry tagged as CONSTANT_String (§4.4.3) represents
an instance of a string literal (§2.3), that is, a literal of the
built-in type java.lang.String. The Unicode characters (§2.1) of the
string literal represented by the CONSTANT_String entry are found in
the CONSTANT_Utf8 (§4.4.7) constant pool entry that the CONSTANT_String
entry references.
The Java language requires that identical string literals (that is,
literals that contain the same sequence of Unicode characters) must
reference the same instance of class String. In addition, if the method
intern is called on any string, the result is a reference to the same
class instance that would be returned if that string appeared as
a literal. Thus,
("a" + "b" + "c").intern() == "abc"
must have the value true.3
To resolve a constant pool entry tagged CONSTANT_String, the Java Virtual
Machine examines the series of Unicode characters represented by the
UTF-8 string that the CONSTANT_String entry references.
If another constant pool entry tagged CONSTANT_String and representing
the identical sequence of Unicode characters has already been resolved,
then the result of resolution is a reference to the instance of class
String created for that earlier constant pool entry.
Otherwise, if the method intern has previously been called on an instance
of class String containing a sequence of Unicode characters identical to
that represented by the constant pool entry, then the result of resolution
is a reference to that same instance of class String.
Otherwise, a new instance of class String is created containing the
sequence of Unicode characters represented by the CONSTANT_String entry;
that class instance is the result of resolution.
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:26 EDT