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-- |
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:
diff
changeset
|
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:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
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:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
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:
diff
changeset
|
4 |
* |
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:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
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:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
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:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
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:
diff
changeset
|
8 |
* |
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:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
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:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
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:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
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:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
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:
diff
changeset
|
13 |
* accompanied this code). |
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:
diff
changeset
|
14 |
* |
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:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
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:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
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:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
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:
diff
changeset
|
18 |
* |
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:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
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:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
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:
diff
changeset
|
21 |
* questions. |
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:
diff
changeset
|
22 |
* |
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:
diff
changeset
|
23 |
*/ |
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:
diff
changeset
|
24 |
|
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:
diff
changeset
|
25 |
/* |
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:
diff
changeset
|
26 |
* @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:
diff
changeset
|
27 |
* @summary Test relative paths specified in the -cp. |
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:
diff
changeset
|
28 |
* @requires vm.cds |
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:
diff
changeset
|
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 |
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:
diff
changeset
|
31 |
* @compile test-classes/Hello.java |
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:
diff
changeset
|
32 |
* @compile test-classes/HelloMore.java |
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:
diff
changeset
|
33 |
* @run driver RelativePath |
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:
diff
changeset
|
34 |
*/ |
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:
diff
changeset
|
35 |
|
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:
diff
changeset
|
36 |
import java.io.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:
diff
changeset
|
37 |
import java.nio.file.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:
diff
changeset
|
38 |
import java.nio.file.Path; |
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:
diff
changeset
|
39 |
import java.nio.file.Paths; |
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:
diff
changeset
|
40 |
import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; |
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:
diff
changeset
|
41 |
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; |
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:
diff
changeset
|
42 |
import java.util.Arrays; |
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:
diff
changeset
|
43 |
import jdk.test.lib.Platform; |
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:
diff
changeset
|
44 |
|
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:
diff
changeset
|
45 |
public class RelativePath { |
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:
diff
changeset
|
46 |
|
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:
diff
changeset
|
47 |
private static final Path USER_DIR = Paths.get(System.getProperty("user.dir")); |
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:
diff
changeset
|
48 |
|
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:
diff
changeset
|
49 |
public static void main(String[] args) throws Exception { |
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:
diff
changeset
|
50 |
String appJar = JarBuilder.getOrCreateHelloJar(); |
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:
diff
changeset
|
51 |
String appJar2 = JarBuilder.build("AppendClasspath_HelloMore", "HelloMore"); |
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:
diff
changeset
|
52 |
|
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:
diff
changeset
|
53 |
// dump an archive with only the jar name in the -cp |
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:
diff
changeset
|
54 |
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:
diff
changeset
|
55 |
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:
diff
changeset
|
56 |
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:
diff
changeset
|
57 |
TestCommon.testDump(jarDir, jarName, TestCommon.list("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:
diff
changeset
|
58 |
|
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:
diff
changeset
|
59 |
// copy the jar file to another dir. Specify the jar file without |
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:
diff
changeset
|
60 |
// a directory path. |
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:
diff
changeset
|
61 |
Path srcPath = Paths.get(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:
diff
changeset
|
62 |
Path destDir = Files.createTempDirectory(USER_DIR, "deploy"); |
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:
diff
changeset
|
63 |
Path destPath = destDir.resolve(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:
diff
changeset
|
64 |
Files.copy(srcPath, destPath, REPLACE_EXISTING, COPY_ATTRIBUTES); |
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:
diff
changeset
|
65 |
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:
diff
changeset
|
66 |
destDir.toString(), |
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:
diff
changeset
|
67 |
"-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:
diff
changeset
|
68 |
"-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:
diff
changeset
|
69 |
"-cp", jarName + File.pathSeparator + appJar2, |
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:
diff
changeset
|
70 |
"-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:
diff
changeset
|
71 |
"HelloMore") |
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:
diff
changeset
|
72 |
.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:
diff
changeset
|
73 |
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:
diff
changeset
|
74 |
.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:
diff
changeset
|
75 |
}); |
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:
diff
changeset
|
76 |
|
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:
diff
changeset
|
77 |
// Long path 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:
diff
changeset
|
78 |
// Create a long directory path and copy the appJar there. |
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:
diff
changeset
|
79 |
final int MAX_PATH = 260; |
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:
diff
changeset
|
80 |
destDir = Paths.get(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:
diff
changeset
|
81 |
int subDirLen = MAX_PATH - jarDir.length() - 3; |
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:
diff
changeset
|
82 |
if (subDirLen > 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:
diff
changeset
|
83 |
char[] chars = new char[subDirLen]; |
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:
diff
changeset
|
84 |
Arrays.fill(chars, 'x'); |
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:
diff
changeset
|
85 |
String subPath = new String(chars); |
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:
diff
changeset
|
86 |
destDir = Paths.get(jarDir, subPath); |
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:
diff
changeset
|
87 |
} |
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:
diff
changeset
|
88 |
File longDir = destDir.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:
diff
changeset
|
89 |
longDir.mkdir(); |
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:
diff
changeset
|
90 |
String destJar = longDir.getPath() + 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:
diff
changeset
|
91 |
Files.copy(Paths.get(appJar), Paths.get(destJar), REPLACE_EXISTING); |
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:
diff
changeset
|
92 |
// Create an archive with the appJar in the long directory path. |
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:
diff
changeset
|
93 |
TestCommon.testDump(destJar, TestCommon.list("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:
diff
changeset
|
94 |
|
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:
diff
changeset
|
95 |
// Run with -cp containing the appJar and another jar appended. |
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:
diff
changeset
|
96 |
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:
diff
changeset
|
97 |
"-cp", destJar + File.pathSeparator + appJar2, |
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:
diff
changeset
|
98 |
"-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:
diff
changeset
|
99 |
"HelloMore") |
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:
diff
changeset
|
100 |
.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:
diff
changeset
|
101 |
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:
diff
changeset
|
102 |
.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:
diff
changeset
|
103 |
}); |
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:
diff
changeset
|
104 |
|
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:
diff
changeset
|
105 |
// Dump an archive with a specified JAR file in -classpath |
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:
diff
changeset
|
106 |
TestCommon.testDump(appJar, TestCommon.list("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:
diff
changeset
|
107 |
|
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:
diff
changeset
|
108 |
// compose a relative path to the hello.jar |
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:
diff
changeset
|
109 |
String newHello = 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:
diff
changeset
|
110 |
|
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:
diff
changeset
|
111 |
// create a sym link to the original hello.jar |
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:
diff
changeset
|
112 |
File linkedHello = null; |
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:
diff
changeset
|
113 |
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:
diff
changeset
|
114 |
linkedHello = 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:
diff
changeset
|
115 |
} |
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:
diff
changeset
|
116 |
|
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:
diff
changeset
|
117 |
// PASS:1) same appJar but referred to via a relative path |
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:
diff
changeset
|
118 |
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:
diff
changeset
|
119 |
"-cp", newHello + File.pathSeparator + appJar2, |
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:
diff
changeset
|
120 |
"-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:
diff
changeset
|
121 |
"HelloMore") |
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:
diff
changeset
|
122 |
.assertNormalExit(); |
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:
diff
changeset
|
123 |
|
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:
diff
changeset
|
124 |
// PASS:2) 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:
diff
changeset
|
125 |
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:
diff
changeset
|
126 |
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:
diff
changeset
|
127 |
"-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:
diff
changeset
|
128 |
"-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:
diff
changeset
|
129 |
"-cp", "." + File.separator + jarName + File.pathSeparator + appJar2, |
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:
diff
changeset
|
130 |
"-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:
diff
changeset
|
131 |
"HelloMore") |
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:
diff
changeset
|
132 |
.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:
diff
changeset
|
133 |
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:
diff
changeset
|
134 |
.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:
diff
changeset
|
135 |
}); |
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:
diff
changeset
|
136 |
|
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:
diff
changeset
|
137 |
// PASS:3) 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:
diff
changeset
|
138 |
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:
diff
changeset
|
139 |
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:
diff
changeset
|
140 |
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:
diff
changeset
|
141 |
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:
diff
changeset
|
142 |
"-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:
diff
changeset
|
143 |
"-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:
diff
changeset
|
144 |
"-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:
diff
changeset
|
145 |
+ File.pathSeparator + appJar2, |
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:
diff
changeset
|
146 |
"-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:
diff
changeset
|
147 |
"HelloMore") |
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:
diff
changeset
|
148 |
.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:
diff
changeset
|
149 |
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:
diff
changeset
|
150 |
.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:
diff
changeset
|
151 |
}); |
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:
diff
changeset
|
152 |
|
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:
diff
changeset
|
153 |
// PASS:4) a jar linked to the original hello.jar |
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:
diff
changeset
|
154 |
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:
diff
changeset
|
155 |
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:
diff
changeset
|
156 |
"-cp", linkedHello.getPath() + File.pathSeparator + appJar2, |
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:
diff
changeset
|
157 |
"HelloMore") |
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:
diff
changeset
|
158 |
.assertNormalExit(); |
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:
diff
changeset
|
159 |
} |
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:
diff
changeset
|
160 |
|
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:
diff
changeset
|
161 |
final String errorMessage1 = "Unable to use shared archive"; |
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:
diff
changeset
|
162 |
final String errorMessage2 = "shared class paths mismatch"; |
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:
diff
changeset
|
163 |
// FAIL: 1) runtime with classpath different from the one used in dump time |
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:
diff
changeset
|
164 |
// (runtime has an extra jar file prepended to the class path) |
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:
diff
changeset
|
165 |
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:
diff
changeset
|
166 |
"-cp", appJar2 + File.pathSeparator + newHello, |
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:
diff
changeset
|
167 |
"HelloMore") |
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:
diff
changeset
|
168 |
.assertAbnormalExit(errorMessage1, errorMessage2); |
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:
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:
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:
diff
changeset
|
171 |
} |