1.1 --- a/src/share/classes/com/sun/tools/jdeps/Analyzer.java Thu Mar 14 08:30:16 2013 +0000 1.2 +++ b/src/share/classes/com/sun/tools/jdeps/Analyzer.java Thu Mar 14 10:33:31 2013 -0700 1.3 @@ -91,9 +91,11 @@ 1.4 result.requiredArchives.add(source); 1.5 } 1.6 // either a profile name or the archive name 1.7 - String tname = getProfile(target); 1.8 - if (tname.isEmpty()){ 1.9 - tname = source.toString(); 1.10 + String tname = result.getTargetProfile(target); 1.11 + if (tname.isEmpty()) { 1.12 + tname = PlatformClassPath.contains(source) 1.13 + ? "JDK internal API (" + source.getFileName() + ")" 1.14 + : source.toString(); 1.15 } 1.16 if (!result.targetNames.contains(tname)) { 1.17 result.targetNames.add(tname); 1.18 @@ -110,7 +112,7 @@ 1.19 * a fully-qualified classname, a package name, a profile or 1.20 * archive name depending on the Analyzer's type. 1.21 */ 1.22 - void visit(String origin, String target); 1.23 + void visit(String origin, String target, String profile); 1.24 /** 1.25 * Visits the source archive to its destination archive of 1.26 * a recorded dependency. 1.27 @@ -124,7 +126,7 @@ 1.28 v.visit(r.archive, a); 1.29 } 1.30 for (String name : r.targetNames) { 1.31 - v.visit(r.archive.getFileName(), name); 1.32 + v.visit(r.archive.getFileName(), name, name); 1.33 } 1.34 } 1.35 } 1.36 @@ -138,7 +140,7 @@ 1.37 for (String target : r.deps.get(origin)) { 1.38 // filter intra-dependency unless in verbose mode 1.39 if (type == Type.VERBOSE || getArchive(origin) != getArchive(target)) { 1.40 - v.visit(origin, target); 1.41 + v.visit(origin, target, r.getTargetProfile(target)); 1.42 } 1.43 } 1.44 } 1.45 @@ -149,21 +151,16 @@ 1.46 return map.containsKey(name) ? map.get(name) : NOT_FOUND; 1.47 } 1.48 1.49 - public String getArchiveName(String name) { 1.50 - return getArchive(name).getFileName(); 1.51 - } 1.52 - 1.53 - public String getProfile(String name) { 1.54 - String pn = type == Type.CLASS ? packageOf(name) : name; 1.55 - Archive source = map.get(name); 1.56 - if (source != null && PlatformClassPath.contains(source)) { 1.57 - String profile = PlatformClassPath.getProfileName(pn); 1.58 - if (profile.isEmpty()) { 1.59 - return "JDK internal API (" + source.getFileName() + ")"; 1.60 - } 1.61 - return profile; 1.62 - } 1.63 - return ""; 1.64 + /** 1.65 + * Returns the file name of the archive for non-JRE class or 1.66 + * internal JRE classes. It returns empty string for SE API. 1.67 + */ 1.68 + public String getArchiveName(String target, String profile) { 1.69 + Archive source = getArchive(target); 1.70 + String name = source.getFileName(); 1.71 + if (PlatformClassPath.contains(source)) 1.72 + return profile.isEmpty() ? "JDK internal API (" + name + ")" : ""; 1.73 + return name; 1.74 } 1.75 1.76 private abstract class ArchiveDeps implements Archive.Visitor { 1.77 @@ -200,6 +197,8 @@ 1.78 } 1.79 1.80 public abstract void visit(Location o, Location t); 1.81 + public abstract String getTargetProfile(String target); 1.82 + 1.83 } 1.84 1.85 private class ClassVisitor extends ArchiveDeps { 1.86 @@ -212,6 +211,10 @@ 1.87 public void visit(Location o, Location t) { 1.88 add(o.getClassName(), t.getClassName()); 1.89 } 1.90 + public String getTargetProfile(String target) { 1.91 + int i = target.lastIndexOf('.'); 1.92 + return (i > 0) ? Profiles.getProfileName(target.substring(0, i)) : ""; 1.93 + } 1.94 } 1.95 1.96 private class PackageVisitor extends ArchiveDeps { 1.97 @@ -221,19 +224,15 @@ 1.98 public void visit(Location o, Location t) { 1.99 add(packageOf(o), packageOf(t)); 1.100 } 1.101 - 1.102 public void visit(Location l) { 1.103 add(packageOf(l)); 1.104 } 1.105 - 1.106 private String packageOf(Location loc) { 1.107 String pkg = loc.getPackageName(); 1.108 return pkg.isEmpty() ? "<unnamed>" : pkg; 1.109 } 1.110 - } 1.111 - 1.112 - private static String packageOf(String cn) { 1.113 - int i = cn.lastIndexOf('.'); 1.114 - return (i > 0) ? cn.substring(0, i) : "<unnamed>"; 1.115 + public String getTargetProfile(String target) { 1.116 + return Profiles.getProfileName(target); 1.117 + } 1.118 } 1.119 }