< prev index next >

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

Print this page

        

@@ -28,12 +28,10 @@
 import com.sun.tools.classfile.AccessFlags;
 import com.sun.tools.classfile.ClassFile;
 import com.sun.tools.classfile.ConstantPoolException;
 import com.sun.tools.classfile.Dependencies.ClassFileError;
 
-import jdk.internal.util.jar.VersionedStream;
-
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;

@@ -334,11 +332,11 @@
             return jf;
         }
 
         protected Set<String> scan() {
             try (JarFile jf = openJarFile(path.toFile(), version)) {
-                return VersionedStream.stream(jf).map(JarEntry::getName)
+                return jf.versionedStream().map(JarEntry::getName)
                          .filter(n -> n.endsWith(".class"))
                          .collect(Collectors.toSet());
             } catch (IOException e) {
                 throw new UncheckedIOException(e);
             }

@@ -381,28 +379,13 @@
             final Iterator<ClassFile> iter = new JarFileIterator(this, jarfile);
             return () -> iter;
         }
     }
 
-    Enumeration<JarEntry> versionedEntries(JarFile jf) {
-        Iterator<JarEntry> it = VersionedStream.stream(jf).iterator();
-        return new Enumeration<>() {
-            @Override
-            public boolean hasMoreElements() {
-                return it.hasNext();
-            }
-
-            @Override
-            public JarEntry nextElement() {
-                return it.next();
-            }
-        };
-    }
-
     class JarFileIterator implements Iterator<ClassFile> {
         protected final JarFileReader reader;
-        protected Enumeration<JarEntry> entries;
+        protected Iterator<JarEntry> entries;
         protected JarFile jf;
         protected JarEntry nextEntry;
         protected ClassFile cf;
         JarFileIterator(JarFileReader reader) {
             this(reader, null);

@@ -414,11 +397,11 @@
 
         void setJarFile(JarFile jarfile) {
             if (jarfile == null) return;
 
             this.jf = jarfile;
-            this.entries = versionedEntries(jf);
+            this.entries = jarfile.versionedStream().iterator();
             this.nextEntry = nextEntry();
         }
 
         public boolean hasNext() {
             if (nextEntry != null && cf != null) {

@@ -448,12 +431,12 @@
             nextEntry = nextEntry();
             return classFile;
         }
 
         protected JarEntry nextEntry() {
-            while (entries.hasMoreElements()) {
-                JarEntry e = entries.nextElement();
+            while (entries.hasNext()) {
+                JarEntry e = entries.next();
                 String name = e.getName();
                 if (name.endsWith(".class")) {
                     return e;
                 }
             }
< prev index next >