src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystemProvider.java
changeset 59216 47c879f478d2
parent 58467 72ef2c0faf47
equal deleted inserted replaced
59215:fcd74557a9cc 59216:47c879f478d2
    50 
    50 
    51 /**
    51 /**
    52  * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
    52  * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
    53  */
    53  */
    54 public class ZipFileSystemProvider extends FileSystemProvider {
    54 public class ZipFileSystemProvider extends FileSystemProvider {
    55 
       
    56     // Property used to specify the entry version to use for a multi-release JAR
       
    57     static final String PROPERTY_RELEASE_VERSION = "releaseVersion";
       
    58     // Original property used to specify the entry version to use for a
       
    59     // multi-release JAR which is kept for backwards compatibility.
       
    60     static final String PROPERTY_MULTI_RELEASE = "multi-release";
       
    61     private final Map<Path, ZipFileSystem> filesystems = new HashMap<>();
    55     private final Map<Path, ZipFileSystem> filesystems = new HashMap<>();
    62 
    56 
    63     public ZipFileSystemProvider() {}
    57     public ZipFileSystemProvider() {}
    64 
    58 
    65     @Override
    59     @Override
   125         ensureFile(path);
   119         ensureFile(path);
   126         return getZipFileSystem(path, env);
   120         return getZipFileSystem(path, env);
   127     }
   121     }
   128 
   122 
   129     private ZipFileSystem getZipFileSystem(Path path, Map<String, ?> env) throws IOException {
   123     private ZipFileSystem getZipFileSystem(Path path, Map<String, ?> env) throws IOException {
   130         ZipFileSystem zipfs;
       
   131         try {
   124         try {
   132             if (env.containsKey(PROPERTY_RELEASE_VERSION) ||
   125             return new ZipFileSystem(this, path, env);
   133                     env.containsKey(PROPERTY_MULTI_RELEASE)) {
       
   134                 zipfs = new JarFileSystem(this, path, env);
       
   135             } else {
       
   136                 zipfs = new ZipFileSystem(this, path, env);
       
   137             }
       
   138         } catch (ZipException ze) {
   126         } catch (ZipException ze) {
   139             String pname = path.toString();
   127             String pname = path.toString();
   140             if (pname.endsWith(".zip") || pname.endsWith(".jar"))
   128             if (pname.endsWith(".zip") || pname.endsWith(".jar"))
   141                 throw ze;
   129                 throw ze;
   142             throw new UnsupportedOperationException();
   130             throw new UnsupportedOperationException();
   143         }
   131         }
   144         return zipfs;
       
   145     }
   132     }
   146 
   133 
   147     @Override
   134     @Override
   148     public Path getPath(URI uri) {
   135     public Path getPath(URI uri) {
   149         String spec = uri.getSchemeSpecificPart();
   136         String spec = uri.getSchemeSpecificPart();