1 /* 2 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 25 /* 26 * @test SharedBaseAddress 27 * @summary Test variety of values for SharedBaseAddress, in AppCDS mode, 28 * making sure VM handles normal values as well as edge values 29 * w/o a crash. 30 * @requires vm.cds 31 * @library /test/lib 32 * @compile test-classes/Hello.java 33 * @run main/timeout=240 SharedBaseAddress 34 */ 35 36 import jdk.test.lib.process.OutputAnalyzer; 37 38 public class SharedBaseAddress { 39 40 // shared base address test table 41 private static final String[] testTable = { 42 "1g", "8g", "64g","512g", "4t", 43 "32t", "128t", "0", 44 "1", "64k", "64M", "320g", 45 "0x800001000" // Default base address + 1 page - probably valid but unaligned to metaspace alignment, see JDK 8247522 46 }; 47 48 public static void main(String[] args) throws Exception { 49 String appJar = JarBuilder.getOrCreateHelloJar(); 50 51 for (String testEntry : testTable) { 52 System.out.println("sharedBaseAddress = " + testEntry); 53 54 // Note: some platforms may restrict valid values for SharedBaseAddress; the VM should print 55 // a warning and use the default value instead. Similar, ASLR may prevent the given address 56 // from being used; this too should handled gracefully by using the default base address. 57 OutputAnalyzer dumpOutput = TestCommon.dump( 58 appJar, new String[] {"Hello"}, "-XX:SharedBaseAddress=" + testEntry); 59 TestCommon.checkDump(dumpOutput, "Loading classes to share"); 60 61 OutputAnalyzer execOutput = TestCommon.exec(appJar, "Hello"); 62 TestCommon.checkExec(execOutput, "Hello World"); 63 } 64 } 65 }