test/runtime/CDSCompressedKPtrs/XShareAuto.java

Mon, 12 Aug 2013 17:37:02 +0200

author
ehelin
date
Mon, 12 Aug 2013 17:37:02 +0200
changeset 5694
7944aba7ba41
parent 5625
35b99e7e0af2
child 5748
9ed97b511b26
permissions
-rw-r--r--

8015107: NPG: Use consistent naming for metaspace concepts
Reviewed-by: coleenp, mgerdin, hseigel

hseigel@5528 1 /*
hseigel@5528 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
hseigel@5528 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hseigel@5528 4 *
hseigel@5528 5 * This code is free software; you can redistribute it and/or modify it
hseigel@5528 6 * under the terms of the GNU General Public License version 2 only, as
hseigel@5528 7 * published by the Free Software Foundation.
hseigel@5528 8 *
hseigel@5528 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hseigel@5528 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hseigel@5528 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hseigel@5528 12 * version 2 for more details (a copy is included in the LICENSE file that
hseigel@5528 13 * accompanied this code).
hseigel@5528 14 *
hseigel@5528 15 * You should have received a copy of the GNU General Public License version
hseigel@5528 16 * 2 along with this work; if not, write to the Free Software Foundation,
hseigel@5528 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hseigel@5528 18 *
hseigel@5528 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hseigel@5528 20 * or visit www.oracle.com if you need additional information or have any
hseigel@5528 21 * questions.
hseigel@5528 22 */
hseigel@5528 23
hseigel@5528 24 /*
hseigel@5528 25 * @test
hseigel@5528 26 * @bug 8005933
hseigel@5528 27 * @summary Test that -Xshare:auto uses CDS when explicitly specified with -server.
hseigel@5528 28 * @library /testlibrary
hseigel@5528 29 * @run main XShareAuto
hseigel@5528 30 */
hseigel@5528 31
hseigel@5528 32 import com.oracle.java.testlibrary.*;
hseigel@5528 33
hseigel@5528 34 public class XShareAuto {
hseigel@5528 35 public static void main(String[] args) throws Exception {
hseigel@5528 36 if (!Platform.is64bit()) {
hseigel@5528 37 System.out.println("ObjectAlignmentInBytes for CDS is only " +
hseigel@5528 38 "supported on 64bit platforms; this plaform is " +
hseigel@5528 39 System.getProperty("sun.arch.data.model"));
hseigel@5528 40 System.out.println("Skipping the test");
hseigel@5528 41 return;
hseigel@5528 42 }
hseigel@5528 43 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
hseigel@5528 44 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
hseigel@5528 45 "-Xshare:dump");
hseigel@5528 46 OutputAnalyzer output = new OutputAnalyzer(pb.start());
hseigel@5528 47 output.shouldContain("Loading classes to share");
hseigel@5528 48 output.shouldHaveExitValue(0);
hseigel@5528 49
hseigel@5528 50 pb = ProcessTools.createJavaProcessBuilder(
hseigel@5528 51 "-server", "-XX:+UnlockDiagnosticVMOptions",
hseigel@5528 52 "-XX:SharedArchiveFile=./sample.jsa", "-version");
hseigel@5528 53 output = new OutputAnalyzer(pb.start());
hseigel@5528 54 output.shouldNotContain("sharing");
hseigel@5528 55 output.shouldHaveExitValue(0);
hseigel@5528 56
hseigel@5528 57 pb = ProcessTools.createJavaProcessBuilder(
hseigel@5528 58 "-server", "-Xshare:auto", "-XX:+UnlockDiagnosticVMOptions",
hseigel@5528 59 "-XX:SharedArchiveFile=./sample.jsa", "-version");
hseigel@5528 60 output = new OutputAnalyzer(pb.start());
hseigel@5528 61 try {
hseigel@5528 62 output.shouldContain("sharing");
hseigel@5528 63 output.shouldHaveExitValue(0);
hseigel@5528 64 } catch (RuntimeException e) {
hseigel@5528 65 // If this failed then check that it would also be unable
hseigel@5528 66 // to share even if -Xshare:on is specified. If so, then
hseigel@5528 67 // return a success status.
hseigel@5528 68 pb = ProcessTools.createJavaProcessBuilder(
hseigel@5528 69 "-server", "-Xshare:on", "-XX:+UnlockDiagnosticVMOptions",
hseigel@5528 70 "-XX:SharedArchiveFile=./sample.jsa", "-version");
hseigel@5528 71 output = new OutputAnalyzer(pb.start());
hseigel@5625 72 output.shouldContain("Unable to use shared archive");
hseigel@5528 73 output.shouldHaveExitValue(1);
hseigel@5528 74 }
hseigel@5528 75 }
hseigel@5528 76 }

mercurial