8191942: Replace jdeps use of jdk.internal.util.jar.VersionedStream with new public API
authormchung
Wed, 29 Nov 2017 20:42:18 -0800
changeset 47989 f1ad41a05fb7
parent 47988 fb0b9913ff7e
child 47990 e712b777f28e
8191942: Replace jdeps use of jdk.internal.util.jar.VersionedStream with new public API Reviewed-by: alanb, erikj
make/autoconf/spec.gmk.in
make/gendata/Gendata-jdk.compiler.gmk
src/java.base/share/classes/java/util/jar/JavaUtilJarAccessImpl.java
src/java.base/share/classes/jdk/internal/misc/JavaUtilJarAccess.java
src/java.base/share/classes/module-info.java
src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java
src/jdk.jdeps/share/classes/com/sun/tools/jdeps/VersionHelper.java
--- a/make/autoconf/spec.gmk.in	Wed Nov 29 15:27:47 2017 -0800
+++ b/make/autoconf/spec.gmk.in	Wed Nov 29 20:42:18 2017 -0800
@@ -565,12 +565,10 @@
 BUILD_JAVA=@FIXPATH@ $(BUILD_JDK)/bin/java $(BUILD_JAVA_FLAGS)
 
 # Interim langtools and rmic modules and arguments
-INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.jdeps jdk.javadoc
+INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.javadoc
 INTERIM_LANGTOOLS_MODULES := $(addsuffix .interim, $(INTERIM_LANGTOOLS_BASE_MODULES))
 INTERIM_LANGTOOLS_ADD_EXPORTS := \
     --add-exports java.base/sun.reflect.annotation=jdk.compiler.interim \
-    --add-exports java.base/jdk.internal.util.jar=jdk.jdeps.interim \
-    --add-exports java.base/jdk.internal.misc=jdk.jdeps.interim \
     #
 INTERIM_LANGTOOLS_MODULES_COMMA := $(strip $(subst $(SPACE),$(COMMA),$(strip \
     $(INTERIM_LANGTOOLS_MODULES))))
--- a/make/gendata/Gendata-jdk.compiler.gmk	Wed Nov 29 15:27:47 2017 -0800
+++ b/make/gendata/Gendata-jdk.compiler.gmk	Wed Nov 29 20:42:18 2017 -0800
@@ -49,13 +49,13 @@
     --add-exports jdk.compiler.interim/com.sun.tools.javac.code=ALL-UNNAMED \
     --add-exports jdk.compiler.interim/com.sun.tools.javac.util=ALL-UNNAMED \
     --add-exports jdk.compiler.interim/com.sun.tools.javac.jvm=ALL-UNNAMED \
-    --add-exports jdk.jdeps.interim/com.sun.tools.classfile=ALL-UNNAMED \
     #
 
 $(eval $(call SetupJavaCompilation, COMPILE_CREATE_SYMBOLS, \
     SETUP := GENERATE_OLDBYTECODE, \
-    SRC := $(TOPDIR)/make/langtools/src/classes, \
-    INCLUDES := build/tools/symbolgenerator, \
+    SRC := $(TOPDIR)/make/langtools/src/classes \
+        $(TOPDIR)/src/jdk.jdeps/share/classes, \
+    INCLUDES := build/tools/symbolgenerator com/sun/tools/classfile, \
     BIN := $(BUILDTOOLS_OUTPUTDIR)/create_symbols, \
     ADD_JAVAC_FLAGS := $(INTERIM_LANGTOOLS_ARGS) \
         $(COMPILECREATESYMBOLS_ADD_EXPORTS), \
--- a/src/java.base/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Wed Nov 29 15:27:47 2017 -0800
+++ b/src/java.base/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Wed Nov 29 20:42:18 2017 -0800
@@ -60,8 +60,4 @@
     public List<Object> getManifestDigests(JarFile jar) {
         return jar.getManifestDigests();
     }
-
-    public String getRealName(JarFile jar, JarEntry entry) {
-        return jar.getRealName(entry);
-    }
 }
--- a/src/java.base/share/classes/jdk/internal/misc/JavaUtilJarAccess.java	Wed Nov 29 15:27:47 2017 -0800
+++ b/src/java.base/share/classes/jdk/internal/misc/JavaUtilJarAccess.java	Wed Nov 29 20:42:18 2017 -0800
@@ -41,5 +41,4 @@
     public Enumeration<JarEntry> entries2(JarFile jar);
     public void setEagerValidation(JarFile jar, boolean eager);
     public List<Object> getManifestDigests(JarFile jar);
-    public String getRealName(JarFile jar, JarEntry entry);
 }
--- a/src/java.base/share/classes/module-info.java	Wed Nov 29 15:27:47 2017 -0800
+++ b/src/java.base/share/classes/module-info.java	Wed Nov 29 20:42:18 2017 -0800
@@ -210,8 +210,7 @@
         jdk.internal.vm.ci,
         jdk.incubator.httpclient;
     exports jdk.internal.util.jar to
-        jdk.jartool,
-        jdk.jdeps;
+        jdk.jartool;
     exports sun.net to
         jdk.incubator.httpclient;
     exports sun.net.ext to
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Wed Nov 29 15:27:47 2017 -0800
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java	Wed Nov 29 20:42:18 2017 -0800
@@ -30,8 +30,6 @@
 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;
@@ -336,7 +334,7 @@
 
         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) {
@@ -383,24 +381,9 @@
         }
     }
 
-    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;
@@ -416,7 +399,7 @@
             if (jarfile == null) return;
 
             this.jf = jarfile;
-            this.entries = versionedEntries(jf);
+            this.entries = jarfile.versionedStream().iterator();
             this.nextEntry = nextEntry();
         }
 
@@ -450,8 +433,8 @@
         }
 
         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;
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/VersionHelper.java	Wed Nov 29 15:27:47 2017 -0800
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/VersionHelper.java	Wed Nov 29 20:42:18 2017 -0800
@@ -27,7 +27,6 @@
 
 import com.sun.tools.classfile.ClassFile;
 import com.sun.tools.classfile.ConstantPoolException;
-import jdk.internal.misc.SharedSecrets;
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -48,7 +47,7 @@
     public static void add(JarFile jarfile, JarEntry e, ClassFile cf)
             throws ConstantPoolException
     {
-        String realName = SharedSecrets.javaUtilJarAccess().getRealName(jarfile, e);
+        String realName = e.getRealName();
         if (realName.startsWith(META_INF_VERSIONS)) {
             int len = META_INF_VERSIONS.length();
             int n = realName.indexOf('/', len);