author | alanb |
Thu, 17 Mar 2016 19:04:28 +0000 | |
changeset 36526 | 3b41f1c69604 |
parent 34752 | 9c262a013456 |
permissions | -rw-r--r-- |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
1 |
/* |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
4 |
* |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
8 |
* |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
13 |
* accompanied this code). |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
14 |
* |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
18 |
* |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
21 |
* questions. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
22 |
*/ |
34752
9c262a013456
8145342: Some copyright notices are inconsistently and ill formatted
vasya
parents:
30846
diff
changeset
|
23 |
|
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
24 |
import java.io.IOException; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
25 |
import java.io.OutputStream; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
26 |
import java.io.PrintWriter; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
27 |
import java.nio.file.Paths; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
28 |
import java.util.ArrayList; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
29 |
import java.util.Arrays; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
30 |
import java.util.HashMap; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
31 |
import java.util.HashSet; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
32 |
import java.util.LinkedHashSet; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
33 |
import java.util.List; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
34 |
import java.util.Locale; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
35 |
import java.util.Map; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
36 |
import java.util.Set; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
37 |
import java.util.function.Supplier; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
38 |
import java.util.stream.Collectors; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
39 |
import java.util.stream.Stream; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
40 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
41 |
/** |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
42 |
* @test |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
43 |
* @bug 8080608 |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
44 |
* @summary Test that jdeps verbose output has a summary line when dependencies |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
45 |
* are found within the same archive. For each testcase, compare the |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
46 |
* result obtained from jdeps with the expected result. |
30846 | 47 |
* @modules jdk.jdeps/com.sun.tools.jdeps |
36526 | 48 |
* java.base/sun.security.x509 |
49 |
* @build use.indirect.DontUseJdkInternal2 |
|
50 |
* @build use.indirect.UseJdkInternalIndirectly |
|
51 |
* @build use.indirect2.DontUseJdkInternal3 |
|
52 |
* @build use.indirect2.UseJdkInternalIndirectly2 |
|
53 |
* @build use.internal.DontUseJdkInternal |
|
54 |
* @build use.internal.UseClassWithJdkInternal |
|
55 |
* @build use.internal.UseJdkInternalClass |
|
56 |
* @build use.internal.UseJdkInternalClass2 |
|
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
57 |
* @run main JdepsDependencyClosure --test:0 |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
58 |
* @run main JdepsDependencyClosure --test:1 |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
59 |
* @run main JdepsDependencyClosure --test:2 |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
60 |
* @run main JdepsDependencyClosure --test:3 |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
61 |
*/ |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
62 |
public class JdepsDependencyClosure { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
63 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
64 |
static boolean VERBOSE = false; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
65 |
static boolean COMPARE_TEXT = true; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
66 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
67 |
static final String JDEPS_SUMMARY_TEXT_FORMAT = "%s -> %s%n"; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
68 |
static final String JDEPS_VERBOSE_TEXT_FORMAT = " %-50s -> %-50s %s%n"; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
69 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
70 |
/** |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
71 |
* Helper class used to store arguments to pass to |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
72 |
* {@code JdepsDependencyClosure.test} as well as expected |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
73 |
* results. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
74 |
*/ |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
75 |
static class TestCaseData { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
76 |
final Map<String, Set<String>> expectedDependencies; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
77 |
final String expectedText; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
78 |
final String[] args; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
79 |
final boolean closure; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
80 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
81 |
TestCaseData(Map<String, Set<String>> expectedDependencies, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
82 |
String expectedText, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
83 |
boolean closure, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
84 |
String[] args) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
85 |
this.expectedDependencies = expectedDependencies; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
86 |
this.expectedText = expectedText; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
87 |
this.closure = closure; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
88 |
this.args = args; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
89 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
90 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
91 |
public void test() { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
92 |
if (expectedDependencies != null) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
93 |
String format = closure |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
94 |
? "Running (closure): jdeps %s %s %s %s" |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
95 |
: "Running: jdeps %s %s %s %s"; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
96 |
System.out.println(String.format(format, (Object[])args)); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
97 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
98 |
JdepsDependencyClosure.test(args, expectedDependencies, expectedText, closure); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
99 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
100 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
101 |
/** |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
102 |
* Make a new test case data to invoke jdeps and test its output. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
103 |
* @param pattern The pattern that will passed through to jdeps -e |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
104 |
* This is expected to match only one class. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
105 |
* @param arcPath The archive to analyze. A jar or a class directory. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
106 |
* @param classes For each reported archive dependency couple, the |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
107 |
* expected list of classes in the source that will |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
108 |
* be reported as having a dependency on the class |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
109 |
* in the target that matches the given pattern. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
110 |
* @param dependencies For each archive dependency couple, a singleton list |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
111 |
* containing the name of the class in the target that |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
112 |
* matches the pattern. It is expected that the pattern |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
113 |
* will match only one class in the target. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
114 |
* If the pattern matches several classes the |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
115 |
* expected text may no longer match the jdeps output. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
116 |
* @param archives A list of archive dependency couple in the form |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
117 |
* {{sourceName1, sourcePath1, targetDescription1, targetPath1} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
118 |
* {sourceName2, sourcePath2, targetDescription2, targetPath2} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
119 |
* ... } |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
120 |
* For a JDK module - e.g. java.base, the targetDescription |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
121 |
* is usually something like "JDK internal API (java.base)" |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
122 |
* and the targetPath is usually the module name "java.base". |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
123 |
* @param closure Whether jdeps should be recursively invoked to build |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
124 |
* the closure. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
125 |
* @return An instance of TestCaseData containing all the information |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
126 |
* needed to perform the jdeps invokation and test its output. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
127 |
*/ |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
128 |
public static TestCaseData make(String pattern, String arcPath, String[][] classes, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
129 |
String[][] dependencies, String[][] archives, boolean closure) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
130 |
final String[] args = new String[] { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
131 |
"-e", pattern, "-v", arcPath |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
132 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
133 |
Map<String, Set<String>> expected = new HashMap<>(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
134 |
String expectedText = ""; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
135 |
for (int i=0; i<classes.length; i++) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
136 |
final int index = i; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
137 |
expectedText += Stream.of(classes[i]) |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
138 |
.map((cn) -> String.format(JDEPS_VERBOSE_TEXT_FORMAT, cn, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
139 |
dependencies[index][0], archives[index][2])) |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
140 |
.reduce(String.format(JDEPS_SUMMARY_TEXT_FORMAT, archives[i][0], |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
141 |
archives[index][3]), (s1,s2) -> s1.concat(s2)); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
142 |
for (String cn : classes[index]) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
143 |
expected.putIfAbsent(cn, new HashSet<>()); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
144 |
expected.get(cn).add(dependencies[index][0]); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
145 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
146 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
147 |
return new TestCaseData(expected, expectedText, closure, args); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
148 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
149 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
150 |
public static TestCaseData valueOf(String[] args) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
151 |
if (args.length == 1 && args[0].startsWith("--test:")) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
152 |
// invoked from jtreg. build test case data for selected test. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
153 |
int index = Integer.parseInt(args[0].substring("--test:".length())); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
154 |
if (index >= dataSuppliers.size()) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
155 |
throw new RuntimeException("No such test case: " + index |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
156 |
+ " - available testcases are [0.." |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
157 |
+ (dataSuppliers.size()-1) + "]"); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
158 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
159 |
return dataSuppliers.get(index).get(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
160 |
} else { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
161 |
// invoked in standalone. just take the given argument |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
162 |
// and perform no validation on the output (except that it |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
163 |
// must start with a summary line) |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
164 |
return new TestCaseData(null, null, true, args); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
165 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
166 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
167 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
168 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
169 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
170 |
static TestCaseData makeTestCaseOne() { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
171 |
final String arcPath = System.getProperty("test.classes", "build/classes"); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
172 |
final String arcName = Paths.get(arcPath).getFileName().toString(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
173 |
final String[][] classes = new String[][] { |
36526 | 174 |
{"use.indirect2.UseJdkInternalIndirectly2", "use.internal.UseClassWithJdkInternal"}, |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
175 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
176 |
final String[][] dependencies = new String[][] { |
36526 | 177 |
{"use.internal.UseJdkInternalClass"}, |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
178 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
179 |
final String[][] archives = new String[][] { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
180 |
{arcName, arcPath, arcName, arcPath}, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
181 |
}; |
36526 | 182 |
return TestCaseData.make("use.internal.UseJdkInternalClass", arcPath, classes, |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
183 |
dependencies, archives, false); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
184 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
185 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
186 |
static TestCaseData makeTestCaseTwo() { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
187 |
String arcPath = System.getProperty("test.classes", "build/classes"); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
188 |
String arcName = Paths.get(arcPath).getFileName().toString(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
189 |
String[][] classes = new String[][] { |
36526 | 190 |
{"use.internal.UseJdkInternalClass", "use.internal.UseJdkInternalClass2"} |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
191 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
192 |
String[][] dependencies = new String[][] { |
36526 | 193 |
{"sun.security.x509.X509CertInfo"} |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
194 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
195 |
String[][] archive = new String[][] { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
196 |
{arcName, arcPath, "JDK internal API (java.base)", "java.base"}, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
197 |
}; |
36526 | 198 |
return TestCaseData.make("sun.security.x509.X509CertInfo", arcPath, classes, |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
199 |
dependencies, archive, false); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
200 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
201 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
202 |
static TestCaseData makeTestCaseThree() { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
203 |
final String arcPath = System.getProperty("test.classes", "build/classes"); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
204 |
final String arcName = Paths.get(arcPath).getFileName().toString(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
205 |
final String[][] classes = new String[][] { |
36526 | 206 |
{"use.indirect2.UseJdkInternalIndirectly2", "use.internal.UseClassWithJdkInternal"}, |
207 |
{"use.indirect.UseJdkInternalIndirectly"} |
|
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
208 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
209 |
final String[][] dependencies = new String[][] { |
36526 | 210 |
{"use.internal.UseJdkInternalClass"}, |
211 |
{"use.internal.UseClassWithJdkInternal"} |
|
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
212 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
213 |
final String[][] archives = new String[][] { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
214 |
{arcName, arcPath, arcName, arcPath}, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
215 |
{arcName, arcPath, arcName, arcPath} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
216 |
}; |
36526 | 217 |
return TestCaseData.make("use.internal.UseJdkInternalClass", arcPath, classes, |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
218 |
dependencies, archives, true); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
219 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
220 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
221 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
222 |
static TestCaseData makeTestCaseFour() { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
223 |
final String arcPath = System.getProperty("test.classes", "build/classes"); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
224 |
final String arcName = Paths.get(arcPath).getFileName().toString(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
225 |
final String[][] classes = new String[][] { |
36526 | 226 |
{"use.internal.UseJdkInternalClass", "use.internal.UseJdkInternalClass2"}, |
227 |
{"use.indirect2.UseJdkInternalIndirectly2", "use.internal.UseClassWithJdkInternal"}, |
|
228 |
{"use.indirect.UseJdkInternalIndirectly"} |
|
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
229 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
230 |
final String[][] dependencies = new String[][] { |
36526 | 231 |
{"sun.security.x509.X509CertInfo"}, |
232 |
{"use.internal.UseJdkInternalClass"}, |
|
233 |
{"use.internal.UseClassWithJdkInternal"} |
|
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
234 |
}; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
235 |
final String[][] archives = new String[][] { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
236 |
{arcName, arcPath, "JDK internal API (java.base)", "java.base"}, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
237 |
{arcName, arcPath, arcName, arcPath}, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
238 |
{arcName, arcPath, arcName, arcPath} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
239 |
}; |
36526 | 240 |
return TestCaseData.make("sun.security.x509.X509CertInfo", arcPath, classes, dependencies, |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
241 |
archives, true); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
242 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
243 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
244 |
static final List<Supplier<TestCaseData>> dataSuppliers = Arrays.asList( |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
245 |
JdepsDependencyClosure::makeTestCaseOne, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
246 |
JdepsDependencyClosure::makeTestCaseTwo, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
247 |
JdepsDependencyClosure::makeTestCaseThree, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
248 |
JdepsDependencyClosure::makeTestCaseFour |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
249 |
); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
250 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
251 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
252 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
253 |
/** |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
254 |
* The OutputStreamParser is used to parse the format of jdeps. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
255 |
* It is thus dependent on that format. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
256 |
*/ |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
257 |
static class OutputStreamParser extends OutputStream { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
258 |
// OutputStreamParser will populate this map: |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
259 |
// |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
260 |
// For each archive, a list of class in where dependencies where |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
261 |
// found... |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
262 |
final Map<String, Set<String>> deps; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
263 |
final StringBuilder text = new StringBuilder(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
264 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
265 |
StringBuilder[] lines = { new StringBuilder(), new StringBuilder() }; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
266 |
int line = 0; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
267 |
int sepi = 0; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
268 |
char[] sep; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
269 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
270 |
public OutputStreamParser(Map<String, Set<String>> deps) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
271 |
this.deps = deps; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
272 |
this.sep = System.getProperty("line.separator").toCharArray(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
273 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
274 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
275 |
@Override |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
276 |
public void write(int b) throws IOException { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
277 |
lines[line].append((char)b); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
278 |
if (b == sep[sepi]) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
279 |
if (++sepi == sep.length) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
280 |
text.append(lines[line]); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
281 |
if (lines[0].toString().startsWith(" ")) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
282 |
throw new RuntimeException("Bad formatting: " |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
283 |
+ "summary line missing for\n"+lines[0]); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
284 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
285 |
// Usually the output looks like that: |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
286 |
// <archive-1> -> java.base |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
287 |
// <class-1> -> <dependency> <dependency description> |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
288 |
// <class-2> -> <dependency> <dependency description> |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
289 |
// ... |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
290 |
// <archive-2> -> java.base |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
291 |
// <class-3> -> <dependency> <dependency description> |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
292 |
// <class-4> -> <dependency> <dependency description> |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
293 |
// ... |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
294 |
// |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
295 |
// We want to keep the <archive> line in lines[0] |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
296 |
// and have the ith <class-i> line in lines[1] |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
297 |
if (line == 1) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
298 |
// we have either a <class> line or an <archive> line. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
299 |
String line1 = lines[0].toString(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
300 |
String line2 = lines[1].toString(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
301 |
if (line2.startsWith(" ")) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
302 |
// we have a class line, record it. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
303 |
parse(line1, line2); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
304 |
// prepare for next <class> line. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
305 |
lines[1] = new StringBuilder(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
306 |
} else { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
307 |
// We have an archive line: We are switching to the next archive. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
308 |
// put the new <archive> line in lines[0], and prepare |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
309 |
// for reading the next <class> line |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
310 |
lines[0] = lines[1]; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
311 |
lines[1] = new StringBuilder(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
312 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
313 |
} else { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
314 |
// we just read the first <archive> line. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
315 |
// prepare to read <class> lines. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
316 |
line = 1; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
317 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
318 |
sepi = 0; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
319 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
320 |
} else { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
321 |
sepi = 0; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
322 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
323 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
324 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
325 |
// Takes a couple of lines, where line1 is an <archive> line and |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
326 |
// line 2 is a <class> line. Parses the line to extract the archive |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
327 |
// name and dependent class name, and record them in the map... |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
328 |
void parse(String line1, String line2) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
329 |
String archive = line1.substring(0, line1.indexOf(" -> ")); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
330 |
int l2ArrowIndex = line2.indexOf(" -> "); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
331 |
String className = line2.substring(2, l2ArrowIndex).replace(" ", ""); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
332 |
String depdescr = line2.substring(l2ArrowIndex + 4); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
333 |
String depclass = depdescr.substring(0, depdescr.indexOf(" ")); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
334 |
deps.computeIfAbsent(archive, (k) -> new HashSet<>()); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
335 |
deps.get(archive).add(className); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
336 |
if (VERBOSE) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
337 |
System.out.println(archive+": "+className+" depends on "+depclass); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
338 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
339 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
340 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
341 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
342 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
343 |
/** |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
344 |
* The main method. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
345 |
* |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
346 |
* Can be run in two modes: |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
347 |
* <ul> |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
348 |
* <li>From jtreg: expects 1 argument in the form {@code --test:<test-nb>}</li> |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
349 |
* <li>From command line: expected syntax is {@code -e <pattern> -v jar [jars..]}</li> |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
350 |
* </ul> |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
351 |
* <p>When called from the command line this method will call jdeps recursively |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
352 |
* to build a closure of the dependencies on {@code <pattern>} and print a summary. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
353 |
* <p>When called from jtreg - it will call jdeps either once only or |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
354 |
* recursively depending on the pattern. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
355 |
* @param args either {@code --test:<test-nb>} or {@code -e <pattern> -v jar [jars..]}. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
356 |
*/ |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
357 |
public static void main(String[] args) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
358 |
runWithLocale(Locale.ENGLISH, TestCaseData.valueOf(args)::test); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
359 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
360 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
361 |
private static void runWithLocale(Locale loc, Runnable run) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
362 |
final Locale defaultLocale = Locale.getDefault(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
363 |
Locale.setDefault(loc); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
364 |
try { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
365 |
run.run(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
366 |
} finally { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
367 |
Locale.setDefault(defaultLocale); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
368 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
369 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
370 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
371 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
372 |
public static void test(String[] args, Map<String, Set<String>> expected, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
373 |
String expectedText, boolean closure) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
374 |
try { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
375 |
doTest(args, expected, expectedText, closure); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
376 |
} catch (Throwable t) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
377 |
try { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
378 |
printDiagnostic(args, expectedText, t, closure); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
379 |
} catch(Throwable tt) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
380 |
throw t; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
381 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
382 |
throw t; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
383 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
384 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
385 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
386 |
static class TextFormatException extends RuntimeException { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
387 |
final String expected; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
388 |
final String actual; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
389 |
TextFormatException(String message, String expected, String actual) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
390 |
super(message); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
391 |
this.expected = expected; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
392 |
this.actual = actual; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
393 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
394 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
395 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
396 |
public static void printDiagnostic(String[] args, String expectedText, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
397 |
Throwable t, boolean closure) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
398 |
if (expectedText != null || t instanceof TextFormatException) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
399 |
System.err.println("===== TEST FAILED ======="); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
400 |
System.err.println("command: " + Stream.of(args) |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
401 |
.reduce("jdeps", (s1,s2) -> s1.concat(" ").concat(s2))); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
402 |
System.err.println("===== Expected Output ======="); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
403 |
System.err.append(expectedText); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
404 |
System.err.println("===== Command Output ======="); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
405 |
if (t instanceof TextFormatException) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
406 |
System.err.print(((TextFormatException)t).actual); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
407 |
} else { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
408 |
com.sun.tools.jdeps.Main.run(args, new PrintWriter(System.err)); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
409 |
if (closure) System.err.println("... (closure not available) ..."); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
410 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
411 |
System.err.println("============================="); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
412 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
413 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
414 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
415 |
public static void doTest(String[] args, Map<String, Set<String>> expected, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
416 |
String expectedText, boolean closure) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
417 |
if (args.length < 3 || !"-e".equals(args[0]) || !"-v".equals(args[2])) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
418 |
System.err.println("Syntax: -e <classname> -v [list of jars or directories]"); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
419 |
return; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
420 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
421 |
Map<String, Map<String, Set<String>>> alldeps = new HashMap<>(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
422 |
String depName = args[1]; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
423 |
List<String> search = new ArrayList<>(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
424 |
search.add(depName); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
425 |
Set<String> searched = new LinkedHashSet<>(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
426 |
StringBuilder text = new StringBuilder(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
427 |
while(!search.isEmpty()) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
428 |
args[1] = search.remove(0); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
429 |
if (VERBOSE) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
430 |
System.out.println("Looking for " + args[1]); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
431 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
432 |
searched.add(args[1]); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
433 |
Map<String, Set<String>> deps = |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
434 |
alldeps.computeIfAbsent(args[1], (k) -> new HashMap<>()); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
435 |
OutputStreamParser parser = new OutputStreamParser(deps); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
436 |
PrintWriter writer = new PrintWriter(parser); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
437 |
com.sun.tools.jdeps.Main.run(args, writer); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
438 |
if (VERBOSE) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
439 |
System.out.println("Found: " + deps.values().stream() |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
440 |
.flatMap(s -> s.stream()).collect(Collectors.toSet())); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
441 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
442 |
if (expectedText != null) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
443 |
text.append(parser.text.toString()); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
444 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
445 |
search.addAll(deps.values().stream() |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
446 |
.flatMap(s -> s.stream()) |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
447 |
.filter(k -> !searched.contains(k)) |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
448 |
.collect(Collectors.toSet())); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
449 |
if (!closure) break; |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
450 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
451 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
452 |
// Print summary... |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
453 |
final Set<String> classes = alldeps.values().stream() |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
454 |
.flatMap((m) -> m.values().stream()) |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
455 |
.flatMap(s -> s.stream()).collect(Collectors.toSet()); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
456 |
Map<String, Set<String>> result = new HashMap<>(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
457 |
for (String c : classes) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
458 |
Set<String> archives = new HashSet<>(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
459 |
Set<String> dependencies = new HashSet<>(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
460 |
for (String d : alldeps.keySet()) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
461 |
Map<String, Set<String>> m = alldeps.get(d); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
462 |
for (String a : m.keySet()) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
463 |
Set<String> s = m.get(a); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
464 |
if (s.contains(c)) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
465 |
archives.add(a); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
466 |
dependencies.add(d); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
467 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
468 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
469 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
470 |
result.put(c, dependencies); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
471 |
System.out.println(c + " " + archives + " depends on " + dependencies); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
472 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
473 |
|
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
474 |
// If we're in jtreg, then check result (expectedText != null) |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
475 |
if (expectedText != null && COMPARE_TEXT) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
476 |
//text.append(String.format("%n")); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
477 |
if (text.toString().equals(expectedText)) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
478 |
System.out.println("SUCCESS - got expected text"); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
479 |
} else { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
480 |
throw new TextFormatException("jdeps output is not as expected", |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
481 |
expectedText, text.toString()); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
482 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
483 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
484 |
if (expected != null) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
485 |
if (expected.equals(result)) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
486 |
System.out.println("SUCCESS - found expected dependencies"); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
487 |
} else if (expectedText == null) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
488 |
throw new RuntimeException("Bad dependencies: Expected " + expected |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
489 |
+ " but found " + result); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
490 |
} else { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
491 |
throw new TextFormatException("Bad dependencies: Expected " |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
492 |
+ expected |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
493 |
+ " but found " + result, |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
494 |
expectedText, text.toString()); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
495 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
496 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
497 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
diff
changeset
|
498 |
} |