2020-05-05 16:27:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, 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.
|
|
|
|
*/
|
|
|
|
|
2020-02-11 20:16:23 +00:00
|
|
|
/*
|
|
|
|
* @test 8232069 for ZGC
|
|
|
|
* @requires vm.cds
|
2020-05-05 16:27:22 +00:00
|
|
|
* @requires vm.bits == 64
|
|
|
|
* @requires vm.gc.Z
|
2020-05-05 21:55:23 +00:00
|
|
|
* @comment assuming that default GC supports both UseCompressedOops and UseCompressedClassPointers
|
|
|
|
* @requires vm.gc == null
|
2020-05-05 16:27:22 +00:00
|
|
|
* @comment Graal does not support ZGC
|
|
|
|
* @requires !vm.graal.enabled
|
2020-02-11 20:16:23 +00:00
|
|
|
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
|
|
|
|
* @compile test-classes/Hello.java
|
2020-05-05 16:27:22 +00:00
|
|
|
* @run driver TestZGCWithCDS
|
2020-02-11 20:16:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import jdk.test.lib.Platform;
|
|
|
|
import jdk.test.lib.process.OutputAnalyzer;
|
|
|
|
|
|
|
|
public class TestZGCWithCDS {
|
|
|
|
public final static String HELLO = "Hello World";
|
|
|
|
public final static String UNABLE_TO_USE_ARCHIVE = "Unable to use shared archive.";
|
|
|
|
public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled.";
|
|
|
|
public static void main(String... args) throws Exception {
|
|
|
|
String helloJar = JarBuilder.build("hello", "Hello");
|
|
|
|
// 0. dump with ZGC
|
|
|
|
System.out.println("0. Dump with ZGC");
|
|
|
|
OutputAnalyzer out = TestCommon
|
|
|
|
.dump(helloJar,
|
|
|
|
new String[] {"Hello"},
|
|
|
|
"-XX:+UseZGC",
|
|
|
|
"-Xlog:cds");
|
|
|
|
out.shouldContain("Dumping shared data to file:");
|
|
|
|
out.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
// 1. Run with same args of dump
|
|
|
|
System.out.println("1. Run with same args of dump");
|
|
|
|
out = TestCommon
|
|
|
|
.exec(helloJar,
|
|
|
|
"-XX:+UseZGC",
|
|
|
|
"-Xlog:cds",
|
|
|
|
"Hello");
|
|
|
|
out.shouldContain(HELLO);
|
|
|
|
out.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
// 2. Run with ZGC turned off
|
|
|
|
System.out.println("2. Run with ZGC turned off");
|
|
|
|
out = TestCommon
|
|
|
|
.exec(helloJar,
|
|
|
|
"-XX:-UseZGC",
|
2020-03-12 16:07:11 +00:00
|
|
|
"-XX:+UseCompressedOops", // in case turned off by vmoptions
|
|
|
|
"-XX:+UseCompressedClassPointers", // by jtreg
|
2020-02-11 20:16:23 +00:00
|
|
|
"-Xlog:cds",
|
|
|
|
"Hello");
|
|
|
|
out.shouldContain(UNABLE_TO_USE_ARCHIVE);
|
|
|
|
out.shouldContain(ERR_MSG);
|
|
|
|
out.shouldHaveExitValue(1);
|
|
|
|
|
|
|
|
// 3. Run with -UseCompressedOops -UseCompressedClassPointers
|
|
|
|
System.out.println("3. Run with -UseCompressedOops -UseCompressedClassPointers");
|
|
|
|
out = TestCommon
|
|
|
|
.exec(helloJar,
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:-UseCompressedClassPointers",
|
|
|
|
"-Xlog:cds",
|
|
|
|
"Hello");
|
|
|
|
out.shouldContain(HELLO);
|
|
|
|
out.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
// 4. Run with +UseCompressedOops -UseCompressedClassPointers
|
|
|
|
System.out.println("4. Run with +UseCompressedOops -UseCompressedClassPointers");
|
|
|
|
out = TestCommon
|
|
|
|
.exec(helloJar,
|
|
|
|
"-XX:+UseCompressedOops",
|
|
|
|
"-XX:-UseCompressedClassPointers",
|
|
|
|
"-Xlog:cds",
|
|
|
|
"Hello");
|
|
|
|
out.shouldContain(UNABLE_TO_USE_ARCHIVE);
|
|
|
|
out.shouldContain(ERR_MSG);
|
|
|
|
out.shouldHaveExitValue(1);
|
|
|
|
|
|
|
|
// 5. Run with +UseCompressedOops +UseCompressedClassPointers
|
|
|
|
System.out.println("5. Run with +UseCompressedOops +UseCompressedClassPointers");
|
|
|
|
out = TestCommon
|
|
|
|
.exec(helloJar,
|
|
|
|
"-XX:+UseCompressedOops",
|
|
|
|
"-XX:+UseCompressedClassPointers",
|
|
|
|
"-Xlog:cds",
|
|
|
|
"Hello");
|
|
|
|
out.shouldContain(UNABLE_TO_USE_ARCHIVE);
|
|
|
|
out.shouldContain(ERR_MSG);
|
|
|
|
out.shouldHaveExitValue(1);
|
|
|
|
|
|
|
|
// 6. dump with -UseCompressedOops -UseCompressedClassPointers
|
|
|
|
System.out.println("6. Dump with -UseCompressedOops -UseCompressedClassPointers");
|
|
|
|
out = TestCommon
|
|
|
|
.dump(helloJar,
|
|
|
|
new String[] {"Hello"},
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:-UseCompressedClassPointers",
|
|
|
|
"-Xlog:cds");
|
|
|
|
out.shouldContain("Dumping shared data to file:");
|
|
|
|
out.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
// 7. Run with ZGC
|
|
|
|
System.out.println("7. Run with ZGC");
|
|
|
|
out = TestCommon
|
|
|
|
.exec(helloJar,
|
|
|
|
"-XX:+UseZGC",
|
|
|
|
"-Xlog:cds",
|
|
|
|
"Hello");
|
|
|
|
out.shouldContain(HELLO);
|
|
|
|
out.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
}
|