8329470: Remove obsolete CDS SharedStrings tests
Reviewed-by: ccheung
This commit is contained in:
parent
8267d6565d
commit
802018306f
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @test
|
|
||||||
* @summary Test locking on shared strings
|
|
||||||
* @requires vm.cds.write.archived.java.heap
|
|
||||||
* @requires vm.gc == null
|
|
||||||
* @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib
|
|
||||||
* @compile LockStringTest.java LockStringValueTest.java
|
|
||||||
* @build jdk.test.whitebox.WhiteBox
|
|
||||||
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
|
|
||||||
* @run driver LockSharedStrings
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class LockSharedStrings {
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
SharedStringsUtils.run(args, LockSharedStrings::test);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void test(String[] args) throws Exception {
|
|
||||||
SharedStringsUtils.buildJarAndWhiteBox("LockStringTest", "LockStringValueTest");
|
|
||||||
|
|
||||||
SharedStringsUtils.dumpWithWhiteBox(
|
|
||||||
TestCommon.list("LockStringTest", "LockStringValueTest"),
|
|
||||||
"ExtraSharedInput.txt", "-Xlog:cds,cds+hashtables");
|
|
||||||
|
|
||||||
String[] extraMatch = new String[] {"LockStringTest: PASS"};
|
|
||||||
SharedStringsUtils.runWithArchiveAndWhiteBox(extraMatch, "LockStringTest");
|
|
||||||
|
|
||||||
extraMatch = new String[] {"LockStringValueTest: PASS"};
|
|
||||||
SharedStringsUtils.runWithArchiveAndWhiteBox(extraMatch, "LockStringValueTest",
|
|
||||||
"--add-opens=java.base/java.lang=ALL-UNNAMED");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import jdk.test.whitebox.WhiteBox;
|
|
||||||
|
|
||||||
public class LockStringTest extends Thread {
|
|
||||||
static String lock;
|
|
||||||
static boolean done;
|
|
||||||
static WhiteBox wb = WhiteBox.getWhiteBox();
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
|
|
||||||
if (!wb.areSharedStringsMapped()) {
|
|
||||||
System.out.println("The shared strings are not mapped");
|
|
||||||
System.out.println("LockStringTest: PASS");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wb.isSharedClass(LockStringTest.class)) {
|
|
||||||
throw new RuntimeException("Failed: LockStringTest class is not shared.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: This class is archived. All string literals (including the ones used in this class)
|
|
||||||
// in all archived classes are interned into the CDS shared string table.
|
|
||||||
|
|
||||||
doTest("StringLock", false);
|
|
||||||
doTest("", true);
|
|
||||||
|
|
||||||
// The following string has a 0 hashCode. Calling String.hashCode() could cause
|
|
||||||
// the String.hash field to be written into, if so make sure we don't functionally
|
|
||||||
// break.
|
|
||||||
doTest("\u0121\u0151\u00a2\u0001\u0001\udbb2", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void doTest(String s, boolean hasZeroHashCode) throws Exception {
|
|
||||||
lock = s;
|
|
||||||
done = false;
|
|
||||||
|
|
||||||
if (!wb.isSharedInternedString(lock)) {
|
|
||||||
throw new RuntimeException("Failed: String \"" + lock + "\" is not shared.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasZeroHashCode && lock.hashCode() != 0) {
|
|
||||||
throw new RuntimeException("Shared string \"" + lock + "\" should have 0 hashCode, but is instead " + lock.hashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
String copy = new String(lock);
|
|
||||||
if (lock.hashCode() != copy.hashCode()) {
|
|
||||||
throw new RuntimeException("Shared string \"" + lock + "\" does not have the same hashCode as its non-shared copy");
|
|
||||||
}
|
|
||||||
|
|
||||||
new LockStringTest().start();
|
|
||||||
|
|
||||||
synchronized(lock) {
|
|
||||||
while (!done) {
|
|
||||||
lock.wait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.gc();
|
|
||||||
System.out.println("LockStringTest: PASS");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
String shared = "LiveOak";
|
|
||||||
synchronized (lock) {
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
new String(shared);
|
|
||||||
System.gc();
|
|
||||||
try {
|
|
||||||
sleep(5);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
|
||||||
done = true;
|
|
||||||
lock.notify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
|
||||||
import jdk.test.whitebox.WhiteBox;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lock the 'value' field of a known shared string, java.lang.Object
|
|
||||||
*/
|
|
||||||
public class LockStringValueTest {
|
|
||||||
public static void main(String args[]) {
|
|
||||||
String s = "LiveOak";
|
|
||||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
|
||||||
|
|
||||||
if (!wb.areSharedStringsMapped()) {
|
|
||||||
System.out.println("The shared strings are not mapped");
|
|
||||||
System.out.println("LockStringValueTest: PASS");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wb.isSharedInternedString(s)) {
|
|
||||||
throw new RuntimeException("LockStringValueTest Failed: String is not shared.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Class c = s.getClass();
|
|
||||||
try {
|
|
||||||
Field f = c.getDeclaredField("value");
|
|
||||||
f.setAccessible(true);
|
|
||||||
Object v = f.get(s);
|
|
||||||
lock(v);
|
|
||||||
} catch (NoSuchFieldException nfe) {
|
|
||||||
} catch (IllegalAccessException iae) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void lock(Object o) {
|
|
||||||
synchronized (o) {
|
|
||||||
System.out.println("LockStringValueTest: PASS");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -37,7 +37,6 @@ import java.io.PrintWriter;
|
|||||||
import jdk.test.lib.cds.CDSOptions;
|
import jdk.test.lib.cds.CDSOptions;
|
||||||
import jdk.test.lib.cds.CDSTestUtils;
|
import jdk.test.lib.cds.CDSTestUtils;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
|
||||||
|
|
||||||
public class SharedStringsStress {
|
public class SharedStringsStress {
|
||||||
static {
|
static {
|
||||||
@ -69,37 +68,17 @@ public class SharedStringsStress {
|
|||||||
String vmOptionsPrefix[] = SharedStringsUtils.getChildVMOptionsPrefix();
|
String vmOptionsPrefix[] = SharedStringsUtils.getChildVMOptionsPrefix();
|
||||||
String appJar = JarBuilder.build("SharedStringsStress", "HelloString");
|
String appJar = JarBuilder.build("SharedStringsStress", "HelloString");
|
||||||
|
|
||||||
String test_cases[][] = {
|
OutputAnalyzer dumpOutput = TestCommon.dump(appJar, TestCommon.list("HelloString"),
|
||||||
// default heap size
|
TestCommon.concat(vmOptionsPrefix,
|
||||||
{},
|
"-XX:SharedArchiveConfigFile=" + sharedArchiveConfigFile,
|
||||||
|
"-Xlog:gc+region+cds",
|
||||||
|
"-Xlog:gc+region=trace"));
|
||||||
|
TestCommon.checkDump(dumpOutput);
|
||||||
|
dumpOutput.shouldContain("string table array (primary)");
|
||||||
|
dumpOutput.shouldContain("string table array (secondary)");
|
||||||
|
|
||||||
// Test for handling of heap fragmentation. With sharedArchiveConfigFile, we will dump about
|
OutputAnalyzer execOutput = TestCommon.exec(appJar,
|
||||||
// 18MB of shared objects on 64 bit VM (smaller on 32-bit).
|
TestCommon.concat(vmOptionsPrefix, "-Xlog:cds", "HelloString"));
|
||||||
//
|
TestCommon.checkExec(execOutput);
|
||||||
// During dump time, an extra copy of these objects are allocated,
|
|
||||||
// so we need about 36MB, plus a few MB for other system data. So 64MB total heap
|
|
||||||
// should be enough.
|
|
||||||
//
|
|
||||||
// The VM should executed a full GC to maximize contiguous free space and
|
|
||||||
// avoid fragmentation.
|
|
||||||
{"-Xmx64m"},
|
|
||||||
};
|
|
||||||
|
|
||||||
for (String[] extra_opts: test_cases) {
|
|
||||||
vmOptionsPrefix = TestCommon.concat(vmOptionsPrefix, extra_opts);
|
|
||||||
|
|
||||||
OutputAnalyzer dumpOutput = TestCommon.dump(appJar, TestCommon.list("HelloString"),
|
|
||||||
TestCommon.concat(vmOptionsPrefix,
|
|
||||||
"-XX:SharedArchiveConfigFile=" + sharedArchiveConfigFile,
|
|
||||||
"-Xlog:gc+region+cds",
|
|
||||||
"-Xlog:gc+region=trace"));
|
|
||||||
TestCommon.checkDump(dumpOutput);
|
|
||||||
dumpOutput.shouldContain("string table array (primary)");
|
|
||||||
dumpOutput.shouldContain("string table array (secondary)");
|
|
||||||
|
|
||||||
OutputAnalyzer execOutput = TestCommon.exec(appJar,
|
|
||||||
TestCommon.concat(vmOptionsPrefix, "-Xlog:cds", "HelloString"));
|
|
||||||
TestCommon.checkExec(execOutput);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user