-
Bug
-
Resolution: Fixed
-
P3
-
None
-
b27
I both of the following classes are stored in a static CDS archive, the "xxxx123yyyy456" string is not stored in the interned string table. As a result, the test will fail with the RuntimeException
public super class OldClassWithStaticString
version 49:0
{
public static final Field s:"Ljava/lang/String;" = String "xxxx123yyyy456";
public static final Field t:"Ljava/lang/String;" = String "OldClassWithStaticString";
Method "<init>":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}
}
class StaticStringInOldClassApp {
static String a = "xxxx123";
public static void main(String args[]) throws Exception {
System.out.println("Hello");
String x = (a + "yyyy456").intern();
Class c = OldClassWithStaticString.class;
Field f = c.getField("s");
String y = (String)(f.get(null));
if (x != y) {
throw new RuntimeException("Interned strings not equal: " +
"\"" + x + "\" @ " + System.identityHashCode(x) + " vs " +
"\"" + y + "\" @ " + System.identityHashCode(y));
}
}
}
public super class OldClassWithStaticString
version 49:0
{
public static final Field s:"Ljava/lang/String;" = String "xxxx123yyyy456";
public static final Field t:"Ljava/lang/String;" = String "OldClassWithStaticString";
Method "<init>":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}
}
class StaticStringInOldClassApp {
static String a = "xxxx123";
public static void main(String args[]) throws Exception {
System.out.println("Hello");
String x = (a + "yyyy456").intern();
Class c = OldClassWithStaticString.class;
Field f = c.getField("s");
String y = (String)(f.get(null));
if (x != y) {
throw new RuntimeException("Interned strings not equal: " +
"\"" + x + "\" @ " + System.identityHashCode(x) + " vs " +
"\"" + y + "\" @ " + System.identityHashCode(y));
}
}
}
- links to
-
Commit(master) openjdk/jdk/68b1b94d
-
Review(master) openjdk/jdk/22340