1 /* 2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test id=ZSinglegen 26 * @bug 8232069 27 * @requires vm.cds 28 * @requires vm.bits == 64 29 * @requires vm.gc.ZSinglegen 30 * @requires vm.gc.Serial 31 * @requires vm.gc == null 32 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds 33 * @compile test-classes/Hello.java 34 * @run driver TestZGCWithCDS -XX:-ZGenerational 35 */ 36 37 /* 38 * @test id=ZGenerational 39 * @bug 8232069 40 * @requires vm.cds 41 * @requires vm.bits == 64 42 * @requires vm.gc.ZGenerational 43 * @requires vm.gc.Serial 44 * @requires vm.gc == null 45 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds 46 * @compile test-classes/Hello.java 47 * @run driver TestZGCWithCDS -XX:+ZGenerational 48 */ 49 50 import jdk.test.lib.Platform; 51 import jdk.test.lib.process.OutputAnalyzer; 52 53 public class TestZGCWithCDS { 54 public final static String HELLO = "Hello World"; 55 public final static String UNABLE_TO_USE_ARCHIVE = "Unable to use shared archive."; 56 public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled."; 57 public static void main(String... args) throws Exception { 58 String zGenerational = args[0]; 59 String helloJar = JarBuilder.build("hello", "Hello"); 60 System.out.println("0. Dump with ZGC"); 61 OutputAnalyzer out = TestCommon 62 .dump(helloJar, 63 new String[] {"Hello"}, 64 "-XX:+UseZGC", 65 zGenerational, 66 "-Xlog:cds"); 67 out.shouldContain("Dumping shared data to file:"); 68 out.shouldHaveExitValue(0); 69 70 System.out.println("1. Run with same args of dump"); 71 out = TestCommon 72 .exec(helloJar, 73 "-XX:+UseZGC", 74 zGenerational, 75 "-Xlog:cds", 76 "Hello"); 77 out.shouldContain(HELLO); 78 out.shouldHaveExitValue(0); 79 80 System.out.println("2. Run with +UseCompressedOops +UseCompressedClassPointers"); 81 out = TestCommon 82 .exec(helloJar, 83 "-XX:-UseZGC", 84 "-XX:+UseCompressedOops", // in case turned off by vmoptions 85 "-XX:+UseCompressedClassPointers", // by jtreg 86 "-Xlog:cds", 87 "Hello"); 88 out.shouldContain(UNABLE_TO_USE_ARCHIVE); 89 out.shouldContain(ERR_MSG); 90 out.shouldHaveExitValue(1); 91 92 System.out.println("3. Run with -UseCompressedOops -UseCompressedClassPointers"); 93 out = TestCommon 94 .exec(helloJar, 95 "-XX:+UseSerialGC", 96 "-XX:-UseCompressedOops", 97 "-XX:-UseCompressedClassPointers", 98 "-Xlog:cds", 99 "Hello"); 100 out.shouldContain(UNABLE_TO_USE_ARCHIVE); 101 out.shouldContain(ERR_MSG); 102 out.shouldHaveExitValue(1); 103 104 System.out.println("4. Run with -UseCompressedOops +UseCompressedClassPointers"); 105 out = TestCommon 106 .exec(helloJar, 107 "-XX:+UseSerialGC", 108 "-XX:-UseCompressedOops", 109 "-XX:+UseCompressedClassPointers", 110 "-Xlog:cds", 111 "Hello"); 112 out.shouldContain(HELLO); 113 out.shouldHaveExitValue(0); 114 115 System.out.println("5. Run with +UseCompressedOops -UseCompressedClassPointers"); 116 out = TestCommon 117 .exec(helloJar, 118 "-XX:+UseSerialGC", 119 "-XX:+UseCompressedOops", 120 "-XX:-UseCompressedClassPointers", 121 "-Xlog:cds", 122 "Hello"); 123 out.shouldContain(UNABLE_TO_USE_ARCHIVE); 124 out.shouldContain(ERR_MSG); 125 out.shouldHaveExitValue(1); 126 127 System.out.println("6. Run with +UseCompressedOops +UseCompressedClassPointers"); 128 out = TestCommon 129 .exec(helloJar, 130 "-XX:+UseSerialGC", 131 "-XX:+UseCompressedOops", 132 "-XX:+UseCompressedClassPointers", 133 "-Xlog:cds", 134 "Hello"); 135 out.shouldContain(UNABLE_TO_USE_ARCHIVE); 136 out.shouldContain(ERR_MSG); 137 out.shouldHaveExitValue(1); 138 139 System.out.println("7. Dump with -UseCompressedOops -UseCompressedClassPointers"); 140 out = TestCommon 141 .dump(helloJar, 142 new String[] {"Hello"}, 143 "-XX:+UseSerialGC", 144 "-XX:-UseCompressedOops", 145 "-XX:+UseCompressedClassPointers", 146 "-Xlog:cds"); 147 out.shouldContain("Dumping shared data to file:"); 148 out.shouldHaveExitValue(0); 149 150 System.out.println("8. Run with ZGC"); 151 out = TestCommon 152 .exec(helloJar, 153 "-XX:+UseZGC", 154 zGenerational, 155 "-Xlog:cds", 156 "Hello"); 157 out.shouldContain(HELLO); 158 out.shouldHaveExitValue(0); 159 } 160 }