5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import jdk.test.lib.Asserts; 25 import jdk.test.lib.OutputAnalyzer; 26 import jdk.test.lib.ProcessTools; 27 28 /* 29 * @test TestMetaspaceSizeFlags 30 * @key gc 31 * @bug 8024650 32 * @summary Test that metaspace size flags can be set correctly 33 * @library /testlibrary 34 * @modules java.base/jdk.internal.misc 35 * java.management 36 */ 37 public class TestMetaspaceSizeFlags { 38 public static final long K = 1024L; 39 public static final long M = 1024L * K; 40 41 // HotSpot uses a number of different values to align memory size flags. 42 // This is currently the largest alignment (unless huge large pages are used). 43 public static final long MAX_ALIGNMENT = 32 * M; 44 45 public static void main(String [] args) throws Exception { 46 testMaxMetaspaceSizeEQMetaspaceSize(MAX_ALIGNMENT, MAX_ALIGNMENT); 47 // 8024650: MaxMetaspaceSize was adjusted instead of MetaspaceSize. 48 testMaxMetaspaceSizeLTMetaspaceSize(MAX_ALIGNMENT, MAX_ALIGNMENT * 2); 49 testMaxMetaspaceSizeGTMetaspaceSize(MAX_ALIGNMENT * 2, MAX_ALIGNMENT); 50 } 51 52 private static void testMaxMetaspaceSizeEQMetaspaceSize(long maxMetaspaceSize, long metaspaceSize) throws Exception { 53 MetaspaceFlags mf = runAndGetValue(maxMetaspaceSize, metaspaceSize); | 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import jdk.test.lib.Asserts; 25 import jdk.test.lib.process.ProcessTools; 26 import jdk.test.lib.process.OutputAnalyzer; 27 28 /* 29 * @test TestMetaspaceSizeFlags 30 * @key gc 31 * @bug 8024650 32 * @summary Test that metaspace size flags can be set correctly 33 * @library /test/lib 34 * @modules java.base/jdk.internal.misc 35 * java.management 36 */ 37 public class TestMetaspaceSizeFlags { 38 public static final long K = 1024L; 39 public static final long M = 1024L * K; 40 41 // HotSpot uses a number of different values to align memory size flags. 42 // This is currently the largest alignment (unless huge large pages are used). 43 public static final long MAX_ALIGNMENT = 32 * M; 44 45 public static void main(String [] args) throws Exception { 46 testMaxMetaspaceSizeEQMetaspaceSize(MAX_ALIGNMENT, MAX_ALIGNMENT); 47 // 8024650: MaxMetaspaceSize was adjusted instead of MetaspaceSize. 48 testMaxMetaspaceSizeLTMetaspaceSize(MAX_ALIGNMENT, MAX_ALIGNMENT * 2); 49 testMaxMetaspaceSizeGTMetaspaceSize(MAX_ALIGNMENT * 2, MAX_ALIGNMENT); 50 } 51 52 private static void testMaxMetaspaceSizeEQMetaspaceSize(long maxMetaspaceSize, long metaspaceSize) throws Exception { 53 MetaspaceFlags mf = runAndGetValue(maxMetaspaceSize, metaspaceSize); |