2015-01-12 11:37:58 -08:00
|
|
|
/*
|
2022-08-22 03:43:27 +00:00
|
|
|
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
2015-01-12 11:37:58 -08: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.
|
|
|
|
*/
|
|
|
|
|
2017-08-03 10:24:34 +02:00
|
|
|
/**
|
2015-01-12 11:37:58 -08:00
|
|
|
* @test
|
2017-08-03 10:24:34 +02:00
|
|
|
* @requires vm.cds
|
2021-08-17 03:45:26 +00:00
|
|
|
* @requires vm.flagless
|
2018-03-29 21:48:38 -07:00
|
|
|
* @bug 8067187 8200078
|
2015-01-12 11:37:58 -08:00
|
|
|
* @summary Testing CDS dumping with the -XX:MaxMetaspaceSize=<size> option
|
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
|
2020-04-29 19:51:45 -07:00
|
|
|
* @run driver MaxMetaspaceSize
|
2015-01-12 11:37:58 -08:00
|
|
|
*/
|
|
|
|
|
2017-10-18 18:49:54 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2017-05-23 20:14:52 -07:00
|
|
|
import jdk.test.lib.cds.CDSTestUtils;
|
2016-08-19 10:06:30 -04:00
|
|
|
import jdk.test.lib.process.ProcessTools;
|
2017-10-18 18:49:54 -04:00
|
|
|
import jdk.test.lib.Platform;
|
2015-01-12 11:37:58 -08:00
|
|
|
|
|
|
|
public class MaxMetaspaceSize {
|
|
|
|
public static void main(String[] args) throws Exception {
|
2017-10-18 18:49:54 -04:00
|
|
|
ArrayList<String> processArgs = new ArrayList<>();
|
|
|
|
processArgs.add("-Xshare:dump");
|
|
|
|
|
|
|
|
if (Platform.is64bit()) {
|
|
|
|
processArgs.add("-XX:MaxMetaspaceSize=3m");
|
|
|
|
processArgs.add("-XX:CompressedClassSpaceSize=1m");
|
|
|
|
} else {
|
|
|
|
processArgs.add("-XX:MaxMetaspaceSize=1m");
|
|
|
|
}
|
|
|
|
|
2022-08-22 03:43:27 +00:00
|
|
|
String msg = "OutOfMemoryError: ((Metaspace)|(Compressed class space))";
|
2020-04-29 08:52:18 +02:00
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(processArgs);
|
2022-08-22 03:43:27 +00:00
|
|
|
CDSTestUtils.executeAndLog(pb, "dump").shouldMatch(msg).shouldHaveExitValue(1);
|
2015-01-12 11:37:58 -08:00
|
|
|
}
|
|
|
|
}
|