author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57705 | 7cf02b2c1455 |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
54927 | 2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
48138 | 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 bootclasspath mismatch test. |
|
48469
7312ae4465d6
8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents:
48171
diff
changeset
|
28 |
* @requires vm.cds |
48138 | 29 |
* @library /test/lib |
57705
7cf02b2c1455
8229267: [TESTBUG] Remove unnecessary @modules dependencies in CDS tests
iklam
parents:
57567
diff
changeset
|
30 |
* @modules jdk.jartool/sun.tools.jar |
48138 | 31 |
* @compile test-classes/Hello.java |
51990
6003e034cdd8
8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents:
50199
diff
changeset
|
32 |
* @run driver BootClassPathMismatch |
48138 | 33 |
*/ |
34 |
||
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
35 |
import jdk.test.lib.Platform; |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
36 |
import jdk.test.lib.cds.CDSOptions; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
37 |
import jdk.test.lib.cds.CDSTestUtils; |
48138 | 38 |
import jdk.test.lib.process.OutputAnalyzer; |
39 |
import java.io.File; |
|
40 |
import java.nio.file.Files; |
|
41 |
import java.nio.file.FileAlreadyExistsException; |
|
42 |
import java.nio.file.StandardCopyOption; |
|
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
43 |
import java.nio.file.Path; |
48138 | 44 |
import java.nio.file.Paths; |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
45 |
import java.nio.file.attribute.FileTime; |
48138 | 46 |
|
47 |
||
48 |
public class BootClassPathMismatch { |
|
49 |
private static final String mismatchMessage = "shared class paths mismatch"; |
|
50 |
||
51 |
public static void main(String[] args) throws Exception { |
|
52 |
JarBuilder.getOrCreateHelloJar(); |
|
53 |
copyHelloToNewDir(); |
|
54 |
||
55 |
BootClassPathMismatch test = new BootClassPathMismatch(); |
|
56 |
test.testBootClassPathMismatch(); |
|
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
57 |
test.testBootClassPathMismatchWithAppClass(); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
58 |
test.testBootClassPathMismatchWithBadPath(); |
54927 | 59 |
if (!TestCommon.isDynamicArchive()) { |
60 |
// this test is not applicable to dynamic archive since |
|
61 |
// there is no class to be archived in the top archive |
|
62 |
test.testBootClassPathMatchWithAppend(); |
|
63 |
} |
|
48138 | 64 |
test.testBootClassPathMatch(); |
65 |
} |
|
66 |
||
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
67 |
/* Archive contains boot classes only, with Hello class on -Xbootclasspath/a path. |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
68 |
* |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
69 |
* Error should be detected if: |
48138 | 70 |
* dump time: -Xbootclasspath/a:${testdir}/hello.jar |
71 |
* run-time : -Xbootclasspath/a:${testdir}/newdir/hello.jar |
|
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
72 |
* |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
73 |
* or |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
74 |
* dump time: -Xbootclasspath/a:${testdir}/newdir/hello.jar |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
75 |
* run-time : -Xbootclasspath/a:${testdir}/hello.jar |
48138 | 76 |
*/ |
77 |
public void testBootClassPathMismatch() throws Exception { |
|
78 |
String appJar = JarBuilder.getOrCreateHelloJar(); |
|
79 |
String appClasses[] = {"Hello"}; |
|
80 |
String testDir = TestCommon.getTestDir("newdir"); |
|
81 |
String otherJar = testDir + File.separator + "hello.jar"; |
|
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
82 |
|
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
83 |
TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + appJar); |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
84 |
TestCommon.run( |
54927 | 85 |
"-Xlog:cds", |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
86 |
"-cp", appJar, "-Xbootclasspath/a:" + otherJar, "Hello") |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
87 |
.assertAbnormalExit(mismatchMessage); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
88 |
|
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
89 |
TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + otherJar); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
90 |
TestCommon.run( |
54927 | 91 |
"-Xlog:cds", |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
92 |
"-cp", appJar, "-Xbootclasspath/a:" + appJar, "Hello") |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
93 |
.assertAbnormalExit(mismatchMessage); |
48138 | 94 |
} |
95 |
||
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
96 |
/* Archive contains boot classes only. |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
97 |
* |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
98 |
* Error should be detected if: |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
99 |
* dump time: -Xbootclasspath/a:${testdir}/newdir/hello.jar |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
100 |
* run-time : -Xbootclasspath/a:${testdir}/newdir/hello.jar1 |
48171
7ad2d33a0f05
8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents:
48138
diff
changeset
|
101 |
*/ |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
102 |
public void testBootClassPathMismatchWithBadPath() throws Exception { |
48171
7ad2d33a0f05
8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents:
48138
diff
changeset
|
103 |
String appClasses[] = {"Hello"}; |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
104 |
String testDir = TestCommon.getTestDir("newdir"); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
105 |
String appJar = testDir + File.separator + "hello.jar"; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
106 |
String otherJar = testDir + File.separator + "hello.jar1"; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
107 |
|
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
108 |
TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + appJar); |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
109 |
TestCommon.run( |
54927 | 110 |
"-Xlog:cds", |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
111 |
"-cp", appJar, "-Xbootclasspath/a:" + otherJar, "Hello") |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
112 |
.assertAbnormalExit(mismatchMessage); |
48171
7ad2d33a0f05
8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents:
48138
diff
changeset
|
113 |
} |
7ad2d33a0f05
8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents:
48138
diff
changeset
|
114 |
|
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
115 |
/* Archive contains boot classes only, with Hello loaded from -Xbootclasspath/a at dump time. |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
116 |
* |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
117 |
* No error if: |
48138 | 118 |
* dump time: -Xbootclasspath/a:${testdir}/hello.jar |
119 |
* run-time : -Xbootclasspath/a:${testdir}/hello.jar |
|
120 |
*/ |
|
121 |
public void testBootClassPathMatch() throws Exception { |
|
122 |
String appJar = TestCommon.getTestJar("hello.jar"); |
|
123 |
String appClasses[] = {"Hello"}; |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
124 |
TestCommon.dump( |
48138 | 125 |
appJar, appClasses, "-Xbootclasspath/a:" + appJar); |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
126 |
TestCommon.run( |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
127 |
"-cp", appJar, "-verbose:class", |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
128 |
"-Xbootclasspath/a:" + appJar, "Hello") |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
129 |
.assertNormalExit("[class,load] Hello source: shared objects file"); |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
130 |
|
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
131 |
// test relative path to appJar |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
132 |
String newJar = TestCommon.composeRelPath(appJar); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
133 |
TestCommon.run( |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
134 |
"-cp", newJar, "-verbose:class", |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
135 |
"-Xbootclasspath/a:" + newJar, "Hello") |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
136 |
.assertNormalExit("[class,load] Hello source: shared objects file"); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
137 |
|
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
138 |
int idx = appJar.lastIndexOf(File.separator); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
139 |
String jarName = appJar.substring(idx + 1); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
140 |
String jarDir = appJar.substring(0, idx); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
141 |
// relative path starting with "." |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
142 |
TestCommon.runWithRelativePath( |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
143 |
jarDir, |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
144 |
"-Xshare:on", |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
145 |
"-XX:SharedArchiveFile=" + TestCommon.getCurrentArchiveName(), |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
146 |
"-cp", "." + File.separator + jarName, |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
147 |
"-Xbootclasspath/a:" + "." + File.separator + jarName, |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
148 |
"-Xlog:class+load=trace,class+path=info", |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
149 |
"Hello") |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
150 |
.assertNormalExit(output -> { |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
151 |
output.shouldContain("Hello source: shared objects file") |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
152 |
.shouldHaveExitValue(0); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
153 |
}); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
154 |
|
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
155 |
// relative path starting with ".." |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
156 |
idx = jarDir.lastIndexOf(File.separator); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
157 |
String jarSubDir = jarDir.substring(idx + 1); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
158 |
TestCommon.runWithRelativePath( |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
159 |
jarDir, |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
160 |
"-Xshare:on", |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
161 |
"-XX:SharedArchiveFile=" + TestCommon.getCurrentArchiveName(), |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
162 |
"-cp", ".." + File.separator + jarSubDir + File.separator + jarName, |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
163 |
"-Xbootclasspath/a:" + ".." + File.separator + jarSubDir + File.separator + jarName, |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
164 |
"-Xlog:class+load=trace,class+path=info", |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
165 |
"Hello") |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
166 |
.assertNormalExit(output -> { |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
167 |
output.shouldContain("Hello source: shared objects file") |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
168 |
.shouldHaveExitValue(0); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
169 |
}); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
170 |
|
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
171 |
// test sym link to appJar |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
172 |
if (!Platform.isWindows()) { |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
173 |
File linkedJar = TestCommon.createSymLink(appJar); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
174 |
TestCommon.run( |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
175 |
"-cp", linkedJar.getPath(), "-verbose:class", |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
176 |
"-Xbootclasspath/a:" + linkedJar.getPath(), "Hello") |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
177 |
.assertNormalExit("[class,load] Hello source: shared objects file"); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
178 |
} |
48138 | 179 |
} |
180 |
||
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
181 |
/* Archive contains boot classes only, runtime add -Xbootclasspath/a path. |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
182 |
* |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
183 |
* No error: |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
184 |
* dump time: No -Xbootclasspath/a |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
185 |
* run-time : -Xbootclasspath/a:${testdir}/hello.jar |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
186 |
*/ |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
187 |
public void testBootClassPathMatchWithAppend() throws Exception { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
188 |
CDSOptions opts = new CDSOptions().setUseVersion(false); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
189 |
OutputAnalyzer out = CDSTestUtils.createArchive(opts); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
190 |
CDSTestUtils.checkDump(out); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
191 |
|
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
192 |
String appJar = JarBuilder.getOrCreateHelloJar(); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
193 |
opts.addPrefix("-Xbootclasspath/a:" + appJar, "-showversion").addSuffix("Hello"); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
194 |
CDSTestUtils.runWithArchiveAndCheck(opts); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
195 |
} |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
196 |
|
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
197 |
/* Archive contains app classes, with Hello on -cp path at dump time. |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
198 |
* |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
199 |
* Error should be detected if: |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
200 |
* dump time: <no bootclasspath specified> |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
201 |
* run-time : -Xbootclasspath/a:${testdir}/hello.jar |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
202 |
*/ |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
203 |
public void testBootClassPathMismatchWithAppClass() throws Exception { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
204 |
String appJar = JarBuilder.getOrCreateHelloJar(); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
205 |
String appClasses[] = {"Hello"}; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
206 |
TestCommon.dump(appJar, appClasses); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
207 |
TestCommon.run( |
54927 | 208 |
"-Xlog:cds", |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
209 |
"-cp", appJar, "-Xbootclasspath/a:" + appJar, "Hello") |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
210 |
.assertAbnormalExit(mismatchMessage); |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
211 |
|
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
212 |
// test relative path to appJar |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
213 |
String newJar = TestCommon.composeRelPath(appJar); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
214 |
TestCommon.run( |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
215 |
"-cp", newJar, "-Xbootclasspath/a:" + newJar, "Hello") |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
216 |
.assertAbnormalExit(mismatchMessage); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
217 |
} |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
218 |
|
48138 | 219 |
private static void copyHelloToNewDir() throws Exception { |
220 |
String classDir = System.getProperty("test.classes"); |
|
221 |
String dstDir = classDir + File.separator + "newdir"; |
|
222 |
try { |
|
223 |
Files.createDirectory(Paths.get(dstDir)); |
|
224 |
} catch (FileAlreadyExistsException e) { } |
|
225 |
||
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
226 |
// copy as hello.jar |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
227 |
Path dstPath = Paths.get(dstDir, "hello.jar"); |
48138 | 228 |
Files.copy(Paths.get(classDir, "hello.jar"), |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
229 |
dstPath, |
48138 | 230 |
StandardCopyOption.REPLACE_EXISTING); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
231 |
|
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
232 |
File helloJar = dstPath.toFile(); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
233 |
long modTime = helloJar.lastModified(); |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
234 |
|
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
235 |
// copy as hello.jar1 |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
236 |
Path dstPath2 = Paths.get(dstDir, "hello.jar1"); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
237 |
Files.copy(Paths.get(classDir, "hello.jar"), |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
238 |
dstPath2, |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
48979
diff
changeset
|
239 |
StandardCopyOption.REPLACE_EXISTING); |
55524
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
240 |
|
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
241 |
// On Windows, we rely on the file size, creation time, and |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
242 |
// modification time in order to differentiate between 2 files. |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
243 |
// Setting a different modification time on hello.jar1 so that this test |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
244 |
// runs more reliably on Windows. |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
245 |
modTime += 10000; |
b279ae9843b8
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
54927
diff
changeset
|
246 |
Files.setAttribute(dstPath2, "lastModifiedTime", FileTime.fromMillis(modTime)); |
48138 | 247 |
} |
248 |
} |