mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-20 23:36:18 +00:00
8029216: (jdeps) Provide a specific option to report JDK internal APIs
Reviewed-by: alanb
This commit is contained in:
parent
f179384b1c
commit
cd7a8e76a4
@ -180,6 +180,15 @@ class JdepsTask {
|
||||
task.options.depth = 0;
|
||||
}
|
||||
},
|
||||
new Option(false, "-jdkinternals") {
|
||||
void process(JdepsTask task, String opt, String arg) {
|
||||
task.options.findJDKInternals = true;
|
||||
task.options.verbose = Analyzer.Type.CLASS;
|
||||
if (task.options.includePattern == null) {
|
||||
task.options.includePattern = Pattern.compile(".*");
|
||||
}
|
||||
}
|
||||
},
|
||||
new Option(false, "-version") {
|
||||
void process(JdepsTask task, String opt, String arg) {
|
||||
task.options.version = true;
|
||||
@ -248,6 +257,11 @@ class JdepsTask {
|
||||
showHelp();
|
||||
return EXIT_CMDERR;
|
||||
}
|
||||
if (options.findJDKInternals &&
|
||||
(options.regex != null || options.packageNames.size() > 0 || options.showSummary)) {
|
||||
showHelp();
|
||||
return EXIT_CMDERR;
|
||||
}
|
||||
if (options.showSummary && options.verbose != Analyzer.Type.SUMMARY) {
|
||||
showHelp();
|
||||
return EXIT_CMDERR;
|
||||
@ -571,6 +585,7 @@ class JdepsTask {
|
||||
boolean wildcard;
|
||||
boolean apiOnly;
|
||||
boolean showLabel;
|
||||
boolean findJDKInternals;
|
||||
String dotOutputDir;
|
||||
String classpath = "";
|
||||
int depth = 1;
|
||||
@ -681,11 +696,22 @@ class JdepsTask {
|
||||
@Override
|
||||
public void visitDependence(String origin, Archive source,
|
||||
String target, Archive archive, Profile profile) {
|
||||
if (!origin.equals(pkg)) {
|
||||
pkg = origin;
|
||||
writer.format(" %s (%s)%n", origin, source.getFileName());
|
||||
if (options.findJDKInternals &&
|
||||
!(archive instanceof JDKArchive && profile == null)) {
|
||||
// filter dependences other than JDK internal APIs
|
||||
return;
|
||||
}
|
||||
if (options.verbose == Analyzer.Type.VERBOSE) {
|
||||
writer.format(" %-50s -> %-50s %s%n",
|
||||
origin, target, getProfileArchiveInfo(archive, profile));
|
||||
} else {
|
||||
if (!origin.equals(pkg)) {
|
||||
pkg = origin;
|
||||
writer.format(" %s (%s)%n", origin, source.getFileName());
|
||||
}
|
||||
writer.format(" -> %-50s %s%n",
|
||||
target, getProfileArchiveInfo(archive, profile));
|
||||
}
|
||||
writer.format(" -> %-50s %s%n", target, getProfileArchiveInfo(archive, profile));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -717,6 +743,11 @@ class JdepsTask {
|
||||
@Override
|
||||
public void visitDependence(String origin, Archive source,
|
||||
String target, Archive archive, Profile profile) {
|
||||
if (options.findJDKInternals &&
|
||||
!(archive instanceof JDKArchive && profile == null)) {
|
||||
// filter dependences other than JDK internal APIs
|
||||
return;
|
||||
}
|
||||
// if -P option is specified, package name -> profile will
|
||||
// be shown and filter out multiple same edges.
|
||||
String name = getProfileArchiveInfo(archive, profile);
|
||||
|
||||
@ -59,10 +59,19 @@ main.opt.apionly=\
|
||||
main.opt.dotoutput=\
|
||||
\ -dotoutput <dir> Destination directory for DOT file output
|
||||
|
||||
main.opt.jdkinternals=\
|
||||
\ -jdkinternals Finds class-level dependences on JDK internal APIs.\n\
|
||||
\ By default, it analyzes all classes on -classpath\n\
|
||||
\ and input files unless -include option is specified.\n\
|
||||
\ This option cannot be used with -p, -e and -s options.\n\
|
||||
\ WARNING: JDK internal APIs may not be accessible in\n\
|
||||
\ the next release.
|
||||
|
||||
main.opt.depth=\
|
||||
\ -depth=<depth> Specify the depth of the transitive\n\
|
||||
\ dependency analysis
|
||||
|
||||
|
||||
err.unknown.option=unknown option: {0}
|
||||
err.missing.arg=no value given for {0}
|
||||
err.internal.error=internal error: {0} {1} {2}
|
||||
|
||||
@ -23,8 +23,8 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8015912
|
||||
* @summary find API dependencies
|
||||
* @bug 8015912 8029216
|
||||
* @summary Test -apionly and -jdkinternals options
|
||||
* @build m.Bar m.Foo m.Gee b.B c.C c.I d.D e.E f.F g.G
|
||||
* @run main APIDeps
|
||||
*/
|
||||
@ -88,6 +88,19 @@ public class APIDeps {
|
||||
new String[] {"g.G", "sun.misc.Lock"},
|
||||
new String[] {testDirBasename, "JDK internal API"},
|
||||
new String[] {"-classpath", testDir.getPath(), "-verbose"});
|
||||
|
||||
// -jdkinternals
|
||||
test(new File(mDir, "Gee.class"),
|
||||
new String[] {"sun.misc.Lock"},
|
||||
new String[] {"JDK internal API"},
|
||||
new String[] {"-jdkinternals"});
|
||||
// -jdkinternals parses all classes on -classpath and the input arguments
|
||||
test(new File(mDir, "Gee.class"),
|
||||
new String[] {"sun.misc.Lock", "sun.misc.Unsafe"},
|
||||
new String[] {"JDK internal API"},
|
||||
new String[] {"-classpath", testDir.getPath(), "-jdkinternals"});
|
||||
|
||||
// parse only APIs
|
||||
// parse only APIs
|
||||
test(mDir,
|
||||
new String[] {"java.lang.Object", "java.lang.String",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user