Path: blob/master/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java
40942 views
/*1* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @requires vm.cds26* @bug 800593327* @summary -Xshare:auto is the default when -Xshare is not specified28* @library /test/lib29* @modules java.base/jdk.internal.misc30* java.management31* @run driver XShareAuto32*/3334import jdk.test.lib.Platform;35import jdk.test.lib.process.ProcessTools;36import jdk.test.lib.process.OutputAnalyzer;3738public class XShareAuto {39public static void main(String[] args) throws Exception {40ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(41"-server", "-XX:+UnlockDiagnosticVMOptions",42"-XX:SharedArchiveFile=./XShareAuto.jsa", "-Xshare:dump", "-Xlog:cds");43OutputAnalyzer output = new OutputAnalyzer(pb.start());44output.shouldContain("Loading classes to share");45output.shouldHaveExitValue(0);464748// We have 2 test cases:49String cases[] = {50"-Xshare:auto", // case [1]: -Xshare:auto is explicitly specified.51"-showversion" // case [2]: -Xshare:auto is not explicitly specified,52// but VM should still use it by default.53};5455for (String x : cases) {56pb = ProcessTools.createJavaProcessBuilder(57"-XX:+UnlockDiagnosticVMOptions",58"-XX:SharedArchiveFile=./XShareAuto.jsa",59"-Xlog:cds",60x,61"-version");62output = new OutputAnalyzer(pb.start());63String outputString = output.getOutput();6465if (!outputString.contains("Unable to map")) {66// sharing may not be enabled if XShareAuto.jsa cannot be mapped due to67// ASLR.68output.shouldContain("sharing");69}70output.shouldHaveExitValue(0);71}72}73}747576