changeset 50822:a9307f400f5a

8203328: Rename EFS in java.util.zip internals to something meaningful Reviewed-by: sherman
author martin
date Wed, 23 May 2018 10:34:18 -0700
parents ec52b4d094c0
children a28085b5830e
files src/java.base/share/classes/java/util/zip/Deflater.java src/java.base/share/classes/java/util/zip/DeflaterOutputStream.java src/java.base/share/classes/java/util/zip/Inflater.java src/java.base/share/classes/java/util/zip/ZipConstants64.java src/java.base/share/classes/java/util/zip/ZipEntry.java src/java.base/share/classes/java/util/zip/ZipFile.java src/java.base/share/classes/java/util/zip/ZipInputStream.java src/java.base/share/classes/java/util/zip/ZipOutputStream.java src/java.base/share/classes/java/util/zip/ZipUtils.java src/java.base/share/classes/java/util/zip/package-info.java src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java test/jdk/java/util/zip/ZipCoding.java
diffstat 13 files changed, 41 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/zip/Deflater.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/Deflater.java	Wed May 23 10:34:18 2018 -0700
@@ -75,7 +75,7 @@
  *
  *     // Decode the bytes into a String
  *     String outputString = new String(result, 0, resultLength, "UTF-8");
- * } catch(java.io.UnsupportedEncodingException ex) {
+ * } catch (java.io.UnsupportedEncodingException ex) {
  *     // handle
  * } catch (java.util.zip.DataFormatException ex) {
  *     // handle
--- a/src/java.base/share/classes/java/util/zip/DeflaterOutputStream.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/DeflaterOutputStream.java	Wed May 23 10:34:18 2018 -0700
@@ -54,7 +54,6 @@
     /**
      * Indicates that the stream has been closed.
      */
-
     private boolean closed = false;
 
     private final boolean syncFlush;
@@ -62,7 +61,7 @@
     /**
      * Creates a new output stream with the specified compressor,
      * buffer size and flush mode.
-
+     *
      * @param out the output stream
      * @param def the compressor ("deflater")
      * @param size the output buffer size
--- a/src/java.base/share/classes/java/util/zip/Inflater.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/Inflater.java	Wed May 23 10:34:18 2018 -0700
@@ -73,7 +73,7 @@
  *
  *     // Decode the bytes into a String
  *     String outputString = new String(result, 0, resultLength, "UTF-8");
- * } catch(java.io.UnsupportedEncodingException ex) {
+ * } catch (java.io.UnsupportedEncodingException ex) {
  *     // handle
  * } catch (java.util.zip.DataFormatException ex) {
  *     // handle
--- a/src/java.base/share/classes/java/util/zip/ZipConstants64.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/ZipConstants64.java	Wed May 23 10:34:18 2018 -0700
@@ -74,11 +74,12 @@
     static final int  ZIP64_EXTLEN = 16;      // uncompressed size, 8-byte
 
     /*
-     * Language encoding flag EFS
+     * Language encoding flag (general purpose flag bit 11)
+     *
+     * If this bit is set the filename and comment fields for this
+     * entry must be encoded using UTF-8.
      */
-    static final int EFS = 0x800;       // If this bit is set the filename and
-                                        // comment fields for this file must be
-                                        // encoded using UTF-8.
+    static final int USE_UTF8 = 0x800;
 
     /*
      * Constants below are defined here (instead of in ZipConstants)
--- a/src/java.base/share/classes/java/util/zip/ZipEntry.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/ZipEntry.java	Wed May 23 10:34:18 2018 -0700
@@ -354,7 +354,6 @@
      * or ZIP file formatted stream.
      *
      * @return The last access time of the entry, null if not specified
-
      * @see #setLastAccessTime(FileTime)
      * @since 1.8
      */
--- a/src/java.base/share/classes/java/util/zip/ZipFile.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/ZipFile.java	Wed May 23 10:34:18 2018 -0700
@@ -377,7 +377,7 @@
             ensureOpen();
             if (Objects.equals(lastEntryName, entry.name)) {
                 pos = lastEntryPos;
-            } else if (!zc.isUTF8() && (entry.flag & EFS) != 0) {
+            } else if (!zc.isUTF8() && (entry.flag & USE_UTF8) != 0) {
                 pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false);
             } else {
                 pos = zsrc.getEntryPos(zc.getBytes(entry.name), false);
@@ -519,7 +519,7 @@
 
         @Override
         @SuppressWarnings("unchecked")
-        public T  next() {
+        public T next() {
             synchronized (ZipFile.this) {
                 ensureOpen();
                 if (!hasNext()) {
@@ -605,7 +605,7 @@
     private String getEntryName(int pos) {
         byte[] cen = res.zsrc.cen;
         int nlen = CENNAM(cen, pos);
-        if (!zc.isUTF8() && (CENFLG(cen, pos) & EFS) != 0) {
+        if (!zc.isUTF8() && (CENFLG(cen, pos) & USE_UTF8) != 0) {
             return zc.toStringUTF8(cen, pos + CENHDR, nlen);
         } else {
             return zc.toString(cen, pos + CENHDR, nlen);
@@ -665,7 +665,7 @@
             // (1) null, invoked from iterator, or
             // (2) not equal to the name stored, a slash is appended during
             // getEntryPos() search.
-            if (!zc.isUTF8() && (flag & EFS) != 0) {
+            if (!zc.isUTF8() && (flag & USE_UTF8) != 0) {
                 name = zc.toStringUTF8(cen, pos + CENHDR, nlen);
             } else {
                 name = zc.toString(cen, pos + CENHDR, nlen);
@@ -684,7 +684,7 @@
         }
         if (clen != 0) {
             int start = pos + CENHDR + nlen + elen;
-            if (!zc.isUTF8() && (flag & EFS) != 0) {
+            if (!zc.isUTF8() && (flag & USE_UTF8) != 0) {
                 e.comment = zc.toStringUTF8(cen, start, clen);
             } else {
                 e.comment = zc.toString(cen, start, clen);
@@ -790,7 +790,7 @@
                         for (InputStream is : copy) {
                             try {
                                 is.close();
-                            }  catch (IOException e) {
+                            } catch (IOException e) {
                                 if (ioe == null) ioe = e;
                                 else ioe.addSuppressed(e);
                             }
@@ -805,9 +805,9 @@
                     try {
                         Source.release(zsrc);
                         zsrc = null;
-                     }  catch (IOException e) {
-                         if (ioe == null) ioe = e;
-                         else ioe.addSuppressed(e);
+                    } catch (IOException e) {
+                        if (ioe == null) ioe = e;
+                        else ioe.addSuppressed(e);
                     }
                 }
             }
@@ -928,7 +928,7 @@
      * Inner class implementing the input stream used to read a
      * (possibly compressed) zip file entry.
      */
-   private class ZipFileInputStream extends InputStream {
+    private class ZipFileInputStream extends InputStream {
         private volatile boolean closeRequested;
         private   long pos;     // current position within entry data
         protected long rem;     // number of remaining bytes within entry
@@ -947,7 +947,7 @@
             pos = - (pos + ZipFile.this.res.zsrc.locpos);
         }
 
-         private void checkZIP64(byte[] cen, int cenpos) {
+        private void checkZIP64(byte[] cen, int cenpos) {
             int off = cenpos + CENHDR + CENNAM(cen, cenpos);
             int end = off + CENEXT(cen, cenpos);
             while (off + 4 < end) {
@@ -984,11 +984,12 @@
             }
         }
 
-       /* The Zip file spec explicitly allows the LOC extra data size to
-        * be different from the CEN extra data size. Since we cannot trust
-        * the CEN extra data size, we need to read the LOC to determine
-        * the entry data offset.
-        */
+        /*
+         * The Zip file spec explicitly allows the LOC extra data size to
+         * be different from the CEN extra data size. Since we cannot trust
+         * the CEN extra data size, we need to read the LOC to determine
+         * the entry data offset.
+         */
         private long initDataOffset() throws IOException {
             if (pos <= 0) {
                 byte[] loc = new byte[LOCHDR];
@@ -1205,7 +1206,7 @@
                     }
                     Object fk = attrs.fileKey();
                     if (fk != null) {
-                        return  fk.equals(key.attrs.fileKey());
+                        return fk.equals(key.attrs.fileKey());
                     } else {
                         return file.equals(key.file);
                     }
@@ -1289,7 +1290,7 @@
         private final int readFullyAt(byte[] buf, int off, int len, long pos)
             throws IOException
         {
-            synchronized(zfile) {
+            synchronized (zfile) {
                 zfile.seek(pos);
                 int N = len;
                 while (N > 0) {
@@ -1305,7 +1306,7 @@
         private final int readAt(byte[] buf, int off, int len, long pos)
             throws IOException
         {
-            synchronized(zfile) {
+            synchronized (zfile) {
                 zfile.seek(pos);
                 return zfile.read(buf, off, len);
             }
@@ -1476,7 +1477,7 @@
             int hsh = 0;
             int pos = 0;
             int limit = cen.length - ENDHDR;
-            while (pos + CENHDR  <= limit) {
+            while (pos + CENHDR <= limit) {
                 if (i >= total) {
                     // This will only happen if the zip file has an incorrect
                     // ENDTOT field, which usually means it contains more than
@@ -1544,7 +1545,7 @@
              * array has enough room at the end to try again with a
              * slash appended if the first table lookup does not succeed.
              */
-            while(true) {
+            while (true) {
                 /*
                  * Search down the target hash chain for a entry whose
                  * 32 bit hash matches the hashed name.
--- a/src/java.base/share/classes/java/util/zip/ZipInputStream.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/ZipInputStream.java	Wed May 23 10:34:18 2018 -0700
@@ -98,7 +98,7 @@
     public ZipInputStream(InputStream in, Charset charset) {
         super(new PushbackInputStream(in, 512), new Inflater(true), 512);
         usesDefaultInflater = true;
-        if(in == null) {
+        if (in == null) {
             throw new NullPointerException("in is null");
         }
         if (charset == null)
@@ -283,7 +283,7 @@
         if (get32(tmpbuf, 0) != LOCSIG) {
             return null;
         }
-        // get flag first, we need check EFS.
+        // get flag first, we need check USE_UTF8.
         flag = get16(tmpbuf, LOCFLG);
         // get the entry name and create the ZipEntry first
         int len = get16(tmpbuf, LOCNAM);
@@ -295,8 +295,8 @@
             b = new byte[blen];
         }
         readFully(b, 0, len);
-        // Force to use UTF-8 if the EFS bit is ON, even the cs is NOT UTF-8
-        ZipEntry e = createZipEntry(((flag & EFS) != 0)
+        // Force to use UTF-8 if the USE_UTF8 bit is ON
+        ZipEntry e = createZipEntry(((flag & USE_UTF8) != 0)
                                     ? zc.toStringUTF8(b, len)
                                     : zc.toString(b, len));
         // now get the remaining fields for the entry
--- a/src/java.base/share/classes/java/util/zip/ZipOutputStream.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/ZipOutputStream.java	Wed May 23 10:34:18 2018 -0700
@@ -97,6 +97,7 @@
             throw new IOException("Stream closed");
         }
     }
+
     /**
      * Compression method for uncompressed (STORED) entries.
      */
@@ -232,7 +233,7 @@
             throw new ZipException("duplicate entry: " + e.name);
         }
         if (zc.isUTF8())
-            e.flag |= EFS;
+            e.flag |= USE_UTF8;
         current = new XEntry(e, written);
         xentries.add(current);
         writeLOC(current);
--- a/src/java.base/share/classes/java/util/zip/ZipUtils.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/ZipUtils.java	Wed May 23 10:34:18 2018 -0700
@@ -88,7 +88,6 @@
     }
 
     /**
-     /*
      * Converts DOS time to Java time (number of milliseconds since epoch).
      */
     public static long dosToJavaTime(long dtime) {
--- a/src/java.base/share/classes/java/util/zip/package-info.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/java.base/share/classes/java/util/zip/package-info.java	Wed May 23 10:34:18 2018 -0700
@@ -46,7 +46,7 @@
  *     <li><a id="lang_encoding">APPENDIX D of</a>
  *         <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">
  *         PKWARE ZIP File Format Specification</a> - Language Encoding Flag
- *         (EFS) to encode ZIP entry filename and comment fields using UTF-8.
+ *         to encode ZIP entry filename and comment fields using UTF-8.
  *     <li><a href="http://www.ietf.org/rfc/rfc1950.txt">
  *         ZLIB Compressed Data Format Specification version 3.3</a>
  *         &nbsp;
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java	Wed May 23 10:34:18 2018 -0700
@@ -43,11 +43,11 @@
     static final int METHOD_AES        = 99;
 
     /*
-     * General purpose big flag
+     * General purpose bit flag
      */
     static final int FLAG_ENCRYPTED  = 0x01;
     static final int FLAG_DATADESCR  = 0x08;    // crc, size and csize in dd
-    static final int FLAG_EFS        = 0x800;   // If this bit is set the filename and
+    static final int FLAG_USE_UTF8   = 0x800;   // If this bit is set the filename and
                                                 // comment fields for this file must be
                                                 // encoded using UTF-8.
     /*
--- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Wed May 23 08:49:00 2018 -0700
+++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java	Wed May 23 10:34:18 2018 -0700
@@ -1374,7 +1374,7 @@
         // store size, compressed size, and crc-32 in LOC header
         e.flag = 0;
         if (zc.isUTF8())
-            e.flag |= FLAG_EFS;
+            e.flag |= FLAG_USE_UTF8;
         OutputStream os;
         if (useTempFile) {
             e.file = getTempPathForEntry(null);
--- a/test/jdk/java/util/zip/ZipCoding.java	Wed May 23 08:49:00 2018 -0700
+++ b/test/jdk/java/util/zip/ZipCoding.java	Wed May 23 10:34:18 2018 -0700
@@ -114,7 +114,7 @@
         testZipInputStream(bis, cs, name, comment, bb);
 
         if ("utf-8".equals(csn)) {
-            // EFS should be set
+            // USE_UTF8 should be set
             bis.reset();
             testZipInputStream(bis, Charset.forName("MS932"), name, comment, bb);
         }