2013-08-15 20:04:10 -04:00
|
|
|
/*
|
2016-08-19 10:06:30 -04:00
|
|
|
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
2013-08-15 20:04:10 -04:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @test
|
|
|
|
* @bug 8005933
|
|
|
|
* @summary Test that -Xshare:auto uses CDS when explicitly specified with -server.
|
2016-08-19 10:06:30 -04:00
|
|
|
* @library /test/lib
|
2016-04-09 23:03:39 +01:00
|
|
|
* @modules java.base/jdk.internal.misc
|
2015-03-26 16:36:56 +01:00
|
|
|
* java.management
|
2013-08-15 20:04:10 -04:00
|
|
|
* @run main XShareAuto
|
|
|
|
*/
|
|
|
|
|
2016-08-19 10:06:30 -04:00
|
|
|
import jdk.test.lib.Platform;
|
|
|
|
import jdk.test.lib.process.ProcessTools;
|
|
|
|
import jdk.test.lib.process.OutputAnalyzer;
|
2013-08-15 20:04:10 -04:00
|
|
|
|
|
|
|
public class XShareAuto {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
2013-09-19 11:04:23 -04:00
|
|
|
"-server", "-XX:+UnlockDiagnosticVMOptions",
|
2015-03-30 08:28:07 -07:00
|
|
|
"-XX:SharedArchiveFile=./XShareAuto.jsa", "-Xshare:dump");
|
2013-08-15 20:04:10 -04:00
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("Loading classes to share");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-server", "-XX:+UnlockDiagnosticVMOptions",
|
2015-03-30 08:28:07 -07:00
|
|
|
"-XX:SharedArchiveFile=./XShareAuto.jsa", "-version");
|
2013-08-15 20:04:10 -04:00
|
|
|
output = new OutputAnalyzer(pb.start());
|
2014-06-22 21:23:32 -04:00
|
|
|
// We asked for server but it could be aliased to something else
|
|
|
|
if (output.getOutput().contains("Server VM")) {
|
|
|
|
// In server case we don't expect to see sharing flag
|
|
|
|
output.shouldNotContain("sharing");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
System.out.println("Skipping test - no Server VM available");
|
|
|
|
return;
|
|
|
|
}
|
2013-08-15 20:04:10 -04:00
|
|
|
|
|
|
|
pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-server", "-Xshare:auto", "-XX:+UnlockDiagnosticVMOptions",
|
2015-03-30 08:28:07 -07:00
|
|
|
"-XX:SharedArchiveFile=./XShareAuto.jsa", "-XX:+PrintSharedSpaces", "-version");
|
2013-08-15 20:04:10 -04:00
|
|
|
output = new OutputAnalyzer(pb.start());
|
|
|
|
try {
|
|
|
|
output.shouldContain("sharing");
|
|
|
|
} catch (RuntimeException e) {
|
2014-03-10 14:50:20 -04:00
|
|
|
// if sharing failed due to ASLR or similar reasons,
|
|
|
|
// check whether sharing was attempted at all (UseSharedSpaces)
|
|
|
|
output.shouldContain("UseSharedSpaces:");
|
2016-04-27 11:40:43 -07:00
|
|
|
output.shouldNotContain("Unable to map %s");
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
2014-03-10 14:50:20 -04:00
|
|
|
output.shouldHaveExitValue(0);
|
2013-08-15 20:04:10 -04:00
|
|
|
}
|
|
|
|
}
|