test/runtime/SharedArchiveFile/ArchiveDoesNotExist.java

Mon, 06 Nov 2017 16:51:47 +0800

author
aoqi
date
Mon, 06 Nov 2017 16:51:47 +0800
changeset 7997
6cbff0651f1a
parent 7202
9c8439756c05
permissions
-rw-r--r--

[Code Reorganization] remove trailing whitespace to pass jcheck test

mseledtsov@7202 1 /*
mseledtsov@7202 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
mseledtsov@7202 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mseledtsov@7202 4 *
mseledtsov@7202 5 * This code is free software; you can redistribute it and/or modify it
mseledtsov@7202 6 * under the terms of the GNU General Public License version 2 only, as
mseledtsov@7202 7 * published by the Free Software Foundation.
mseledtsov@7202 8 *
mseledtsov@7202 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mseledtsov@7202 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mseledtsov@7202 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mseledtsov@7202 12 * version 2 for more details (a copy is included in the LICENSE file that
mseledtsov@7202 13 * accompanied this code).
mseledtsov@7202 14 *
mseledtsov@7202 15 * You should have received a copy of the GNU General Public License version
mseledtsov@7202 16 * 2 along with this work; if not, write to the Free Software Foundation,
mseledtsov@7202 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mseledtsov@7202 18 *
mseledtsov@7202 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mseledtsov@7202 20 * or visit www.oracle.com if you need additional information or have any
mseledtsov@7202 21 * questions.
mseledtsov@7202 22 */
mseledtsov@7202 23
mseledtsov@7202 24 /*
mseledtsov@7202 25 * @test ArchiveDoesNotExist
mseledtsov@7202 26 * @summary Test how VM handles "file does not exist" situation while
mseledtsov@7202 27 * attempting to use CDS archive. JVM should exit gracefully
mseledtsov@7202 28 * when sharing mode is ON, and continue w/o sharing if sharing
mseledtsov@7202 29 * mode is AUTO.
mseledtsov@7202 30 * @library /testlibrary
mseledtsov@7202 31 * @run main ArchiveDoesNotExist
mseledtsov@7202 32 */
mseledtsov@7202 33
mseledtsov@7202 34 import com.oracle.java.testlibrary.*;
mseledtsov@7202 35 import java.io.File;
mseledtsov@7202 36
mseledtsov@7202 37 public class ArchiveDoesNotExist {
mseledtsov@7202 38 public static void main(String[] args) throws Exception {
mseledtsov@7202 39 String fileName = "test.jsa";
mseledtsov@7202 40
mseledtsov@7202 41 File cdsFile = new File(fileName);
mseledtsov@7202 42 if (cdsFile.exists())
mseledtsov@7202 43 throw new RuntimeException("Test error: cds file already exists");
mseledtsov@7202 44
mseledtsov@7202 45 // Sharing: on
mseledtsov@7202 46 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
mseledtsov@7202 47 "-XX:+UnlockDiagnosticVMOptions",
mseledtsov@7202 48 "-XX:SharedArchiveFile=./" + fileName,
mseledtsov@7202 49 "-Xshare:on",
mseledtsov@7202 50 "-version");
mseledtsov@7202 51
mseledtsov@7202 52 OutputAnalyzer output = new OutputAnalyzer(pb.start());
mseledtsov@7202 53 output.shouldContain("Specified shared archive not found");
mseledtsov@7202 54 output.shouldHaveExitValue(1);
mseledtsov@7202 55
mseledtsov@7202 56 // Sharing: auto
mseledtsov@7202 57 pb = ProcessTools.createJavaProcessBuilder(
mseledtsov@7202 58 "-XX:+UnlockDiagnosticVMOptions",
mseledtsov@7202 59 "-XX:SharedArchiveFile=./" + fileName,
mseledtsov@7202 60 "-Xshare:auto",
mseledtsov@7202 61 "-version");
mseledtsov@7202 62
mseledtsov@7202 63 output = new OutputAnalyzer(pb.start());
mseledtsov@7202 64 output.shouldMatch("(java|openjdk) version");
mseledtsov@7202 65 output.shouldNotContain("sharing");
mseledtsov@7202 66 output.shouldHaveExitValue(0);
mseledtsov@7202 67 }
mseledtsov@7202 68 }

mercurial