author | iklam |
Thu, 14 Nov 2019 14:54:39 -0800 | |
changeset 59098 | 124164752fe4 |
parent 59070 | 22ee476cc664 |
permissions | -rw-r--r-- |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
1 |
/* |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
4 |
* |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
8 |
* |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
13 |
* accompanied this code). |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
14 |
* |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
18 |
* |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
21 |
* questions. |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
22 |
* |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
23 |
*/ |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
24 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
25 |
/** |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
26 |
* @test |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
27 |
* @comment the test uses -XX:ArchiveRelocationMode=1 to force relocation. |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
28 |
* @requires vm.cds |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
29 |
* @summary Testing relocation of dynamic CDS archive (during both dump time and run time) |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
30 |
* @comment JDK-8231610 Relocate the CDS archive if it cannot be mapped to the requested address |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
31 |
* @bug 8231610 |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
32 |
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
33 |
* @build Hello |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
34 |
* @run driver ClassFileInstaller -jar hello.jar Hello |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
35 |
* @run driver DynamicArchiveRelocationTest |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
36 |
*/ |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
37 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
38 |
import jdk.test.lib.process.OutputAnalyzer; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
39 |
import jtreg.SkippedException; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
40 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
41 |
public class DynamicArchiveRelocationTest extends DynamicArchiveTestBase { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
42 |
public static void main(String... args) throws Exception { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
43 |
try { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
44 |
testOuter(false); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
45 |
testOuter(true); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
46 |
} catch (SkippedException s) { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
47 |
s.printStackTrace(); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
48 |
throw new RuntimeException("Archive mapping should always succeed after JDK-8231610 (did the machine run out of memory?)"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
49 |
} |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
50 |
} |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
51 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
52 |
static void testOuter(boolean dump_base_reloc) throws Exception { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
53 |
testInner(dump_base_reloc, true, false); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
54 |
testInner(dump_base_reloc, false, true); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
55 |
testInner(dump_base_reloc, true, true); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
56 |
} |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
57 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
58 |
static boolean dump_base_reloc, dump_top_reloc, run_reloc; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
59 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
60 |
// dump_base_reloc - force relocation of archive when dumping base archive |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
61 |
// dump_top_reloc - force relocation of archive when dumping top archive |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
62 |
// run_reloc - force relocation of archive when running |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
63 |
static void testInner(boolean dump_base_reloc, boolean dump_top_reloc, boolean run_reloc) throws Exception { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
64 |
DynamicArchiveRelocationTest.dump_base_reloc = dump_base_reloc; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
65 |
DynamicArchiveRelocationTest.dump_top_reloc = dump_top_reloc; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
66 |
DynamicArchiveRelocationTest.run_reloc = run_reloc; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
67 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
68 |
runTest(DynamicArchiveRelocationTest::doTest); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
69 |
} |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
70 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
71 |
static int caseCount = 0; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
72 |
static void doTest() throws Exception { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
73 |
caseCount += 1; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
74 |
System.out.println("============================================================"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
75 |
System.out.println("case = " + caseCount + ", base = " + dump_base_reloc |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
76 |
+ ", top = " + dump_top_reloc |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
77 |
+ ", run = " + run_reloc); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
78 |
System.out.println("============================================================"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
79 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
80 |
String appJar = ClassFileInstaller.getJarPath("hello.jar"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
81 |
String mainClass = "Hello"; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
82 |
String forceRelocation = "-XX:ArchiveRelocationMode=1"; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
83 |
String dumpBaseRelocArg = dump_base_reloc ? forceRelocation : "-showversion"; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
84 |
String dumpTopRelocArg = dump_top_reloc ? forceRelocation : "-showversion"; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
85 |
String runRelocArg = run_reloc ? forceRelocation : "-showversion"; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
86 |
String logArg = "-Xlog:cds=debug,cds+reloc=debug"; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
87 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
88 |
String baseArchiveName = getNewArchiveName("base"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
89 |
String topArchiveName = getNewArchiveName("top"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
90 |
|
59098
124164752fe4
8234196: [TESTBUG] DynamicArchiveRelocationTest.java missing "ArchiveRelocationMode == 1 ...."
iklam
parents:
59070
diff
changeset
|
91 |
String runtimeMsg1 = "runtime archive relocation start"; |
124164752fe4
8234196: [TESTBUG] DynamicArchiveRelocationTest.java missing "ArchiveRelocationMode == 1 ...."
iklam
parents:
59070
diff
changeset
|
92 |
String runtimeMsg2 = "runtime archive relocation done"; |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
93 |
String unlockArg = "-XX:+UnlockDiagnosticVMOptions"; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
94 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
95 |
// (1) Dump base archive (static) |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
96 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
97 |
OutputAnalyzer out = dumpBaseArchive(baseArchiveName, unlockArg, dumpBaseRelocArg, logArg); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
98 |
if (dump_base_reloc) { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
99 |
out.shouldContain("ArchiveRelocationMode == 1: always allocate class space at an alternative address"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
100 |
out.shouldContain("Relocating archive from"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
101 |
} |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
102 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
103 |
// (2) Dump top archive (dynamic) |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
104 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
105 |
dump2(baseArchiveName, topArchiveName, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
106 |
unlockArg, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
107 |
dumpTopRelocArg, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
108 |
logArg, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
109 |
"-cp", appJar, mainClass) |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
110 |
.assertNormalExit(output -> { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
111 |
if (dump_top_reloc) { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
112 |
output.shouldContain(runtimeMsg1); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
113 |
output.shouldContain(runtimeMsg2); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
114 |
} |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
115 |
}); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
116 |
|
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
117 |
run2(baseArchiveName, topArchiveName, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
118 |
unlockArg, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
119 |
runRelocArg, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
120 |
logArg, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
121 |
"-cp", appJar, mainClass) |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
122 |
.assertNormalExit(output -> { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
123 |
if (run_reloc) { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
124 |
output.shouldContain(runtimeMsg1); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
125 |
output.shouldContain(runtimeMsg2); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
126 |
} |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
127 |
}); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
128 |
} |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
diff
changeset
|
129 |
} |