author | serb |
Sat, 09 Jun 2018 13:33:35 -0700 | |
changeset 50647 | a98ff7c2103d |
parent 47216 | 71c04702a3d5 |
child 52650 | c16b6cc93272 |
permissions | -rw-r--r-- |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
1 |
/* |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
2 |
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
4 |
* |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
10 |
* |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
15 |
* accompanied this code). |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
16 |
* |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
20 |
* |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
23 |
* questions. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
24 |
*/ |
34752
9c262a013456
8145342: Some copyright notices are inconsistently and ill formatted
vasya
parents:
30846
diff
changeset
|
25 |
|
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
26 |
package com.sun.tools.jdeps; |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
27 |
|
39671
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
28 |
import com.sun.tools.classfile.Dependency.Location; |
38524 | 29 |
|
39671
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
30 |
import java.io.BufferedReader; |
38524 | 31 |
import java.io.IOException; |
39671
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
32 |
import java.io.InputStream; |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
33 |
import java.io.InputStreamReader; |
38524 | 34 |
import java.io.UncheckedIOException; |
36526 | 35 |
import java.util.Collections; |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
36 |
import java.util.Comparator; |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
37 |
import java.util.HashMap; |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
38 |
import java.util.HashSet; |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
39 |
import java.util.Map; |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
40 |
import java.util.Objects; |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
41 |
import java.util.Set; |
25692
39537fdca12c
8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents:
25442
diff
changeset
|
42 |
import java.util.stream.Collectors; |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
43 |
import java.util.stream.Stream; |
25692
39537fdca12c
8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents:
25442
diff
changeset
|
44 |
|
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
45 |
/** |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
46 |
* Dependency Analyzer. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
47 |
*/ |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
48 |
public class Analyzer { |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
49 |
/** |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
50 |
* Type of the dependency analysis. Appropriate level of data |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
51 |
* will be stored. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
52 |
*/ |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
53 |
public enum Type { |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
54 |
SUMMARY, |
38524 | 55 |
MODULE, // equivalent to summary in addition, print module descriptor |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
56 |
PACKAGE, |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
57 |
CLASS, |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
58 |
VERBOSE |
22163 | 59 |
} |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
60 |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
61 |
/** |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
62 |
* Filter to be applied when analyzing the dependencies from the given archives. |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
63 |
* Only the accepted dependencies are recorded. |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
64 |
*/ |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
65 |
interface Filter { |
38524 | 66 |
boolean accepts(Location origin, Archive originArchive, |
67 |
Location target, Archive targetArchive); |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
68 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
69 |
|
38524 | 70 |
protected final JdepsConfiguration configuration; |
25874 | 71 |
protected final Type type; |
72 |
protected final Filter filter; |
|
36526 | 73 |
protected final Map<Archive, Dependences> results = new HashMap<>(); |
74 |
protected final Map<Location, Archive> locationToArchive = new HashMap<>(); |
|
75 |
static final Archive NOT_FOUND |
|
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
76 |
= new Archive(JdepsTask.getMessage("artifact.not.found")); |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
77 |
|
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
78 |
/** |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
79 |
* Constructs an Analyzer instance. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
80 |
* |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
81 |
* @param type Type of the dependency analysis |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
82 |
* @param filter |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
83 |
*/ |
38524 | 84 |
Analyzer(JdepsConfiguration config, Type type, Filter filter) { |
85 |
this.configuration = config; |
|
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
86 |
this.type = type; |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
87 |
this.filter = filter; |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
88 |
} |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
89 |
|
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
90 |
/** |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
91 |
* Performs the dependency analysis on the given archives. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
92 |
*/ |
38524 | 93 |
boolean run(Iterable<? extends Archive> archives, |
94 |
Map<Location, Archive> locationMap) |
|
95 |
{ |
|
96 |
this.locationToArchive.putAll(locationMap); |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
97 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
98 |
// traverse and analyze all dependencies |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
99 |
for (Archive archive : archives) { |
36526 | 100 |
Dependences deps = new Dependences(archive, type); |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
101 |
archive.visitDependences(deps); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
102 |
results.put(archive, deps); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
103 |
} |
25874 | 104 |
return true; |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
105 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
106 |
|
38524 | 107 |
/** |
108 |
* Returns the analyzed archives |
|
109 |
*/ |
|
110 |
Set<Archive> archives() { |
|
111 |
return results.keySet(); |
|
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
112 |
} |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
113 |
|
38524 | 114 |
/** |
115 |
* Returns true if the given archive has dependences. |
|
116 |
*/ |
|
117 |
boolean hasDependences(Archive archive) { |
|
21046
ebf16a1a6328
8015912: jdeps support to output in dot file format
mchung
parents:
16550
diff
changeset
|
118 |
if (results.containsKey(archive)) { |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
119 |
return results.get(archive).dependencies().size() > 0; |
21046
ebf16a1a6328
8015912: jdeps support to output in dot file format
mchung
parents:
16550
diff
changeset
|
120 |
} |
ebf16a1a6328
8015912: jdeps support to output in dot file format
mchung
parents:
16550
diff
changeset
|
121 |
return false; |
ebf16a1a6328
8015912: jdeps support to output in dot file format
mchung
parents:
16550
diff
changeset
|
122 |
} |
ebf16a1a6328
8015912: jdeps support to output in dot file format
mchung
parents:
16550
diff
changeset
|
123 |
|
38524 | 124 |
/** |
125 |
* Returns the dependences, either class name or package name |
|
126 |
* as specified in the given verbose level, from the given source. |
|
127 |
*/ |
|
128 |
Set<String> dependences(Archive source) { |
|
36526 | 129 |
if (!results.containsKey(source)) { |
130 |
return Collections.emptySet(); |
|
131 |
} |
|
38524 | 132 |
|
133 |
return results.get(source).dependencies() |
|
134 |
.stream() |
|
135 |
.map(Dep::target) |
|
136 |
.collect(Collectors.toSet()); |
|
25692
39537fdca12c
8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents:
25442
diff
changeset
|
137 |
} |
39537fdca12c
8050804: (jdeps) Recommend supported API to replace use of JDK internal API
mchung
parents:
25442
diff
changeset
|
138 |
|
38524 | 139 |
/** |
140 |
* Returns the direct dependences of the given source |
|
141 |
*/ |
|
142 |
Stream<Archive> requires(Archive source) { |
|
36526 | 143 |
if (!results.containsKey(source)) { |
144 |
return Stream.empty(); |
|
145 |
} |
|
38524 | 146 |
return results.get(source).requires() |
147 |
.stream(); |
|
36526 | 148 |
} |
149 |
||
38524 | 150 |
interface Visitor { |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
151 |
/** |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
152 |
* Visits a recorded dependency from origin to target which can be |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
153 |
* a fully-qualified classname, a package name, a module or |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
154 |
* archive name depending on the Analyzer's type. |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
155 |
*/ |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
156 |
public void visitDependence(String origin, Archive originArchive, |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
157 |
String target, Archive targetArchive); |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
158 |
} |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
159 |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
160 |
/** |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
161 |
* Visit the dependencies of the given source. |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
162 |
* If the requested level is SUMMARY, it will visit the required archives list. |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
163 |
*/ |
38524 | 164 |
void visitDependences(Archive source, Visitor v, Type level) { |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
165 |
if (level == Type.SUMMARY) { |
36526 | 166 |
final Dependences result = results.get(source); |
30843
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
167 |
final Set<Archive> reqs = result.requires(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
168 |
Stream<Archive> stream = reqs.stream(); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
169 |
if (reqs.isEmpty()) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
170 |
if (hasDependences(source)) { |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
171 |
// If reqs.isEmpty() and we have dependences, then it means |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
172 |
// that the dependences are from 'source' onto itself. |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
173 |
stream = Stream.of(source); |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
174 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
175 |
} |
6e378856c5a2
8080608: Missing archive name from jdeps -v -e output if no dependency on other JAR
dfuchs
parents:
28706
diff
changeset
|
176 |
stream.sorted(Comparator.comparing(Archive::getName)) |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
177 |
.forEach(archive -> { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
178 |
Profile profile = result.getTargetProfile(archive); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
179 |
v.visitDependence(source.getName(), source, |
36526 | 180 |
profile != null ? profile.profileName() |
181 |
: archive.getName(), archive); |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
182 |
}); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
183 |
} else { |
36526 | 184 |
Dependences result = results.get(source); |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
185 |
if (level != type) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
186 |
// requesting different level of analysis |
36526 | 187 |
result = new Dependences(source, level); |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
188 |
source.visitDependences(result); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
189 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
190 |
result.dependencies().stream() |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
191 |
.sorted(Comparator.comparing(Dep::origin) |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
192 |
.thenComparing(Dep::target)) |
36526 | 193 |
.forEach(d -> v.visitDependence(d.origin(), d.originArchive(), |
194 |
d.target(), d.targetArchive())); |
|
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
195 |
} |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
196 |
} |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
197 |
|
38524 | 198 |
void visitDependences(Archive source, Visitor v) { |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
199 |
visitDependences(source, v, type); |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
200 |
} |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
201 |
|
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
202 |
/** |
36526 | 203 |
* Dependences contains the dependencies for an Archive that can have one or |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
204 |
* more classes. |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
205 |
*/ |
36526 | 206 |
class Dependences implements Archive.Visitor { |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
207 |
protected final Archive archive; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
208 |
protected final Set<Archive> requires; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
209 |
protected final Set<Dep> deps; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
210 |
protected final Type level; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
211 |
private Profile profile; |
36526 | 212 |
Dependences(Archive archive, Type level) { |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
213 |
this.archive = archive; |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
214 |
this.deps = new HashSet<>(); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
215 |
this.requires = new HashSet<>(); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
216 |
this.level = level; |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
217 |
} |
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
218 |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
219 |
Set<Dep> dependencies() { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
220 |
return deps; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
221 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
222 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
223 |
Set<Archive> requires() { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
224 |
return requires; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
225 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
226 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
227 |
Profile getTargetProfile(Archive target) { |
36526 | 228 |
if (target.getModule().isJDK()) { |
25874 | 229 |
return Profile.getProfile((Module) target); |
230 |
} else { |
|
231 |
return null; |
|
232 |
} |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
233 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
234 |
|
38524 | 235 |
/* |
236 |
* Returns the archive that contains the given location. |
|
237 |
*/ |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
238 |
Archive findArchive(Location t) { |
38524 | 239 |
// local in this archive |
36526 | 240 |
if (archive.getClasses().contains(t)) |
241 |
return archive; |
|
242 |
||
38524 | 243 |
Archive target; |
244 |
if (locationToArchive.containsKey(t)) { |
|
245 |
target = locationToArchive.get(t); |
|
246 |
} else { |
|
247 |
// special case JDK removed API |
|
248 |
target = configuration.findClass(t) |
|
249 |
.orElseGet(() -> REMOVED_JDK_INTERNALS.contains(t) |
|
250 |
? REMOVED_JDK_INTERNALS |
|
251 |
: NOT_FOUND); |
|
252 |
} |
|
253 |
return locationToArchive.computeIfAbsent(t, _k -> target); |
|
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
254 |
} |
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
255 |
|
38524 | 256 |
// return classname or package name depending on the level |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
257 |
private String getLocationName(Location o) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
258 |
if (level == Type.CLASS || level == Type.VERBOSE) { |
41164
69167c89e68f
8153654: Update jdeps to be multi-release jar aware
sdrach
parents:
39671
diff
changeset
|
259 |
return VersionHelper.get(o.getClassName()); |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
260 |
} else { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
261 |
String pkg = o.getPackageName(); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
262 |
return pkg.isEmpty() ? "<unnamed>" : pkg; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
263 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
264 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
265 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
266 |
@Override |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
267 |
public void visit(Location o, Location t) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
268 |
Archive targetArchive = findArchive(t); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
269 |
if (filter.accepts(o, archive, t, targetArchive)) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
270 |
addDep(o, t); |
28706
a724585645ce
8068937: jdeps shows "not found" if target class has no reference other than its own package
mchung
parents:
25874
diff
changeset
|
271 |
if (archive != targetArchive && !requires.contains(targetArchive)) { |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
272 |
requires.add(targetArchive); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
273 |
} |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
274 |
} |
36526 | 275 |
if (targetArchive.getModule().isNamed()) { |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
276 |
Profile p = Profile.getProfile(t.getPackageName()); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
277 |
if (profile == null || (p != null && p.compareTo(profile) > 0)) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
278 |
profile = p; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
279 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
280 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
281 |
} |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
282 |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
283 |
private Dep curDep; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
284 |
protected Dep addDep(Location o, Location t) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
285 |
String origin = getLocationName(o); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
286 |
String target = getLocationName(t); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
287 |
Archive targetArchive = findArchive(t); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
288 |
if (curDep != null && |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
289 |
curDep.origin().equals(origin) && |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
290 |
curDep.originArchive() == archive && |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
291 |
curDep.target().equals(target) && |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
292 |
curDep.targetArchive() == targetArchive) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
293 |
return curDep; |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
294 |
} |
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
295 |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
296 |
Dep e = new Dep(origin, archive, target, targetArchive); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
297 |
if (deps.contains(e)) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
298 |
for (Dep e1 : deps) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
299 |
if (e.equals(e1)) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
300 |
curDep = e1; |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
301 |
} |
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
302 |
} |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
303 |
} else { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
304 |
deps.add(e); |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
305 |
curDep = e; |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
306 |
} |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
307 |
return curDep; |
16550
f20e2521f3df
8005428: Update jdeps to read the same profile information as by javac
mchung
parents:
16290
diff
changeset
|
308 |
} |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
309 |
} |
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
310 |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
311 |
/* |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
312 |
* Class-level or package-level dependency |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
313 |
*/ |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
314 |
class Dep { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
315 |
final String origin; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
316 |
final Archive originArchive; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
317 |
final String target; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
318 |
final Archive targetArchive; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
319 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
320 |
Dep(String origin, Archive originArchive, String target, Archive targetArchive) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
321 |
this.origin = origin; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
322 |
this.originArchive = originArchive; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
323 |
this.target = target; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
324 |
this.targetArchive = targetArchive; |
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
325 |
} |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
326 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
327 |
String origin() { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
328 |
return origin; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
329 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
330 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
331 |
Archive originArchive() { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
332 |
return originArchive; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
333 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
334 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
335 |
String target() { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
336 |
return target; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
337 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
338 |
|
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
339 |
Archive targetArchive() { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
340 |
return targetArchive; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
341 |
} |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
342 |
|
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
343 |
@Override |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
344 |
@SuppressWarnings("unchecked") |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
345 |
public boolean equals(Object o) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
346 |
if (o instanceof Dep) { |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
347 |
Dep d = (Dep) o; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
348 |
return this.origin.equals(d.origin) && |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
349 |
this.originArchive == d.originArchive && |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
350 |
this.target.equals(d.target) && |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
351 |
this.targetArchive == d.targetArchive; |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
352 |
} |
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
353 |
return false; |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
354 |
} |
21503
45fc62482cae
8027481: jdeps to handle classes with the same package name and correct profile for javax.crypto.*
mchung
parents:
21046
diff
changeset
|
355 |
|
25442
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
356 |
@Override |
755ff386d1ac
8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API
mchung
parents:
22163
diff
changeset
|
357 |
public int hashCode() { |
36526 | 358 |
return Objects.hash(this.origin, |
359 |
this.originArchive, |
|
360 |
this.target, |
|
361 |
this.targetArchive); |
|
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
362 |
} |
25874 | 363 |
|
364 |
public String toString() { |
|
365 |
return String.format("%s (%s) -> %s (%s)%n", |
|
366 |
origin, originArchive.getName(), |
|
367 |
target, targetArchive.getName()); |
|
368 |
} |
|
369 |
} |
|
38524 | 370 |
|
39671
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
371 |
static final Jdk8Internals REMOVED_JDK_INTERNALS = new Jdk8Internals(); |
38524 | 372 |
|
39671
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
373 |
static class Jdk8Internals extends Module { |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
374 |
private final String JDK8_INTERNALS = "/com/sun/tools/jdeps/resources/jdk8_internals.txt"; |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
375 |
private final Set<String> jdk8Internals; |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
376 |
private Jdk8Internals() { |
38524 | 377 |
super("JDK removed internal API"); |
39671
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
378 |
try (InputStream in = JdepsTask.class.getResourceAsStream(JDK8_INTERNALS); |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
379 |
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
380 |
this.jdk8Internals = reader.lines() |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
381 |
.filter(ln -> !ln.startsWith("#")) |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
382 |
.collect(Collectors.toSet()); |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
383 |
} catch (IOException e) { |
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
384 |
throw new UncheckedIOException(e); |
38524 | 385 |
} |
386 |
} |
|
387 |
||
388 |
public boolean contains(Location location) { |
|
389 |
String cn = location.getClassName(); |
|
390 |
int i = cn.lastIndexOf('.'); |
|
391 |
String pn = i > 0 ? cn.substring(0, i) : ""; |
|
39671
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
392 |
|
5a4b6a035514
8160398: (jdeps) Replace a list of JDK 8 internal API for detecting if it's removed in JDK 9 or later
mchung
parents:
38532
diff
changeset
|
393 |
return jdk8Internals.contains(pn); |
38524 | 394 |
} |
395 |
||
396 |
@Override |
|
397 |
public String name() { |
|
398 |
return getName(); |
|
399 |
} |
|
400 |
||
401 |
@Override |
|
38532
24f77d64bb1f
8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
38524
diff
changeset
|
402 |
public boolean isJDK() { |
24f77d64bb1f
8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
38524
diff
changeset
|
403 |
return true; |
24f77d64bb1f
8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
38524
diff
changeset
|
404 |
} |
24f77d64bb1f
8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
38524
diff
changeset
|
405 |
|
24f77d64bb1f
8153042: jdeps should continue to report JDK internal APIs that are removed/renamed in JDK
mchung
parents:
38524
diff
changeset
|
406 |
@Override |
38524 | 407 |
public boolean isExported(String pn) { |
408 |
return false; |
|
409 |
} |
|
410 |
} |
|
16290
b0b4f52de7ea
8006225: tools/jdeps/Basic.java failes with AssertionError
mchung
parents:
diff
changeset
|
411 |
} |