8191942: Replace jdeps use of jdk.internal.util.jar.VersionedStream with new public API

Reviewed-by: alanb, erikj
This commit is contained in:
Mandy Chung 2017-11-29 20:42:18 -08:00
parent 581c28572a
commit 44e4089789
7 changed files with 11 additions and 37 deletions

View File

@ -565,12 +565,10 @@ BUILD_JAVA_FLAGS := @BOOTCYCLE_JVM_ARGS_BIG@
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))))

View File

@ -49,13 +49,13 @@ COMPILECREATESYMBOLS_ADD_EXPORTS := \
--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), \

View File

@ -60,8 +60,4 @@ class JavaUtilJarAccessImpl implements JavaUtilJarAccess {
public List<Object> getManifestDigests(JarFile jar) {
return jar.getManifestDigests();
}
public String getRealName(JarFile jar, JarEntry entry) {
return jar.getRealName(entry);
}
}

View File

@ -41,5 +41,4 @@ public interface JavaUtilJarAccess {
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);
}

View File

@ -210,8 +210,7 @@ module java.base {
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

View File

@ -30,8 +30,6 @@ 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;
@ -336,7 +334,7 @@ public class ClassFileReader implements Closeable {
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 @@ public class ClassFileReader implements Closeable {
}
}
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 @@ public class ClassFileReader implements Closeable {
if (jarfile == null) return;
this.jf = jarfile;
this.entries = versionedEntries(jf);
this.entries = jarfile.versionedStream().iterator();
this.nextEntry = nextEntry();
}
@ -450,8 +433,8 @@ public class ClassFileReader implements Closeable {
}
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;

View File

@ -27,7 +27,6 @@ package com.sun.tools.jdeps;
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 class VersionHelper {
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);