author | rehn |
Fri, 29 Nov 2019 12:09:25 +0100 | |
changeset 59325 | 3636bab5e81e |
parent 52650 | c16b6cc93272 |
permissions | -rw-r--r-- |
41164 | 1 |
/* |
48543
7067fe4e054e
8189102: All tools should support -?, -h and --help
goetz
parents:
47945
diff
changeset
|
2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
41164 | 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 |
* @test |
|
44182
ce2f0cbc81b9
8176333: jdeps error message should include a proper MR jar file name
mchung
parents:
41164
diff
changeset
|
26 |
* @bug 8153654 8176333 |
41164 | 27 |
* @summary Tests for jdeps tool with multi-release jar files |
28 |
* @modules jdk.jdeps/com.sun.tools.jdeps |
|
29 |
* @library mrjar mrjar/base mrjar/9 mrjar/10 mrjar/v9 mrjar/v10 |
|
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
30 |
* @build test.* p.* q.* foo/* Main |
41164 | 31 |
* @run testng MultiReleaseJar |
32 |
*/ |
|
33 |
||
34 |
import org.testng.Assert; |
|
35 |
import org.testng.annotations.AfterClass; |
|
36 |
import org.testng.annotations.BeforeClass; |
|
37 |
import org.testng.annotations.Test; |
|
38 |
||
45861
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
44182
diff
changeset
|
39 |
import java.io.File; |
41164 | 40 |
import java.io.InputStream; |
41 |
import java.nio.file.Path; |
|
42 |
import java.nio.file.Paths; |
|
45861
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
44182
diff
changeset
|
43 |
import java.util.stream.Stream; |
41164 | 44 |
|
45 |
public class MultiReleaseJar { |
|
46 |
Path mrjar; |
|
47 |
String testJdk; |
|
48 |
String fileSep; |
|
49 |
Path cmdPath; |
|
50 |
||
51 |
@BeforeClass |
|
52 |
public void initialize() throws Exception { |
|
45861
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
44182
diff
changeset
|
53 |
String testClassPath = System.getProperty("test.class.path", ""); |
a82ccda077c9
8183505: Update langtools tests to allow for unique test classes directory
jjg
parents:
44182
diff
changeset
|
54 |
mrjar = Stream.of(testClassPath.split(File.pathSeparator)) |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
55 |
.map(Paths::get) |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
56 |
.filter(e -> e.endsWith("mrjar")) |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
57 |
.findAny() |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
58 |
.orElseThrow(() -> new InternalError("mrjar not found")); |
41164 | 59 |
testJdk = System.getProperty("test.jdk"); |
60 |
fileSep = System.getProperty("file.separator"); |
|
61 |
cmdPath = Paths.get(testJdk, "bin"); |
|
62 |
||
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
63 |
// build Version.jar, Version_9.jar and main.jar |
41164 | 64 |
Result r = run("jar -cf Version.jar -C base test --release 9 -C 9 test --release 10 -C 10 test"); |
65 |
checkResult(r); |
|
66 |
||
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
67 |
r = run("jar -cf Version_9.jar -C base test --release 9 -C 9 test"); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
68 |
checkResult(r); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
69 |
|
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
70 |
r = run("jar -cf Main.jar Main.class"); |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
71 |
checkResult(r); |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
72 |
|
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
73 |
r = run("jar -cf Foo.jar -C base p"); |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
74 |
checkResult(r); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
75 |
|
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
76 |
Path foo = Paths.get(System.getProperty("test.classes")).resolve("modules").resolve("foo"); |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
77 |
r = run("jar -uf Foo.jar --release 9 -C " + foo.toString() + " module-info.class --release 10 -C v10 q"); |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
78 |
checkResult(r); |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
79 |
} |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
80 |
|
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
81 |
@Test |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
82 |
public void basic() throws Exception { |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
83 |
Result r = run("jdeps --multi-release 9 -v missing.jar"); |
41164 | 84 |
checkResult(r, false, "Warning: Path does not exist: missing.jar"); |
85 |
||
86 |
r = run("jdeps -v Version.jar"); |
|
44182
ce2f0cbc81b9
8176333: jdeps error message should include a proper MR jar file name
mchung
parents:
41164
diff
changeset
|
87 |
checkResult(r, false, "--multi-release option is not set"); |
41164 | 88 |
|
89 |
r = run("jdeps --multi-release base -v Version.jar"); |
|
90 |
checkResult(r, true, |
|
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
91 |
"Version.jar ->", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
92 |
"test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
93 |
"test.Version" |
41164 | 94 |
); |
95 |
||
96 |
r = run("jdeps --multi-release 9 -v Version.jar"); |
|
97 |
checkResult(r, true, |
|
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
98 |
"Version.jar ->", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
99 |
"9/test.NonPublic", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
100 |
"9/test.NonPublic", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
101 |
"9/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
102 |
"9/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
103 |
"9/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
104 |
"9/test.Version" |
41164 | 105 |
); |
106 |
||
107 |
r = run("jdeps --multi-release 10 -v Version.jar"); |
|
108 |
checkResult(r, true, |
|
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
109 |
"Version.jar ->", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
110 |
"10/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
111 |
"10/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
112 |
"10/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
113 |
"10/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
114 |
"9/test.NonPublic", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
115 |
"9/test.NonPublic" |
41164 | 116 |
); |
117 |
||
118 |
r = run("jdeps --multi-release 8 -v Version.jar"); |
|
119 |
checkResult(r, false, "Error: invalid argument for option: 8"); |
|
120 |
||
121 |
r = run("jdeps --multi-release 9.1 -v Version.jar"); |
|
122 |
checkResult(r, false, "Error: invalid argument for option: 9.1"); |
|
123 |
||
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
124 |
runJdeps("Main.class"); |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
125 |
runJdeps("Main.jar"); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
126 |
} |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
127 |
|
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
128 |
|
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
129 |
private void runJdeps(String path) throws Exception { |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
130 |
Result r = run("jdeps -v -R -cp Version.jar " + path); |
44182
ce2f0cbc81b9
8176333: jdeps error message should include a proper MR jar file name
mchung
parents:
41164
diff
changeset
|
131 |
checkResult(r, false, "--multi-release option is not set"); |
41164 | 132 |
|
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
133 |
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar -multi-release 9 " + path); |
41164 | 134 |
checkResult(r, false, |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
135 |
"Error: unknown option: -multi-release", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
136 |
"Usage: jdeps <options> <path", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
137 |
"use --help" |
41164 | 138 |
); |
139 |
||
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
140 |
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar --multi-release 9 " + path); |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
141 |
|
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
142 |
String name = path; |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
143 |
int index = path.lastIndexOf('/'); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
144 |
if (index >= 0) { |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
145 |
name = path.substring(index + 1, path.length()); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
146 |
} |
41164 | 147 |
checkResult(r, true, |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
148 |
name + " -> Version.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
149 |
name + " -> foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
150 |
name + " -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
151 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
152 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
153 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
154 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
155 |
"Version.jar -> java.base", |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
156 |
"9/test.NonPublic", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
157 |
"9/test.NonPublic", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
158 |
"9/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
159 |
"9/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
160 |
"9/test.Version", |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
161 |
"9/test.Version", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
162 |
"foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
163 |
"Foo.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
164 |
"requires mandated java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
165 |
"foo -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
166 |
"p.Foo" |
41164 | 167 |
); |
168 |
||
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
169 |
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar --multi-release 10 " + path); |
41164 | 170 |
checkResult(r, true, |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
171 |
name + " -> Version.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
172 |
name + " -> foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
173 |
name + " -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
174 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
175 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
176 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
177 |
"Main", |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
178 |
"Version.jar ->", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
179 |
"10/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
180 |
"10/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
181 |
"10/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
182 |
"10/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
183 |
"9/test.NonPublic", |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
184 |
"9/test.NonPublic", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
185 |
"foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
186 |
"Foo.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
187 |
"requires mandated java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
188 |
"foo -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
189 |
"p.Foo" |
41164 | 190 |
); |
191 |
||
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
192 |
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar --multi-release base " + path); |
41164 | 193 |
checkResult(r, true, |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
194 |
name + " -> Version.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
195 |
name + " -> foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
196 |
name + " -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
197 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
198 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
199 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
200 |
"Main", |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
201 |
"Version.jar ->", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
202 |
"test.Version", |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
203 |
"test.Version", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
204 |
"foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
205 |
"Foo.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
206 |
"requires mandated java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
207 |
"foo -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
208 |
"p.Foo" |
41164 | 209 |
); |
210 |
||
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
211 |
r = run("jdeps -v -R -cp Version.jar --module-path Foo.jar --multi-release 9.1 " + path); |
41164 | 212 |
checkResult(r, false, "Error: invalid argument for option: 9.1"); |
213 |
||
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
214 |
// Version_9.jar does not have any version 10 entry |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
215 |
r = run("jdeps -v -R -cp Version_9.jar --module-path Foo.jar --multi-release 10 " + path); |
41164 | 216 |
checkResult(r, true, |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
217 |
name + " -> Version_9.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
218 |
name + " -> foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
219 |
name + " -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
220 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
221 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
222 |
"Main", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
223 |
"Main", |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
224 |
"Version_9.jar ->", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
225 |
"9/test.NonPublic", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
226 |
"9/test.NonPublic", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
227 |
"9/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
228 |
"9/test.Version", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
229 |
"9/test.Version", |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
230 |
"9/test.Version", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
231 |
"foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
232 |
"Foo.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
233 |
"requires mandated java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
234 |
"foo -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
235 |
"p.Foo" |
41164 | 236 |
); |
237 |
} |
|
238 |
||
239 |
@Test |
|
240 |
public void ps_and_qs() throws Exception { |
|
241 |
// build the jar file |
|
242 |
Result r = run("jar -cf PQ.jar -C base p --release 9 -C v9 p -C v9 q --release 10 -C v10 q"); |
|
243 |
checkResult(r); |
|
244 |
||
245 |
r = run("jdeps -v -R -cp PQ.jar --multi-release base PQ.jar"); |
|
246 |
checkResult(r, true, |
|
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
247 |
"PQ.jar -> java.base", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
248 |
"p.Foo" |
41164 | 249 |
); |
250 |
||
251 |
r = run("jdeps -v -R -cp PQ.jar --multi-release 9 PQ.jar"); |
|
252 |
checkResult(r, true, |
|
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
253 |
"PQ.jar -> java.base", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
254 |
"9/p.Foo", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
255 |
"9/p.Foo", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
256 |
"9/q.Bar" |
41164 | 257 |
); |
258 |
||
259 |
||
260 |
r = run("jdeps -v -R -cp PQ.jar --multi-release 10 PQ.jar"); |
|
261 |
checkResult(r, true, |
|
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
262 |
"PQ.jar -> java.base", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
263 |
"10/q.Bar", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
264 |
"10/q.Bar", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
265 |
"10/q.Gee", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
266 |
"9/p.Foo", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
267 |
"9/p.Foo" |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
268 |
); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
269 |
} |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
270 |
|
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
271 |
@Test |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
272 |
public void modularJar() throws Exception { |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
273 |
Result r = run("jdeps -v --multi-release 10 --module-path Foo.jar -m foo"); |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
274 |
checkResult(r, true, |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
275 |
"foo", // module name |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
276 |
"Foo.jar", // the path to Foo.jar |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
277 |
"requires mandated java.base", // module dependences |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
278 |
"foo -> java.base", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
279 |
"10/q.Bar", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
280 |
"10/q.Bar", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
281 |
"10/q.Gee", |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
282 |
"p.Foo" |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
283 |
); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
284 |
|
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
285 |
r = run("jdeps --multi-release 9 -cp Version.jar --module-path Foo.jar Main.jar"); |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
286 |
checkResult(r, true, |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
287 |
"Main.jar -> Version.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
288 |
"Main.jar -> foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
289 |
"Main.jar -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
290 |
"-> java.lang", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
291 |
"-> p", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
292 |
"-> test" |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
293 |
); |
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
294 |
|
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
295 |
r = run("jdeps --multi-release 10 -cp Version.jar --module-path Foo.jar Main.jar"); |
51685
1f70116be2df
8210502: jdeps does not handle properly on analyzing a mixture of MR JARs and non-MR JARs
mchung
parents:
48543
diff
changeset
|
296 |
checkResult(r, true, |
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
297 |
"Main.jar -> Version.jar", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
298 |
"Main.jar -> foo", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
299 |
"Main.jar -> java.base", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
300 |
"-> java.lang", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
301 |
"-> p", |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
51685
diff
changeset
|
302 |
"-> test" |
41164 | 303 |
); |
304 |
} |
|
305 |
||
306 |
static class Result { |
|
307 |
final String cmd; |
|
308 |
final int rc; |
|
309 |
final String out; |
|
310 |
final String err; |
|
311 |
Result(String cmd, int rc, String out, String err) { |
|
312 |
this.cmd = cmd; |
|
313 |
this.rc = rc; |
|
314 |
this.out = out; |
|
315 |
this.err = err; |
|
316 |
} |
|
317 |
} |
|
318 |
||
319 |
Result run(String cmd) throws Exception { |
|
320 |
String[] cmds = cmd.split(" +"); |
|
321 |
cmds[0] = cmdPath.resolve(cmds[0]).toString(); |
|
322 |
ProcessBuilder pb = new ProcessBuilder(cmds); |
|
323 |
pb.directory(mrjar.toFile()); |
|
47945
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
324 |
Process p = null; |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
325 |
try { |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
326 |
p = pb.start(); |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
327 |
p.waitFor(); |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
328 |
|
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
329 |
String out; |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
330 |
try (InputStream is = p.getInputStream()) { |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
331 |
out = new String(is.readAllBytes()); |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
332 |
} |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
333 |
String err; |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
334 |
try (InputStream is = p.getErrorStream()) { |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
335 |
err = new String(is.readAllBytes()); |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
336 |
} |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
337 |
return new Result(cmd, p.exitValue(), out, err); |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
338 |
} catch (Throwable t) { |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
339 |
if (p != null) { |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
340 |
p.destroyForcibly().waitFor(); |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
341 |
} |
39afb6894e3a
8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException
mchung
parents:
47216
diff
changeset
|
342 |
throw t; |
41164 | 343 |
} |
344 |
} |
|
345 |
||
346 |
void checkResult(Result r) throws Exception { |
|
347 |
System.out.println(r.cmd); |
|
348 |
System.out.println(r.out); |
|
349 |
if (r.rc != 0) { |
|
350 |
System.out.println(r.err); |
|
351 |
throw new Exception("rc=" + r.rc); |
|
352 |
} |
|
353 |
System.out.println(); |
|
354 |
} |
|
355 |
||
356 |
void checkResult(Result r, boolean checkrc, String... lines) throws Exception { |
|
357 |
System.out.println(r.cmd); |
|
358 |
System.out.println(r.out); |
|
359 |
if (checkrc && r.rc != 0) { |
|
360 |
System.out.println(r.err); |
|
361 |
throw new Exception("rc=" + r.rc); |
|
362 |
} |
|
363 |
String[] out = r.out.split("\r?\n"); |
|
364 |
Assert.assertEquals(out.length, lines.length); |
|
365 |
int n = 0; |
|
366 |
for (String line : lines) { |
|
367 |
Assert.assertTrue(out[n++].contains(line), "\"" + line + "\""); |
|
368 |
} |
|
369 |
System.out.println(); |
|
370 |
} |
|
371 |
} |