1 /* 2 * Copyright (c) 2013, 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 26 * @bug 8003424 27 * @summary Test that cannot use CDS if UseCompressedClassPointers is turned off. 28 * @library /testlibrary 29 * @build com.oracle.java.testlibrary.* 30 * @run main CDSCompressedKPtrsError 31 */ 32 33 import com.oracle.java.testlibrary.*; 34 35 public class CDSCompressedKPtrsError { 36 public static void main(String[] args) throws Exception { 37 ProcessBuilder pb; 38 if (Platform.is64bit()) { 39 pb = ProcessTools.createJavaProcessBuilder( 40 "-XX:+UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", 41 "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump"); 42 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 43 try { 44 output.shouldContain("Loading classes to share"); 45 output.shouldHaveExitValue(0); 46 47 pb = ProcessTools.createJavaProcessBuilder( 48 "-XX:-UseCompressedClassPointers", "-XX:-UseCompressedOops", 49 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:on", "-version"); 50 output = new OutputAnalyzer(pb.start()); 51 output.shouldContain("Unable to use shared archive"); 52 output.shouldHaveExitValue(0); 53 54 pb = ProcessTools.createJavaProcessBuilder( 55 "-XX:-UseCompressedClassPointers", "-XX:+UseCompressedOops", 56 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:on", "-version"); 57 output = new OutputAnalyzer(pb.start()); 58 output.shouldContain("Unable to use shared archive"); 59 output.shouldHaveExitValue(0); 60 61 pb = ProcessTools.createJavaProcessBuilder( 62 "-XX:+UseCompressedClassPointers", "-XX:-UseCompressedOops", 63 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:on", "-version"); 64 output = new OutputAnalyzer(pb.start()); 65 output.shouldContain("Unable to use shared archive"); 66 output.shouldHaveExitValue(0); 67 68 } catch (RuntimeException e) { 69 output.shouldContain("Unable to use shared archive"); 70 output.shouldHaveExitValue(1); 71 } 72 73 // Test bad options with -Xshare:dump. 74 pb = ProcessTools.createJavaProcessBuilder( 75 "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", 76 "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump"); 77 output = new OutputAnalyzer(pb.start()); 78 output.shouldContain("Cannot dump shared archive"); 79 80 pb = ProcessTools.createJavaProcessBuilder( 81 "-XX:+UseCompressedOops", "-XX:-UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", 82 "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump"); 83 output = new OutputAnalyzer(pb.start()); 84 output.shouldContain("Cannot dump shared archive"); 85 86 pb = ProcessTools.createJavaProcessBuilder( 87 "-XX:-UseCompressedOops", "-XX:-UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", 88 "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump"); 89 output = new OutputAnalyzer(pb.start()); 90 output.shouldContain("Cannot dump shared archive"); 91 92 } 93 } 94 }