RFR 8144355: JDK 9 changes to ZipFileSystem to support multi-release jar files
Paul Sandoz
paul.sandoz at oracle.com
Fri Dec 18 08:28:44 UTC 2015
HI Steve,
I find the use of the system property awkward.
Did you try doing:
new File(...).toURI()
?
I noticed you are already creating Path instances for deletion, so it might be even better to do Path.toURI() e.g.:
uvuri = “jar:” + Paths.get(userdir, "unversioned.jar”).toURI();
rather than:
uvuri = “jar:” + new FIle(userdir, "unversioned.jar”).toURI();
Paul.
> On 18 Dec 2015, at 03:20, Steve Drach <steve.drach at oracle.com> wrote:
>
> Hi,
>
> jprt found a bug in one of my tests when run on windows. The fix is simple as you can see in the patch below. I also took the opportunity to add a comment to a line in the source code. Please let me know if these patches can be added to the changeset.
>
> Thanks
> Steve
>
> diff --git a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java
> --- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java
> +++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java
> @@ -55,7 +55,8 @@
>
> JarFileSystem(ZipFileSystemProvider provider, Path zfpath, Map<String,?> env) throws IOException {
> super(provider, zfpath, env);
> - lookup = path -> path;
> + lookup = path -> path; // lookup needs to be set before isMultiReleaseJar is called because
> + // it eventually calls getEntry0
> if (isMultiReleaseJar()) {
> int version;
> Object o = env.get("multi-release");
> diff --git a/test/jdk/nio/zipfs/MultiReleaseJarTest.java b/test/jdk/nio/zipfs/MultiReleaseJarTest.java
> --- a/test/jdk/nio/zipfs/MultiReleaseJarTest.java
> +++ b/test/jdk/nio/zipfs/MultiReleaseJarTest.java
> @@ -65,9 +65,15 @@
> creator.buildUnversionedJar();
> creator.buildMultiReleaseJar();
> creator.buildShortMultiReleaseJar();
> - uvuri = new URI("jar:file:" + userdir + "/unversioned.jar");
> - mruri = new URI("jar:file:" + userdir + "/multi-release.jar");
> - smruri = new URI("jar:file:" + userdir + "/short-multi-release.jar");
> + String udir;
> + if (System.getProperty("os.name").startsWith("Windows")) {
> + udir = "/" + userdir.replace('\\','/');
> + } else {
> + udir = userdir;
> + }
> + uvuri = new URI("jar:file:" + udir + "/unversioned.jar");
> + mruri = new URI("jar:file:" + udir + "/multi-release.jar");
> + smruri = new URI("jar:file:" + udir + "/short-multi-release.jar");
> entryName = className.replace('.', '/') + ".class";
> }
>
>> Issue: https://bugs.openjdk.java.net/browse/JDK-8144355
>>
>> Change to modules.xml: http://cr.openjdk.java.net/~sdrach/8144355/top/webrev.01/index.html
>>
>> Changes to ZipFileSystem: http://cr.openjdk.java.net/~sdrach/8144355/jdk/webrev.01/index.html
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20151218/50361253/signature.asc>
More information about the nio-dev
mailing list