src/share/classes/com/sun/tools/jdeps/ClassFileReader.java

Print this page

        

*** 43,63 **** */ public class ClassFileReader { /** * Returns a ClassFileReader instance of a given path. */ ! public static ClassFileReader newInstance(File path) throws IOException { ! if (!path.exists()) { ! throw new FileNotFoundException(path.getAbsolutePath()); } ! if (path.isDirectory()) { ! return new DirectoryReader(path.toPath()); ! } else if (path.getName().endsWith(".jar")) { ! return new JarFileReader(path.toPath()); } else { ! return new ClassFileReader(path.toPath()); } } /** * Returns a ClassFileReader instance of a given JarFile. --- 43,63 ---- */ public class ClassFileReader { /** * Returns a ClassFileReader instance of a given path. */ ! public static ClassFileReader newInstance(Path path) throws IOException { ! if (!Files.exists(path)) { ! throw new FileNotFoundException(path.toString()); } ! if (Files.isDirectory(path)) { ! return new DirectoryReader(path); ! } else if (path.getFileName().toString().endsWith(".jar")) { ! return new JarFileReader(path); } else { ! return new ClassFileReader(path); } } /** * Returns a ClassFileReader instance of a given JarFile.
*** 161,180 **** public ClassFile getClassFile(String name) throws IOException { if (name.indexOf('.') > 0) { int i = name.lastIndexOf('.'); String pathname = name.replace('.', File.separatorChar) + ".class"; Path p = path.resolve(pathname); ! if (!p.toFile().exists()) { p = path.resolve(pathname.substring(0, i) + "$" + pathname.substring(i+1, pathname.length())); } ! if (p.toFile().exists()) { return readClassFile(p); } } else { Path p = path.resolve(name + ".class"); ! if (p.toFile().exists()) { return readClassFile(p); } } return null; } --- 161,180 ---- public ClassFile getClassFile(String name) throws IOException { if (name.indexOf('.') > 0) { int i = name.lastIndexOf('.'); String pathname = name.replace('.', File.separatorChar) + ".class"; Path p = path.resolve(pathname); ! if (!Files.exists(p)) { p = path.resolve(pathname.substring(0, i) + "$" + pathname.substring(i+1, pathname.length())); } ! if (Files.exists(p)) { return readClassFile(p); } } else { Path p = path.resolve(name + ".class"); ! if (Files.exists(p)) { return readClassFile(p); } } return null; }
*** 191,201 **** private List<Path> walkTree(Path dir) throws IOException { final List<Path> files = new ArrayList<Path>(); Files.walkFileTree(dir, new SimpleFileVisitor<Path>() { public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { ! if (file.toFile().getName().endsWith(".class")) { files.add(file); } return FileVisitResult.CONTINUE; } }); --- 191,201 ---- private List<Path> walkTree(Path dir) throws IOException { final List<Path> files = new ArrayList<Path>(); Files.walkFileTree(dir, new SimpleFileVisitor<Path>() { public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { ! if (file.getFileName().toString().endsWith(".class")) { files.add(file); } return FileVisitResult.CONTINUE; } });