1 /* 2 * Copyright (c) 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 27 * @comment the test uses -XX:ArchiveRelocationMode=1 to force relocation. 28 * @requires vm.cds 29 * @summary Testing relocation of dynamic CDS archive (during both dump time and run time) 30 * @comment JDK-8231610 Relocate the CDS archive if it cannot be mapped to the requested address 31 * @bug 8231610 32 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes 33 * @build Hello 34 * @build sun.hotspot.WhiteBox 35 * @run driver ClassFileInstaller -jar hello.jar Hello 36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission 37 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicArchiveRelocationTest 38 */ 39 40 import jdk.test.lib.process.OutputAnalyzer; 41 import jtreg.SkippedException; 42 43 public class DynamicArchiveRelocationTest extends DynamicArchiveTestBase { 44 public static void main(String... args) throws Exception { 45 try { 46 testOuter(false); 47 testOuter(true); 48 } catch (SkippedException s) { 49 s.printStackTrace(); 50 throw new RuntimeException("Archive mapping should always succeed after JDK-8231610 (did the machine run out of memory?)"); 51 } 52 } 53 54 static void testOuter(boolean dump_base_reloc) throws Exception { 55 testInner(dump_base_reloc, true, false); 56 testInner(dump_base_reloc, false, true); | 1 /* 2 * Copyright (c) 2020, 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 27 * @comment the test uses -XX:ArchiveRelocationMode=1 to force relocation. 28 * @requires vm.cds 29 * @summary Testing relocation of dynamic CDS archive (during both dump time and run time) 30 * @comment JDK-8231610 Relocate the CDS archive if it cannot be mapped to the requested address 31 * @bug 8231610 32 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes 33 * @build Hello 34 * @build sun.hotspot.WhiteBox 35 * @run driver ClassFileInstaller -jar hello.jar Hello 36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox 37 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicArchiveRelocationTest 38 */ 39 40 import jdk.test.lib.process.OutputAnalyzer; 41 import jtreg.SkippedException; 42 43 public class DynamicArchiveRelocationTest extends DynamicArchiveTestBase { 44 public static void main(String... args) throws Exception { 45 try { 46 testOuter(false); 47 testOuter(true); 48 } catch (SkippedException s) { 49 s.printStackTrace(); 50 throw new RuntimeException("Archive mapping should always succeed after JDK-8231610 (did the machine run out of memory?)"); 51 } 52 } 53 54 static void testOuter(boolean dump_base_reloc) throws Exception { 55 testInner(dump_base_reloc, true, false); 56 testInner(dump_base_reloc, false, true); |