--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystemProvider.java Fri Oct 04 15:51:17 2019 -0400
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystemProvider.java Sun Oct 06 13:08:58 2019 -0400
@@ -53,6 +53,11 @@
*/
public class ZipFileSystemProvider extends FileSystemProvider {
+ // Property used to specify the entry version to use for a multi-release JAR
+ static final String PROPERTY_RELEASE_VERSION = "releaseVersion";
+ // Original property used to specify the entry version to use for a
+ // multi-release JAR which is kept for backwards compatibility.
+ static final String PROPERTY_MULTI_RELEASE = "multi-release";
private final Map<Path, ZipFileSystem> filesystems = new HashMap<>();
public ZipFileSystemProvider() {}
@@ -104,20 +109,7 @@
if (filesystems.containsKey(realPath))
throw new FileSystemAlreadyExistsException();
}
- ZipFileSystem zipfs;
- try {
- if (env.containsKey("multi-release")) {
- zipfs = new JarFileSystem(this, path, env);
- } else {
- zipfs = new ZipFileSystem(this, path, env);
- }
- } catch (ZipException ze) {
- String pname = path.toString();
- if (pname.endsWith(".zip") || pname.endsWith(".jar"))
- throw ze;
- // assume NOT a zip/jar file
- throw new UnsupportedOperationException();
- }
+ ZipFileSystem zipfs = getZipFileSystem(path, env);
if (realPath == null) { // newly created
realPath = path.toRealPath();
}
@@ -131,20 +123,25 @@
throws IOException
{
ensureFile(path);
+ return getZipFileSystem(path, env);
+ }
+
+ private ZipFileSystem getZipFileSystem(Path path, Map<String, ?> env) throws IOException {
+ ZipFileSystem zipfs;
try {
- ZipFileSystem zipfs;
- if (env.containsKey("multi-release")) {
+ if (env.containsKey(PROPERTY_RELEASE_VERSION) ||
+ env.containsKey(PROPERTY_MULTI_RELEASE)) {
zipfs = new JarFileSystem(this, path, env);
} else {
zipfs = new ZipFileSystem(this, path, env);
}
- return zipfs;
} catch (ZipException ze) {
String pname = path.toString();
if (pname.endsWith(".zip") || pname.endsWith(".jar"))
throw ze;
throw new UnsupportedOperationException();
}
+ return zipfs;
}
@Override