|
1 /* |
|
2 * Copyright (c) 2017, 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 * @summary Shared classes can still be used when archived heap regions cannot be |
|
28 * mapped due to out of range, and -Xshare:on should not fail. Test on |
|
29 * linux 64-bit only since the HeapBaseMinAddress value is platform specific. |
|
30 * The value used in the test may cause different behavior on other platforms. |
|
31 * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) |
|
32 * @requires (os.family == "linux") & (os.arch == "amd64") & (sun.arch.data.model == "64") |
|
33 * @requires (vm.gc=="null") |
|
34 * @library /test/lib /test/hotspot/jtreg/runtime/appcds |
|
35 * @modules java.base/jdk.internal.misc |
|
36 * @modules java.management |
|
37 * jdk.jartool/sun.tools.jar |
|
38 * @compile ../test-classes/Hello.java |
|
39 * @run main RangeNotWithinHeap |
|
40 */ |
|
41 |
|
42 import jdk.test.lib.process.OutputAnalyzer; |
|
43 |
|
44 public class RangeNotWithinHeap { |
|
45 public static void main(String[] args) throws Exception { |
|
46 JarBuilder.getOrCreateHelloJar(); |
|
47 String appJar = TestCommon.getTestJar("hello.jar"); |
|
48 String appClasses[] = TestCommon.list("Hello"); |
|
49 |
|
50 OutputAnalyzer output = TestCommon.dump(appJar, appClasses, |
|
51 "-XX:HeapBaseMinAddress=0x600000000", "-Xmx6G", "-Xlog:gc+heap=trace"); |
|
52 TestCommon.checkDump(output, "oa0 space:"); |
|
53 |
|
54 // Force archive region out of runtime java heap |
|
55 output = TestCommon.exec(appJar, "Hello"); |
|
56 TestCommon.checkExec(output, "Hello World"); |
|
57 output = TestCommon.exec(appJar, |
|
58 "-XX:HeapBaseMinAddress=0x600000000", "-Xmx2G", "-Xlog:gc+heap=trace,cds", "Hello"); |
|
59 TestCommon.checkExec(output, "Hello World"); |
|
60 try { |
|
61 output.shouldContain( |
|
62 "UseSharedSpaces: Unable to allocate region, range is not within java heap."); |
|
63 } catch (Exception e) { |
|
64 // In rare case the heap data is not used. |
|
65 if (output.getOutput().contains("Cached heap data from the CDS archive is being ignored")) { |
|
66 return; |
|
67 } |
|
68 // Check for common shared class data mapping failures. |
|
69 TestCommon.checkCommonExecExceptions(output, e); |
|
70 } |
|
71 } |
|
72 } |