langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java
changeset 16550 f20e2521f3df
parent 15030 2d8dec41f029
child 21046 ebf16a1a6328
equal deleted inserted replaced
16549:1bdeedb5446c 16550:f20e2521f3df
    57         } else {
    57         } else {
    58             return new ClassFileReader(path.toPath());
    58             return new ClassFileReader(path.toPath());
    59         }
    59         }
    60     }
    60     }
    61 
    61 
       
    62     /**
       
    63      * Returns a ClassFileReader instance of a given JarFile.
       
    64      */
       
    65     public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException {
       
    66         return new JarFileReader(path, jf);
       
    67     }
       
    68 
    62     protected final Path path;
    69     protected final Path path;
    63     protected final String baseFileName;
    70     protected final String baseFileName;
    64     private ClassFileReader(Path path) {
    71     private ClassFileReader(Path path) {
    65         this.path = path;
    72         this.path = path;
    66         this.baseFileName = path.getFileName() != null
    73         this.baseFileName = path.getFileName() != null
   226     }
   233     }
   227 
   234 
   228     private static class JarFileReader extends ClassFileReader {
   235     private static class JarFileReader extends ClassFileReader {
   229         final JarFile jarfile;
   236         final JarFile jarfile;
   230         JarFileReader(Path path) throws IOException {
   237         JarFileReader(Path path) throws IOException {
       
   238             this(path, new JarFile(path.toFile()));
       
   239         }
       
   240         JarFileReader(Path path, JarFile jf) throws IOException {
   231             super(path);
   241             super(path);
   232             this.jarfile = new JarFile(path.toFile());
   242             this.jarfile = jf;
   233         }
   243         }
   234 
   244 
   235         public ClassFile getClassFile(String name) throws IOException {
   245         public ClassFile getClassFile(String name) throws IOException {
   236             if (name.indexOf('.') > 0) {
   246             if (name.indexOf('.') > 0) {
   237                 int i = name.lastIndexOf('.');
   247                 int i = name.lastIndexOf('.');