langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
changeset 22007 907f7054db16
parent 21503 45fc62482cae
child 22163 3651128c74eb
--- a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java	Tue Dec 03 23:10:23 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java	Wed Dec 04 15:39:36 2013 -0800
@@ -180,6 +180,15 @@
                 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 @@
                 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 @@
         boolean wildcard;
         boolean apiOnly;
         boolean showLabel;
+        boolean findJDKInternals;
         String dotOutputDir;
         String classpath = "";
         int depth = 1;
@@ -681,11 +696,22 @@
         @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;
             }
-            writer.format("      -> %-50s %s%n", target, getProfileArchiveInfo(archive, profile));
+            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));
+            }
         }
 
         @Override
@@ -717,6 +743,11 @@
         @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);