--- old/make/autoconf/spec.gmk.in 2017-11-27 17:23:34.000000000 -0800 +++ new/make/autoconf/spec.gmk.in 2017-11-27 17:23:33.000000000 -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)))) --- old/make/gendata/Gendata-jdk.compiler.gmk 2017-11-27 17:23:35.000000000 -0800 +++ new/make/gendata/Gendata-jdk.compiler.gmk 2017-11-27 17:23:35.000000000 -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), \ --- old/src/java.base/share/classes/java/util/jar/JavaUtilJarAccessImpl.java 2017-11-27 17:23:37.000000000 -0800 +++ new/src/java.base/share/classes/java/util/jar/JavaUtilJarAccessImpl.java 2017-11-27 17:23:36.000000000 -0800 @@ -60,8 +60,4 @@ public List getManifestDigests(JarFile jar) { return jar.getManifestDigests(); } - - public String getRealName(JarFile jar, JarEntry entry) { - return jar.getRealName(entry); - } } --- old/src/java.base/share/classes/jdk/internal/misc/JavaUtilJarAccess.java 2017-11-27 17:23:38.000000000 -0800 +++ new/src/java.base/share/classes/jdk/internal/misc/JavaUtilJarAccess.java 2017-11-27 17:23:38.000000000 -0800 @@ -41,5 +41,4 @@ public Enumeration entries2(JarFile jar); public void setEagerValidation(JarFile jar, boolean eager); public List getManifestDigests(JarFile jar); - public String getRealName(JarFile jar, JarEntry entry); } --- old/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java 2017-11-27 17:23:40.000000000 -0800 +++ new/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ClassFileReader.java 2017-11-27 17:23:40.000000000 -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 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 versionedEntries(JarFile jf) { - Iterator 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 { protected final JarFileReader reader; - protected Enumeration entries; + protected Iterator 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; --- old/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/VersionHelper.java 2017-11-27 17:23:41.000000000 -0800 +++ new/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/VersionHelper.java 2017-11-27 17:23:41.000000000 -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); --- old/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java 2017-11-27 17:23:43.000000000 -0800 +++ new/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java 2017-11-27 17:23:43.000000000 -0800 @@ -34,7 +34,6 @@ import java.util.stream.Stream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import jdk.internal.util.jar.VersionedStream; import jdk.tools.jlink.internal.Archive.Entry.EntryType; /** @@ -105,7 +104,7 @@ } catch (IOException ioe) { throw new UncheckedIOException(ioe); } - return VersionedStream.stream(jarFile) + return jarFile.versionedStream() .filter(je -> !je.isDirectory()) .map(this::toEntry); } --- old/src/java.base/share/classes/jdk/internal/util/jar/VersionedStream.java 2017-11-27 17:23:44.000000000 -0800 +++ /dev/null 2017-11-27 17:23:45.000000000 -0800 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.internal.util.jar; - -import java.util.Objects; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.stream.Stream; - -public class VersionedStream { - private static final String META_INF_VERSIONS = "META-INF/versions/"; - - /** - * Returns a stream of versioned entries, derived from the base names of - * all entries in a multi-release {@code JarFile} that are present either in - * the base directory or in any versioned directory with a version number - * less than or equal to the {@code Runtime.Version::major} that the - * {@code JarFile} was opened with. These versioned entries are aliases - * for the real entries -- i.e. the names are base names and the content - * may come from a versioned directory entry. If the {@code jarFile} is not - * a multi-release jar, a stream of all entries is returned. - * - * @param jf the input JarFile - * @return stream of entries - * @since 9 - */ - public static Stream stream(JarFile jf) { - if (jf.isMultiRelease()) { - int version = jf.getVersion().major(); - return jf.stream() - .map(je -> getBaseSuffix(je, version)) - .filter(Objects::nonNull) - .distinct() - .map(jf::getJarEntry); - } - return jf.stream(); - } - - private static String getBaseSuffix(JarEntry je, int version) { - String name = je.getName(); - if (name.startsWith(META_INF_VERSIONS)) { - int len = META_INF_VERSIONS.length(); - int index = name.indexOf('/', len); - if (index == -1 || index == (name.length() - 1)) { - // filter out META-INF/versions/* and META-INF/versions/*/ - return null; - } - try { - if (Integer.parseInt(name, len, index, 10) > version) { - // not an integer - return null; - } - } catch (NumberFormatException x) { - // silently remove malformed entries - return null; - } - // We know name looks like META-INF/versions/*/* - return name.substring(index + 1); - } - return name; - } -}