609 String cn = d.getTarget().getName(); |
609 String cn = d.getTarget().getName(); |
610 if (!doneClasses.contains(cn) && !deque.contains(cn)) { |
610 if (!doneClasses.contains(cn) && !deque.contains(cn)) { |
611 deque.add(cn); |
611 deque.add(cn); |
612 } |
612 } |
613 a.addClass(d.getOrigin(), d.getTarget()); |
613 a.addClass(d.getOrigin(), d.getTarget()); |
|
614 } else { |
|
615 // ensure that the parsed class is added the archive |
|
616 a.addClass(d.getOrigin()); |
614 } |
617 } |
615 } |
618 } |
616 for (String name : a.reader().skippedEntries()) { |
619 for (String name : a.reader().skippedEntries()) { |
617 warning("warn.skipped.entry", name, a.getPathName()); |
620 warning("warn.skipped.entry", name, a.getPathName()); |
618 } |
621 } |
641 } |
644 } |
642 if (!doneClasses.contains(classFileName)) { |
645 if (!doneClasses.contains(classFileName)) { |
643 // if name is a fully-qualified class name specified |
646 // if name is a fully-qualified class name specified |
644 // from command-line, this class might already be parsed |
647 // from command-line, this class might already be parsed |
645 doneClasses.add(classFileName); |
648 doneClasses.add(classFileName); |
|
649 |
646 for (Dependency d : finder.findDependencies(cf)) { |
650 for (Dependency d : finder.findDependencies(cf)) { |
647 if (depth == 0) { |
651 if (depth == 0) { |
648 // ignore the dependency |
652 // ignore the dependency |
649 a.addClass(d.getOrigin()); |
653 a.addClass(d.getOrigin()); |
650 break; |
654 break; |
807 throw new InternalError("Cannot find jdkinternals resource bundle"); |
814 throw new InternalError("Cannot find jdkinternals resource bundle"); |
808 } |
815 } |
809 } |
816 } |
810 } |
817 } |
811 |
818 |
812 private List<Archive> getClassPathArchives(String paths) throws IOException { |
819 /* |
|
820 * Returns the list of Archive specified in cpaths and not included |
|
821 * initialArchives |
|
822 */ |
|
823 private List<Archive> getClassPathArchives(String cpaths) |
|
824 throws IOException |
|
825 { |
813 List<Archive> result = new ArrayList<>(); |
826 List<Archive> result = new ArrayList<>(); |
814 if (paths.isEmpty()) { |
827 if (cpaths.isEmpty()) { |
815 return result; |
828 return result; |
816 } |
829 } |
817 for (String p : paths.split(File.pathSeparator)) { |
830 List<Path> paths = new ArrayList<>(); |
|
831 for (String p : cpaths.split(File.pathSeparator)) { |
818 if (p.length() > 0) { |
832 if (p.length() > 0) { |
819 List<Path> files = new ArrayList<>(); |
|
820 // wildcard to parse all JAR files e.g. -classpath dir/* |
833 // wildcard to parse all JAR files e.g. -classpath dir/* |
821 int i = p.lastIndexOf(".*"); |
834 int i = p.lastIndexOf(".*"); |
822 if (i > 0) { |
835 if (i > 0) { |
823 Path dir = Paths.get(p.substring(0, i)); |
836 Path dir = Paths.get(p.substring(0, i)); |
824 try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.jar")) { |
837 try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.jar")) { |
825 for (Path entry : stream) { |
838 for (Path entry : stream) { |
826 files.add(entry); |
839 paths.add(entry); |
827 } |
840 } |
828 } |
841 } |
829 } else { |
842 } else { |
830 files.add(Paths.get(p)); |
843 paths.add(Paths.get(p)); |
831 } |
844 } |
832 for (Path f : files) { |
845 } |
833 if (Files.exists(f)) { |
846 } |
834 result.add(Archive.getInstance(f)); |
847 for (Path path : paths) { |
835 } |
848 boolean found = initialArchives.stream() |
836 } |
849 .map(Archive::path) |
|
850 .anyMatch(p -> isSameFile(path, p)); |
|
851 if (!found && Files.exists(path)) { |
|
852 result.add(Archive.getInstance(path)); |
837 } |
853 } |
838 } |
854 } |
839 return result; |
855 return result; |
|
856 } |
|
857 |
|
858 private boolean isSameFile(Path p1, Path p2) { |
|
859 try { |
|
860 return Files.isSameFile(p1, p2); |
|
861 } catch (IOException e) { |
|
862 throw new UncheckedIOException(e); |
|
863 } |
840 } |
864 } |
841 |
865 |
842 class RawOutputFormatter implements Analyzer.Visitor { |
866 class RawOutputFormatter implements Analyzer.Visitor { |
843 private final PrintWriter writer; |
867 private final PrintWriter writer; |
844 private String pkg = ""; |
868 private String pkg = ""; |