diff -r 747e11afce7e -r 4925a7f447b0 langtools/src/jdk.dev/share/classes/com/sun/tools/jdeps/JdepsTask.java --- a/langtools/src/jdk.dev/share/classes/com/sun/tools/jdeps/JdepsTask.java Mon Feb 02 10:38:39 2015 +0100 +++ b/langtools/src/jdk.dev/share/classes/com/sun/tools/jdeps/JdepsTask.java Mon Feb 02 13:57:38 2015 +0100 @@ -611,6 +611,9 @@ deque.add(cn); } a.addClass(d.getOrigin(), d.getTarget()); + } else { + // ensure that the parsed class is added the archive + a.addClass(d.getOrigin()); } } for (String name : a.reader().skippedEntries()) { @@ -643,6 +646,7 @@ // if name is a fully-qualified class name specified // from command-line, this class might already be parsed doneClasses.add(classFileName); + for (Dependency d : finder.findDependencies(cf)) { if (depth == 0) { // ignore the dependency @@ -654,6 +658,9 @@ if (!doneClasses.contains(cn) && !deque.contains(cn)) { deque.add(cn); } + } else { + // ensure that the parsed class is added the archive + a.addClass(d.getOrigin()); } } } @@ -809,36 +816,53 @@ } } - private List getClassPathArchives(String paths) throws IOException { + /* + * Returns the list of Archive specified in cpaths and not included + * initialArchives + */ + private List getClassPathArchives(String cpaths) + throws IOException + { List result = new ArrayList<>(); - if (paths.isEmpty()) { + if (cpaths.isEmpty()) { return result; } - for (String p : paths.split(File.pathSeparator)) { + List paths = new ArrayList<>(); + for (String p : cpaths.split(File.pathSeparator)) { if (p.length() > 0) { - List files = new ArrayList<>(); // wildcard to parse all JAR files e.g. -classpath dir/* int i = p.lastIndexOf(".*"); if (i > 0) { Path dir = Paths.get(p.substring(0, i)); try (DirectoryStream stream = Files.newDirectoryStream(dir, "*.jar")) { for (Path entry : stream) { - files.add(entry); + paths.add(entry); } } } else { - files.add(Paths.get(p)); - } - for (Path f : files) { - if (Files.exists(f)) { - result.add(Archive.getInstance(f)); - } + paths.add(Paths.get(p)); } } } + for (Path path : paths) { + boolean found = initialArchives.stream() + .map(Archive::path) + .anyMatch(p -> isSameFile(path, p)); + if (!found && Files.exists(path)) { + result.add(Archive.getInstance(path)); + } + } return result; } + private boolean isSameFile(Path p1, Path p2) { + try { + return Files.isSameFile(p1, p2); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + class RawOutputFormatter implements Analyzer.Visitor { private final PrintWriter writer; private String pkg = "";