< prev index next >

src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java

Print this page
rev 53034 : 8215472: Cleanups in implementation classes of jdk.zipfs and tests


  31 import java.nio.file.NoSuchFileException;
  32 import java.nio.file.Path;
  33 import java.util.Arrays;
  34 import java.util.HashMap;
  35 import java.util.Map;
  36 import java.util.TreeMap;
  37 import java.util.function.Consumer;
  38 import java.util.function.Function;
  39 import java.util.jar.Attributes;
  40 import java.util.jar.Manifest;
  41 
  42 /**
  43  * Adds aliasing to ZipFileSystem to support multi-release jar files.  An alias map
  44  * is created by {@link JarFileSystem#createVersionedLinks(int)}.  The map is then
  45  * consulted when an entry is looked up in {@link JarFileSystem#getEntry(byte[])}
  46  * to determine if the entry has a corresponding versioned entry.  If so, the
  47  * versioned entry is returned.
  48  *
  49  * @author Steve Drach
  50  */
  51 
  52 class JarFileSystem extends ZipFileSystem {
  53     private Function<byte[],byte[]> lookup;
  54 
  55     @Override
  56     IndexNode getInode(byte[] path) {
  57         // check for an alias to a versioned entry
  58         byte[] versionedPath = lookup.apply(path);
  59         return versionedPath == null ? super.getInode(path) : super.getInode(versionedPath);
  60     }
  61 
  62     JarFileSystem(ZipFileSystemProvider provider, Path zfpath, Map<String,?> env)
  63             throws IOException {
  64         super(provider, zfpath, env);
  65         lookup = path -> path;  // lookup needs to be set before isMultiReleaseJar is called
  66                                 // because it eventually calls getEntry
  67         if (isMultiReleaseJar()) {
  68             int version;
  69             Object o = env.get("multi-release");
  70             if (o instanceof String) {
  71                 String s = (String)o;




  31 import java.nio.file.NoSuchFileException;
  32 import java.nio.file.Path;
  33 import java.util.Arrays;
  34 import java.util.HashMap;
  35 import java.util.Map;
  36 import java.util.TreeMap;
  37 import java.util.function.Consumer;
  38 import java.util.function.Function;
  39 import java.util.jar.Attributes;
  40 import java.util.jar.Manifest;
  41 
  42 /**
  43  * Adds aliasing to ZipFileSystem to support multi-release jar files.  An alias map
  44  * is created by {@link JarFileSystem#createVersionedLinks(int)}.  The map is then
  45  * consulted when an entry is looked up in {@link JarFileSystem#getEntry(byte[])}
  46  * to determine if the entry has a corresponding versioned entry.  If so, the
  47  * versioned entry is returned.
  48  *
  49  * @author Steve Drach
  50  */

  51 class JarFileSystem extends ZipFileSystem {
  52     private Function<byte[],byte[]> lookup;
  53 
  54     @Override
  55     IndexNode getInode(byte[] path) {
  56         // check for an alias to a versioned entry
  57         byte[] versionedPath = lookup.apply(path);
  58         return versionedPath == null ? super.getInode(path) : super.getInode(versionedPath);
  59     }
  60 
  61     JarFileSystem(ZipFileSystemProvider provider, Path zfpath, Map<String,?> env)
  62             throws IOException {
  63         super(provider, zfpath, env);
  64         lookup = path -> path;  // lookup needs to be set before isMultiReleaseJar is called
  65                                 // because it eventually calls getEntry
  66         if (isMultiReleaseJar()) {
  67             int version;
  68             Object o = env.get("multi-release");
  69             if (o instanceof String) {
  70                 String s = (String)o;


< prev index next >