8272348: Update CDS tests in anticipation of JDK-8270489

Reviewed-by: ccheung, minqi
This commit is contained in:
Ioi Lam 2021-08-16 03:22:52 +00:00
parent 3f38a50c52
commit 36e2ddad4d
23 changed files with 85 additions and 56 deletions

View File

@ -1936,12 +1936,20 @@ WB_ENTRY(jboolean, WB_IsShared(JNIEnv* env, jobject wb, jobject obj))
return Universe::heap()->is_archived_object(obj_oop); return Universe::heap()->is_archived_object(obj_oop);
WB_END WB_END
WB_ENTRY(jboolean, WB_IsSharedInternedString(JNIEnv* env, jobject wb, jobject str))
ResourceMark rm(THREAD);
oop str_oop = JNIHandles::resolve(str);
int length;
jchar* chars = java_lang_String::as_unicode_string(str_oop, length, CHECK_(false));
return StringTable::lookup_shared(chars, length) == str_oop;
WB_END
WB_ENTRY(jboolean, WB_IsSharedClass(JNIEnv* env, jobject wb, jclass clazz)) WB_ENTRY(jboolean, WB_IsSharedClass(JNIEnv* env, jobject wb, jclass clazz))
return (jboolean)MetaspaceShared::is_in_shared_metaspace(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz))); return (jboolean)MetaspaceShared::is_in_shared_metaspace(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)));
WB_END WB_END
WB_ENTRY(jboolean, WB_AreSharedStringsIgnored(JNIEnv* env)) WB_ENTRY(jboolean, WB_AreSharedStringsMapped(JNIEnv* env))
return !HeapShared::closed_regions_mapped(); return HeapShared::closed_regions_mapped();
WB_END WB_END
WB_ENTRY(jobject, WB_GetResolvedReferences(JNIEnv* env, jobject wb, jclass clazz)) WB_ENTRY(jobject, WB_GetResolvedReferences(JNIEnv* env, jobject wb, jclass clazz))
@ -2625,8 +2633,9 @@ static JNINativeMethod methods[] = {
(void*)&WB_GetDefaultArchivePath}, (void*)&WB_GetDefaultArchivePath},
{CC"isSharingEnabled", CC"()Z", (void*)&WB_IsSharingEnabled}, {CC"isSharingEnabled", CC"()Z", (void*)&WB_IsSharingEnabled},
{CC"isShared", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared }, {CC"isShared", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
{CC"isSharedInternedString", CC"(Ljava/lang/String;)Z", (void*)&WB_IsSharedInternedString },
{CC"isSharedClass", CC"(Ljava/lang/Class;)Z", (void*)&WB_IsSharedClass }, {CC"isSharedClass", CC"(Ljava/lang/Class;)Z", (void*)&WB_IsSharedClass },
{CC"areSharedStringsIgnored", CC"()Z", (void*)&WB_AreSharedStringsIgnored }, {CC"areSharedStringsMapped", CC"()Z", (void*)&WB_AreSharedStringsMapped },
{CC"getResolvedReferences", CC"(Ljava/lang/Class;)Ljava/lang/Object;", (void*)&WB_GetResolvedReferences}, {CC"getResolvedReferences", CC"(Ljava/lang/Class;)Ljava/lang/Object;", (void*)&WB_GetResolvedReferences},
{CC"linkClass", CC"(Ljava/lang/Class;)V", (void*)&WB_LinkClass}, {CC"linkClass", CC"(Ljava/lang/Class;)V", (void*)&WB_LinkClass},
{CC"areOpenArchiveHeapObjectsMapped", CC"()Z", (void*)&WB_AreOpenArchiveHeapObjectsMapped}, {CC"areOpenArchiveHeapObjectsMapped", CC"()Z", (void*)&WB_AreOpenArchiveHeapObjectsMapped},

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2021, 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
@ -49,9 +49,9 @@ public class ServiceLoaderTest {
CDSTestUtils.createArchiveAndCheck(opts); CDSTestUtils.createArchiveAndCheck(opts);
// Some mach5 tiers run with -vmoptions:-Xlog:cds=debug. This would cause the outputs to mismatch. // Some mach5 tiers run with -vmoptions:-Xlog:cds=debug. This would cause the outputs to mismatch.
// Force -Xlog:cds=warning to supress the CDS logs. // Force the log level to warning for all tags to supressed the CDS logs. Also disable the timestamp.
opts.setUseVersion(false); opts.setUseVersion(false);
opts.addSuffix("-showversion", "-Xlog:cds=warning", "ServiceLoaderApp"); opts.addSuffix("-showversion", "-Xlog:all=warning::level,tags", "ServiceLoaderApp");
OutputAnalyzer out1 = CDSTestUtils.runWithArchive(opts); OutputAnalyzer out1 = CDSTestUtils.runWithArchive(opts);
opts.setXShareMode("off"); opts.setXShareMode("off");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2021, 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
@ -29,8 +29,8 @@ public class SharedStringsWb {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
if (wb.areSharedStringsIgnored()) { if (!wb.areSharedStringsMapped()) {
System.out.println("Shared strings are ignored, assuming PASS"); System.out.println("Shared strings are not mapped, assuming PASS");
return; return;
} }
@ -43,7 +43,7 @@ public class SharedStringsWb {
throw new RuntimeException("Shared string is not a valid String: FAIL"); throw new RuntimeException("Shared string is not a valid String: FAIL");
} }
if (wb.isShared(internedS)) { if (wb.isSharedInternedString(internedS)) {
System.out.println("Found shared string, result: PASS"); System.out.println("Found shared string, result: PASS");
} else { } else {
throw new RuntimeException("String is not shared, result: FAIL"); throw new RuntimeException("String is not shared, result: FAIL");

View File

@ -97,8 +97,8 @@ public class DumpClassList {
.shouldNotContain("Preload Warning: Cannot find java/lang/invoke/LambdaForm") .shouldNotContain("Preload Warning: Cannot find java/lang/invoke/LambdaForm")
.shouldNotContain("Preload Warning: Cannot find boot/append/Foo") .shouldNotContain("Preload Warning: Cannot find boot/append/Foo")
.shouldNotContain("Preload Warning: Cannot find jdk/jfr/NewClass") .shouldNotContain("Preload Warning: Cannot find jdk/jfr/NewClass")
.shouldMatch(".info..class,load *. boot.append.Foo") // from -Xlog:class+load .shouldMatch("class,load *. boot.append.Foo") // from -Xlog:class+load
.shouldMatch("cds,class.*boot boot.append.Foo") // from -Xlog:cds+class .shouldMatch("cds,class.*boot boot.append.Foo") // from -Xlog:cds+class
.shouldNotMatch(".info..class,load *. jdk.jfr.NewClass"); // from -Xlog:class+load .shouldNotMatch("class,load *. jdk.jfr.NewClass"); // from -Xlog:class+load
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2021, 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
@ -62,8 +62,8 @@ public class GCStressApp {
return; return;
} }
if (wb.areSharedStringsIgnored()) { if (!wb.areSharedStringsMapped()) {
System.out.println("Shared strings are ignored."); System.out.println("Shared strings are not mapped.");
return; return;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2021, 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
@ -55,7 +55,7 @@ public class RedefineClassApp {
static Instrumentation instrumentation; static Instrumentation instrumentation;
public static void main(String args[]) throws Throwable { public static void main(String args[]) throws Throwable {
if (wb.areSharedStringsIgnored()) { if (!wb.areSharedStringsMapped()) {
System.out.println("Shared strings are ignored."); System.out.println("Shared strings are ignored.");
return; return;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2021, 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
@ -38,7 +38,7 @@ public class GCSharedStringsDuringDumpWb {
} }
public static void CheckString(WhiteBox wb, String s) { public static void CheckString(WhiteBox wb, String s) {
if (!wb.areSharedStringsIgnored() && !wb.isShared(s)) { if (wb.areSharedStringsMapped() && !wb.isSharedInternedString(s)) {
throw new RuntimeException("String is not shared."); throw new RuntimeException("String is not shared.");
} }
} }

View File

@ -26,6 +26,7 @@
* @test * @test
* @summary Exercise GC with shared strings * @summary Exercise GC with shared strings
* @requires vm.cds.archived.java.heap * @requires vm.cds.archived.java.heap
* @requires vm.gc == null
* @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib
* @build HelloStringGC sun.hotspot.WhiteBox * @build HelloStringGC sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -26,6 +26,7 @@
* @test * @test
* @summary Test relevant combinations of command line flags with shared strings * @summary Test relevant combinations of command line flags with shared strings
* @requires vm.cds.archived.java.heap & vm.hasJFR * @requires vm.cds.archived.java.heap & vm.hasJFR
* @requires vm.gc == null
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
* @build HelloString * @build HelloString
* @run driver FlagCombo * @run driver FlagCombo
@ -36,6 +37,7 @@
* @summary Test relevant combinations of command line flags with shared strings * @summary Test relevant combinations of command line flags with shared strings
* @comment A special test excluding the case that requires JFR * @comment A special test excluding the case that requires JFR
* @requires vm.cds.archived.java.heap & !vm.hasJFR * @requires vm.cds.archived.java.heap & !vm.hasJFR
* @requires vm.gc == null
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
* @build HelloString * @build HelloString
* @run driver FlagCombo noJfr * @run driver FlagCombo noJfr

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, 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
@ -33,7 +33,7 @@ public class HelloStringGC {
String testString2 = "test123"; String testString2 = "test123";
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
if (!wb.isShared(testString1) && !wb.areSharedStringsIgnored()) { if (wb.areSharedStringsMapped() && !wb.isSharedInternedString(testString1)) {
throw new RuntimeException("testString1 is not shared"); throw new RuntimeException("testString1 is not shared");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, 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
@ -34,7 +34,7 @@ public class HelloStringPlus {
System.out.println("Hello String: " + testString1); System.out.println("Hello String: " + testString1);
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
if (!wb.isShared(testString1) && !wb.areSharedStringsIgnored()) { if (wb.areSharedStringsMapped() && !wb.isSharedInternedString(testString1)) {
throw new RuntimeException("testString1 is not shared"); throw new RuntimeException("testString1 is not shared");
} }
@ -66,7 +66,7 @@ public class HelloStringPlus {
// Check intern() method for "" string // Check intern() method for "" string
String empty = ""; String empty = "";
String empty_interned = empty.intern(); String empty_interned = empty.intern();
if (!wb.isShared(empty)) { if (wb.areSharedStringsMapped() && !wb.isSharedInternedString(empty)) {
throw new RuntimeException("Empty string should be shared"); throw new RuntimeException("Empty string should be shared");
} }
if (empty_interned != empty) { if (empty_interned != empty) {

View File

@ -26,6 +26,7 @@
* @test * @test
* @summary Test shared strings together with string intern operation * @summary Test shared strings together with string intern operation
* @requires vm.cds.archived.java.heap * @requires vm.cds.archived.java.heap
* @requires vm.gc == null
* @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib
* @compile InternStringTest.java * @compile InternStringTest.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, 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
@ -38,10 +38,12 @@ public class InternStringTest {
// All string literals are shared. // All string literals are shared.
String shared1 = "LiveOak"; String shared1 = "LiveOak";
String interned1 = shared1.intern(); String interned1 = shared1.intern();
if (wb.areSharedStringsIgnored() || wb.isShared(interned1)) { if (wb.areSharedStringsMapped()) {
System.out.println(passed_output1); if (wb.isSharedInternedString(interned1)) {
} else { System.out.println(passed_output1);
throw new RuntimeException("Failed: String is not shared."); } else {
throw new RuntimeException("Failed: String is not shared.");
}
} }
// Test 2: shared_string1.intern() == shared_string2.intern() // Test 2: shared_string1.intern() == shared_string2.intern()
@ -58,10 +60,12 @@ public class InternStringTest {
String a = "X" + latin1Sup.substring(1); String a = "X" + latin1Sup.substring(1);
String b = a.intern(); String b = a.intern();
if (wb.areSharedStringsIgnored() || wb.isShared(b)) { if (wb.areSharedStringsMapped()) {
System.out.println(passed_output3); if (wb.isSharedInternedString(b)) {
} else { System.out.println(passed_output3);
throw new RuntimeException("Failed: expected shared string with latin1-supplement chars."); } else {
throw new RuntimeException("Failed: expected shared string with latin1-supplement chars.");
}
} }
} }
@ -69,10 +73,12 @@ public class InternStringTest {
{ {
String a = "X" + nonWestern.substring(1); String a = "X" + nonWestern.substring(1);
String b = a.intern(); String b = a.intern();
if (wb.areSharedStringsIgnored() || wb.isShared(b)) { if (wb.areSharedStringsMapped()) {
System.out.println(passed_output4); if (wb.isSharedInternedString(b)) {
} else { System.out.println(passed_output4);
throw new RuntimeException("Failed: expected shared string with non-western chars."); } else {
throw new RuntimeException("Failed: expected shared string with non-western chars.");
}
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, 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
@ -26,6 +26,7 @@
* @test * @test
* @summary Basic shared string test with large pages * @summary Basic shared string test with large pages
* @requires vm.cds.archived.java.heap * @requires vm.cds.archived.java.heap
* @requires vm.gc == null
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
* @build HelloString * @build HelloString
* @run driver LargePages * @run driver LargePages

View File

@ -26,6 +26,7 @@
* @test * @test
* @summary Test locking on shared strings * @summary Test locking on shared strings
* @requires vm.cds.archived.java.heap * @requires vm.cds.archived.java.heap
* @requires vm.gc == null
* @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib
* @compile LockStringTest.java LockStringValueTest.java * @compile LockStringTest.java LockStringValueTest.java
* @build sun.hotspot.WhiteBox * @build sun.hotspot.WhiteBox

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, 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
@ -31,13 +31,13 @@ public class LockStringTest extends Thread {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (wb.areSharedStringsIgnored()) { if (!wb.areSharedStringsMapped()) {
System.out.println("The shared strings are ignored"); System.out.println("The shared strings are not mapped");
System.out.println("LockStringTest: PASS"); System.out.println("LockStringTest: PASS");
return; return;
} }
if (!wb.isShared(LockStringTest.class)) { if (!wb.isSharedClass(LockStringTest.class)) {
throw new RuntimeException("Failed: LockStringTest class is not shared."); throw new RuntimeException("Failed: LockStringTest class is not shared.");
} }
@ -57,7 +57,7 @@ public class LockStringTest extends Thread {
lock = s; lock = s;
done = false; done = false;
if (!wb.isShared(lock)) { if (!wb.isSharedInternedString(lock)) {
throw new RuntimeException("Failed: String \"" + lock + "\" is not shared."); throw new RuntimeException("Failed: String \"" + lock + "\" is not shared.");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, 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
@ -33,13 +33,13 @@ public class LockStringValueTest {
String s = "LiveOak"; String s = "LiveOak";
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
if (wb.areSharedStringsIgnored()) { if (!wb.areSharedStringsMapped()) {
System.out.println("The shared strings are ignored"); System.out.println("The shared strings are not mapped");
System.out.println("LockStringValueTest: PASS"); System.out.println("LockStringValueTest: PASS");
return; return;
} }
if (!wb.isShared(s)) { if (!wb.isSharedInternedString(s)) {
throw new RuntimeException("LockStringValueTest Failed: String is not shared."); throw new RuntimeException("LockStringValueTest Failed: String is not shared.");
} }

View File

@ -26,6 +26,7 @@
* @test * @test
* @summary Basic plus test for shared strings * @summary Basic plus test for shared strings
* @requires vm.cds.archived.java.heap * @requires vm.cds.archived.java.heap
* @requires vm.gc == null
* @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib
* @build HelloStringPlus sun.hotspot.WhiteBox * @build HelloStringPlus sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, 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
@ -29,10 +29,12 @@ public class SharedStringsWb {
WhiteBox wb = WhiteBox.getWhiteBox(); WhiteBox wb = WhiteBox.getWhiteBox();
String s = "shared_test_string_unique_14325"; String s = "shared_test_string_unique_14325";
s = s.intern(); s = s.intern();
if (wb.areSharedStringsIgnored() || wb.isShared(s)) { if (wb.areSharedStringsMapped()) {
System.out.println("Found shared string."); if (wb.isSharedInternedString(s)) {
} else { System.out.println("Found shared string.");
throw new RuntimeException("String is not shared."); } else {
throw new RuntimeException("String is not shared.");
}
} }
} }
} }

View File

@ -26,6 +26,7 @@
* @test * @test
* @summary White box test for shared strings * @summary White box test for shared strings
* @requires vm.cds.archived.java.heap * @requires vm.cds.archived.java.heap
* @requires vm.gc == null
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
* @build sun.hotspot.WhiteBox SharedStringsWb * @build sun.hotspot.WhiteBox SharedStringsWb
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -27,6 +27,7 @@
* @summary Regression test for JDK-8098821 * @summary Regression test for JDK-8098821
* @bug 8098821 * @bug 8098821
* @requires vm.cds.archived.java.heap * @requires vm.cds.archived.java.heap
* @requires vm.gc == null
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
* @run driver SysDictCrash * @run driver SysDictCrash
*/ */

View File

@ -310,7 +310,7 @@ public class WhiteBox {
makeMethodNotCompilable0(method, compLevel, isOsr); makeMethodNotCompilable0(method, compLevel, isOsr);
} }
public int getMethodCompilationLevel(Executable method) { public int getMethodCompilationLevel(Executable method) {
return getMethodCompilationLevel(method, false /*not ost*/); return getMethodCompilationLevel(method, false /*not osr*/);
} }
private native int getMethodCompilationLevel0(Executable method, boolean isOsr); private native int getMethodCompilationLevel0(Executable method, boolean isOsr);
public int getMethodCompilationLevel(Executable method, boolean isOsr) { public int getMethodCompilationLevel(Executable method, boolean isOsr) {
@ -591,7 +591,8 @@ public class WhiteBox {
public native boolean isSharingEnabled(); public native boolean isSharingEnabled();
public native boolean isShared(Object o); public native boolean isShared(Object o);
public native boolean isSharedClass(Class<?> c); public native boolean isSharedClass(Class<?> c);
public native boolean areSharedStringsIgnored(); public native boolean areSharedStringsMapped();
public native boolean isSharedInternedString(String s);
public native boolean isCDSIncluded(); public native boolean isCDSIncluded();
public native boolean isJFRIncluded(); public native boolean isJFRIncluded();
public native boolean isJavaHeapArchiveSupported(); public native boolean isJavaHeapArchiveSupported();
@ -605,6 +606,7 @@ public class WhiteBox {
// Handshakes // Handshakes
public native int handshakeWalkStack(Thread t, boolean all_threads); public native int handshakeWalkStack(Thread t, boolean all_threads);
public native boolean handshakeReadMonitors(Thread t);
public native void asyncHandshakeWalkStack(Thread t); public native void asyncHandshakeWalkStack(Thread t);
public native void lockAndBlock(boolean suspender); public native void lockAndBlock(boolean suspender);

View File

@ -592,7 +592,8 @@ public class WhiteBox {
public native boolean isSharingEnabled(); public native boolean isSharingEnabled();
public native boolean isShared(Object o); public native boolean isShared(Object o);
public native boolean isSharedClass(Class<?> c); public native boolean isSharedClass(Class<?> c);
public native boolean areSharedStringsIgnored(); public native boolean areSharedStringsMapped();
public native boolean isSharedInternedString(String s);
public native boolean isCDSIncluded(); public native boolean isCDSIncluded();
public native boolean isJFRIncluded(); public native boolean isJFRIncluded();
public native boolean isJavaHeapArchiveSupported(); public native boolean isJavaHeapArchiveSupported();