8215472: (zipfs) Cleanups in implementation classes of jdk.zipfs and tests
authorclanger
Wed, 19 Dec 2018 10:36:16 +0000
changeset 53043 fd2e8f941ded
parent 53042 56fbb14251ca
child 53044 432795b1c2c8
8215472: (zipfs) Cleanups in implementation classes of jdk.zipfs and tests Reviewed-by: redestad, lancea
src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystemProvider.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipDirectoryStream.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileAttributeView.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileAttributes.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileStore.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystemProvider.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipInfo.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java
src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipUtils.java
test/jdk/java/util/zip/zip.java
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java	Wed Dec 19 10:36:16 2018 +0000
@@ -48,7 +48,6 @@
  *
  * @author Steve Drach
  */
-
 class JarFileSystem extends ZipFileSystem {
     private Function<byte[],byte[]> lookup;
 
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystemProvider.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystemProvider.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -25,21 +25,13 @@
 
 package jdk.nio.zipfs;
 
-import java.nio.file.*;
-import java.nio.file.spi.*;
-import java.nio.file.attribute.*;
-import java.nio.file.spi.FileSystemProvider;
-
 import java.net.URI;
-import java.io.IOException;
 import java.net.URISyntaxException;
-import java.nio.channels.FileChannel;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
-class JarFileSystemProvider extends ZipFileSystemProvider
-{
+class JarFileSystemProvider extends ZipFileSystemProvider {
 
     @Override
     public String getScheme() {
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipCoder.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -34,15 +34,14 @@
 import java.nio.charset.CodingErrorAction;
 import java.util.Arrays;
 
+import static java.nio.charset.StandardCharsets.ISO_8859_1;
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.nio.charset.StandardCharsets.ISO_8859_1;
 
 /**
  * Utility class for zipfile name and comment decoding and encoding
  *
- * @author  Xueming Shen
+ * @author Xueming Shen
  */
-
 class ZipCoder {
 
     static class UTF8 extends ZipCoder {
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -26,10 +26,8 @@
 package jdk.nio.zipfs;
 
 /**
- *
  * @author Xueming Shen
  */
-
 class ZipConstants {
     /*
      * Compression methods
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipDirectoryStream.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipDirectoryStream.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -25,19 +25,18 @@
 
 package jdk.nio.zipfs;
 
+import java.io.IOException;
+import java.nio.file.ClosedDirectoryStreamException;
 import java.nio.file.DirectoryStream;
-import java.nio.file.ClosedDirectoryStreamException;
 import java.nio.file.NotDirectoryException;
 import java.nio.file.Path;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
-import java.io.IOException;
 
 /**
  *
- * @author  Xueming Shen, Rajendra Gutupalli, Jaya Hangal
+ * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
  */
-
 class ZipDirectoryStream implements DirectoryStream<Path> {
 
     private final ZipFileSystem zipfs;
@@ -70,8 +69,8 @@
         } catch (IOException e) {
             throw new IllegalStateException(e);
         }
+
         return new Iterator<Path>() {
-            private Path next;
             @Override
             public boolean hasNext() {
                 if (isClosed)
@@ -97,5 +96,4 @@
     public synchronized void close() throws IOException {
         isClosed = true;
     }
-
 }
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileAttributeView.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileAttributeView.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -25,17 +25,17 @@
 
 package jdk.nio.zipfs;
 
-import java.nio.file.attribute.*;
 import java.io.IOException;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.FileAttributeView;
+import java.nio.file.attribute.FileTime;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
-/*
- * @author  Xueming Shen, Rajendra Gutupalli, Jaya Hangal
+/**
+ * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
  */
-
-class ZipFileAttributeView implements BasicFileAttributeView
-{
+class ZipFileAttributeView implements BasicFileAttributeView {
     private static enum AttrID {
         size,
         creationTime,
@@ -85,8 +85,7 @@
         return isZipView ? "zip" : "basic";
     }
 
-    public ZipFileAttributes readAttributes() throws IOException
-    {
+    public ZipFileAttributes readAttributes() throws IOException {
         return path.getAttributes();
     }
 
@@ -104,11 +103,11 @@
     {
         try {
             if (AttrID.valueOf(attribute) == AttrID.lastModifiedTime)
-                setTimes ((FileTime)value, null, null);
+                setTimes((FileTime)value, null, null);
             if (AttrID.valueOf(attribute) == AttrID.lastAccessTime)
-                setTimes (null, (FileTime)value, null);
+                setTimes(null, (FileTime)value, null);
             if (AttrID.valueOf(attribute) == AttrID.creationTime)
-                setTimes (null, null, (FileTime)value);
+                setTimes(null, null, (FileTime)value);
             return;
         } catch (IllegalArgumentException x) {}
         throw new UnsupportedOperationException("'" + attribute +
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileAttributes.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileAttributes.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -28,10 +28,10 @@
 import java.nio.file.attribute.BasicFileAttributes;
 
 /**
+ * The attributes of a file stored in a zip file.
  *
- * @author  Xueming Shen, Rajendra Gutupalli,Jaya Hangal
+ * @author Xueming Shen, Rajendra Gutupalli,Jaya Hangal
  */
-
 interface ZipFileAttributes extends BasicFileAttributes {
     public long compressedSize();
     public long crc();
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileStore.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileStore.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -26,21 +26,17 @@
 package jdk.nio.zipfs;
 
 import java.io.IOException;
-import java.nio.file.Files;
 import java.nio.file.FileStore;
 import java.nio.file.FileSystems;
+import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.BasicFileAttributeView;
 import java.nio.file.attribute.FileAttributeView;
 import java.nio.file.attribute.FileStoreAttributeView;
-import java.nio.file.attribute.BasicFileAttributeView;
-import java.util.Formatter;
 
-/*
- *
- * @author  Xueming Shen, Rajendra Gutupalli, Jaya Hangal
+/**
+ * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
  */
-
 class ZipFileStore extends FileStore {
 
     private final ZipFileSystem zfs;
@@ -76,7 +72,6 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) {
         if (type == null)
             throw new NullPointerException();
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -29,17 +29,22 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.EOFException;
-import java.io.File;
 import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
-import java.nio.channels.*;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SeekableByteChannel;
+import java.nio.channels.WritableByteChannel;
 import java.nio.file.*;
-import java.nio.file.attribute.*;
-import java.nio.file.spi.*;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.FileTime;
+import java.nio.file.attribute.UserPrincipalLookupService;
+import java.nio.file.spi.FileSystemProvider;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
@@ -49,25 +54,30 @@
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.regex.Pattern;
 import java.util.zip.CRC32;
+import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
 import java.util.zip.Inflater;
-import java.util.zip.Deflater;
 import java.util.zip.InflaterInputStream;
-import java.util.zip.DeflaterOutputStream;
 import java.util.zip.ZipException;
-import static java.lang.Boolean.*;
+
+import static java.lang.Boolean.TRUE;
+import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import static java.nio.file.StandardOpenOption.APPEND;
+import static java.nio.file.StandardOpenOption.CREATE;
+import static java.nio.file.StandardOpenOption.CREATE_NEW;
+import static java.nio.file.StandardOpenOption.READ;
+import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
+import static java.nio.file.StandardOpenOption.WRITE;
 import static jdk.nio.zipfs.ZipConstants.*;
 import static jdk.nio.zipfs.ZipUtils.*;
-import static java.nio.file.StandardOpenOption.*;
-import static java.nio.file.StandardCopyOption.*;
 
 /**
  * A FileSystem built on a zip file
  *
  * @author Xueming Shen
  */
-
 class ZipFileSystem extends FileSystem {
-
     private final ZipFileSystemProvider provider;
     private final Path zfpath;
     final ZipCoder zc;
@@ -79,15 +89,15 @@
     private final boolean useTempFile;   // use a temp file for newOS, default
                                          // is to use BAOS for better performance
     private static final boolean isWindows = AccessController.doPrivileged(
-            (PrivilegedAction<Boolean>) () -> System.getProperty("os.name")
-                                                    .startsWith("Windows"));
+            (PrivilegedAction<Boolean>)() -> System.getProperty("os.name")
+                                                   .startsWith("Windows"));
     private final boolean forceEnd64;
     private final int defaultMethod;     // METHOD_STORED if "noCompression=true"
                                          // METHOD_DEFLATED otherwise
 
     ZipFileSystem(ZipFileSystemProvider provider,
                   Path zfpath,
-                  Map<String, ?> env)  throws IOException
+                  Map<String, ?> env) throws IOException
     {
         // default encoding for name/comment
         String nameEncoding = env.containsKey("encoding") ?
@@ -269,12 +279,12 @@
         }
         if (!streams.isEmpty()) {    // unlock and close all remaining streams
             Set<InputStream> copy = new HashSet<>(streams);
-            for (InputStream is: copy)
+            for (InputStream is : copy)
                 is.close();
         }
         beginWrite();                // lock and sync
         try {
-            AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+            AccessController.doPrivileged((PrivilegedExceptionAction<Void>)() -> {
                 sync(); return null;
             });
             ch.close();              // close the ch just in case no update
@@ -296,7 +306,7 @@
 
         IOException ioe = null;
         synchronized (tmppaths) {
-            for (Path p: tmppaths) {
+            for (Path p : tmppaths) {
                 try {
                     AccessController.doPrivileged(
                         (PrivilegedExceptionAction<Boolean>)() -> Files.deleteIfExists(p));
@@ -521,7 +531,7 @@
         boolean hasCreate = false;
         boolean hasAppend = false;
         boolean hasTruncate = false;
-        for (OpenOption opt: options) {
+        for (OpenOption opt : options) {
             if (opt == READ)
                 throw new IllegalArgumentException("READ not allowed");
             if (opt == CREATE_NEW)
@@ -1455,6 +1465,7 @@
             e.size  = def.getBytesRead();
             e.csize = def.getBytesWritten();
             e.crc = crc.getValue();
+            releaseDeflater(def);
         }
     }
 
@@ -1477,7 +1488,7 @@
             // TBD: wrap to hook close()
             // streams.add(eis);
             return eis;
-        } else {  // untouced  CEN or COPY
+        } else {  // untouched CEN or COPY
             eis = new EntryInputStream(e, ch);
         }
         if (e.method == METHOD_DEFLATED) {
@@ -1539,14 +1550,12 @@
                                           // point to a new channel after sync()
         private   long pos;               // current position within entry data
         protected long rem;               // number of remaining bytes within entry
-        protected final long size;        // uncompressed size of this entry
 
         EntryInputStream(Entry e, SeekableByteChannel zfch)
             throws IOException
         {
             this.zfch = zfch;
             rem = e.csize;
-            size = e.size;
             pos = e.locoff;
             if (pos == -1) {
                 Entry e2 = getEntry(e.name);
@@ -1613,10 +1622,6 @@
             return rem > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) rem;
         }
 
-        public long size() {
-            return size;
-        }
-
         public void close() {
             rem = 0;
             streams.remove(this);
@@ -1672,7 +1677,7 @@
     // List of available Deflater objects for compression
     private final List<Deflater> deflaters = new ArrayList<>();
 
-    // Gets an deflater from the list of available deflaters or allocates
+    // Gets a deflater from the list of available deflaters or allocates
     // a new one.
     private Deflater getDeflater() {
         synchronized (deflaters) {
@@ -1985,9 +1990,7 @@
             return this;
         }
 
-        int writeCEN(OutputStream os) throws IOException
-        {
-            int written  = CENHDR;
+        int writeCEN(OutputStream os) throws IOException {
             int version0 = version();
             long csize0  = csize;
             long size0   = size;
@@ -2101,9 +2104,7 @@
         ///////////////////// LOC //////////////////////
 
         int writeLOC(OutputStream os) throws IOException {
-            writeInt(os, LOCSIG);               // LOC header signature
-            int version = version();
-
+            int version0 = version();
             byte[] zname = isdir ? toDirectoryPath(name) : name;
             int nlen = (zname != null) ? zname.length - 1 : 0; // [0] is slash
             int elen = (extra != null) ? extra.length : 0;
@@ -2112,8 +2113,9 @@
             int elen64 = 0;
             int elenEXTT = 0;
             int elenNTFS = 0;
+            writeInt(os, LOCSIG);               // LOC header signature
             if ((flag & FLAG_DATADESCR) != 0) {
-                writeShort(os, version());      // version needed to extract
+                writeShort(os, version0);       // version needed to extract
                 writeShort(os, flag);           // general purpose bit flag
                 writeShort(os, method);         // compression method
                 // last modification time
@@ -2128,7 +2130,7 @@
                     elen64 = 20;    //headid(2) + size(2) + size(8) + csize(8)
                     writeShort(os, 45);         // ver 4.5 for zip64
                 } else {
-                    writeShort(os, version());  // version needed to extract
+                    writeShort(os, version0);   // version needed to extract
                 }
                 writeShort(os, flag);           // general purpose bit flag
                 writeShort(os, method);         // compression method
@@ -2430,7 +2432,6 @@
     //     structure.
     // A possible solution is to build the node tree ourself as
     // implemented below.
-    private IndexNode root;
 
     // default time stamp for pseudo entries
     private long zfsDefaultTimeStamp = System.currentTimeMillis();
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystemProvider.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystemProvider.java	Wed Dec 19 10:36:16 2018 +0000
@@ -25,28 +25,31 @@
 
 package jdk.nio.zipfs;
 
-import java.io.*;
-import java.nio.channels.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
 import java.nio.file.*;
 import java.nio.file.DirectoryStream.Filter;
-import java.nio.file.attribute.*;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.FileAttributeView;
 import java.nio.file.spi.FileSystemProvider;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ExecutorService;
 import java.util.zip.ZipException;
-import java.util.concurrent.ExecutorService;
 
-/*
- *
- * @author  Xueming Shen, Rajendra Gutupalli, Jaya Hangal
+/**
+ * @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
  */
-
 public class ZipFileSystemProvider extends FileSystemProvider {
 
-
     private final Map<Path, ZipFileSystem> filesystems = new HashMap<>();
 
     public ZipFileSystemProvider() {}
@@ -202,7 +205,6 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     public <V extends FileAttributeView> V
         getFileAttributeView(Path path, Class<V> type, LinkOption... options)
     {
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipInfo.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipInfo.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -28,15 +28,17 @@
 import java.nio.file.Paths;
 import java.util.Collections;
 import java.util.Map;
+
 import static jdk.nio.zipfs.ZipConstants.*;
-import static jdk.nio.zipfs.ZipUtils.*;
+import static jdk.nio.zipfs.ZipUtils.dosToJavaTime;
+import static jdk.nio.zipfs.ZipUtils.unixToJavaTime;
+import static jdk.nio.zipfs.ZipUtils.winToJavaTime;
 
 /**
  * Print all loc and cen headers of the ZIP file
  *
- * @author  Xueming Shen
+ * @author Xueming Shen
  */
-
 public class ZipInfo {
 
     public static void main(String[] args) throws Throwable {
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipPath.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -25,22 +25,36 @@
 
 package jdk.nio.zipfs;
 
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.URI;
-import java.nio.channels.*;
+import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
 import java.nio.file.*;
 import java.nio.file.DirectoryStream.Filter;
-import java.nio.file.attribute.*;
-import java.util.*;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.FileTime;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.Set;
+
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.nio.file.StandardOpenOption.*;
-import static java.nio.file.StandardCopyOption.*;
+import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import static java.nio.file.StandardOpenOption.CREATE;
+import static java.nio.file.StandardOpenOption.READ;
+import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
+import static java.nio.file.StandardOpenOption.WRITE;
 
 /**
- *
- * @author  Xueming Shen, Rajendra Gutupalli,Jaya Hangal
+ * @author Xueming Shen, Rajendra Gutupalli,Jaya Hangal
  */
-
 final class ZipPath implements Path {
 
     private final ZipFileSystem zfs;
@@ -522,7 +536,6 @@
     private byte[] normalize(String path, int off, int len) {
         StringBuilder to = new StringBuilder(len);
         to.append(path, 0, off);
-        int m = off;
         char prevC = 0;
         while (off < len) {
             char c = path.charAt(off++);
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipUtils.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipUtils.java	Wed Dec 19 10:36:16 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2018, 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
@@ -33,14 +33,12 @@
 import java.time.ZoneId;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.PatternSyntaxException;
-import java.util.concurrent.TimeUnit;
 
 /**
- *
  * @author Xueming Shen
  */
-
 class ZipUtils {
 
     /*
@@ -155,7 +153,6 @@
             ldt.getSecond() >> 1) & 0xffffffffL;
     }
 
-
     // used to adjust values between Windows and java epoch
     private static final long WINDOWS_EPOCH_IN_MICROSECONDS = -11644473600000000L;
     public static final long winToJavaTime(long wtime) {
--- a/test/jdk/java/util/zip/zip.java	Wed Dec 19 10:30:43 2018 +0100
+++ b/test/jdk/java/util/zip/zip.java	Wed Dec 19 10:36:16 2018 +0000
@@ -23,9 +23,14 @@
 
 import java.io.*;
 import java.nio.charset.Charset;
+import java.text.MessageFormat;
 import java.util.*;
-import java.util.zip.*;
-import java.text.MessageFormat;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
 
 /**
  * A stripped-down version of Jar tool with a "-encoding" option to
@@ -39,9 +44,9 @@
     String[] files;
     Charset cs = Charset.forName("UTF-8");
 
-    Map<String, File> entryMap = new HashMap<String, File>();
-    Set<File> entries = new LinkedHashSet<File>();
-    List<String> paths = new ArrayList<String>();
+    Map<String, File> entryMap = new HashMap<>();
+    Set<File> entries = new LinkedHashSet<>();
+    List<String> paths = new ArrayList<>();
 
     CRC32 crc32 = new CRC32();
     /*
@@ -330,15 +335,13 @@
         }
     }
 
-    boolean update(InputStream in, OutputStream out) throws IOException
-    {
+    boolean update(InputStream in, OutputStream out) throws IOException {
         try (ZipInputStream zis = new ZipInputStream(in, cs);
              ZipOutputStream zos = new ZipOutputStream(out, cs))
         {
             ZipEntry e = null;
             byte[] buf = new byte[1024];
             int n = 0;
-            boolean updateOk = true;
 
             // put the old entries first, replace if necessary
             while ((e = zis.getNextEntry()) != null) {
@@ -367,11 +370,11 @@
             }
 
             // add the remaining new files
-            for (File f: entries) {
+            for (File f : entries) {
                 addFile(zos, f);
             }
         }
-        return updateOk;
+        return true;
     }
 
     private String entryName(String name) {
@@ -479,6 +482,8 @@
 
     Set<ZipEntry> newDirSet() {
         return new HashSet<ZipEntry>() {
+            private static final long serialVersionUID = 4547977575248028254L;
+
             public boolean add(ZipEntry e) {
                 return (e == null || super.add(e));
             }};
@@ -520,7 +525,6 @@
             Enumeration<? extends ZipEntry> zes = zf.entries();
             while (zes.hasMoreElements()) {
                 ZipEntry e = zes.nextElement();
-                InputStream is;
                 if (files == null) {
                     dirs.add(extractFile(zf.getInputStream(e), e));
                 } else {
@@ -533,8 +537,8 @@
                     }
                 }
             }
+            updateLastModifiedTime(dirs);
         }
-        updateLastModifiedTime(dirs);
     }
 
     ZipEntry extractFile(InputStream is, ZipEntry e) throws IOException {
@@ -727,7 +731,7 @@
         st.commentChar('#');
         st.quoteChar('"');
         st.quoteChar('\'');
-        while (st.nextToken() != st.TT_EOF) {
+        while (st.nextToken() != StreamTokenizer.TT_EOF) {
             args.add(st.sval);
         }
         r.close();
@@ -738,4 +742,3 @@
         System.exit(z.run(args) ? 0 : 1);
     }
 }
-