src/java.base/share/classes/java/util/zip/ZipUtils.java
author redestad
Thu, 12 Oct 2017 16:00:29 +0200
changeset 47331 39d1de71faca
parent 47216 71c04702a3d5
child 49834 99644c75eaed
permissions -rw-r--r--
8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59 Reviewed-by: sherman, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
     1
/*
45924
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
     2
 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
     4
 *
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    10
 *
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    15
 * accompanied this code).
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    16
 *
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    20
 *
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    23
 * questions.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    24
 */
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    25
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    26
package java.util.zip;
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    27
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    28
import java.nio.file.attribute.FileTime;
45924
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
    29
import java.security.AccessController;
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
    30
import java.security.PrivilegedAction;
47331
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    31
import java.time.DateTimeException;
33405
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
    32
import java.time.Instant;
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
    33
import java.time.LocalDateTime;
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
    34
import java.time.ZoneId;
47331
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    35
import java.util.Date;
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    36
import java.util.concurrent.TimeUnit;
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    37
34686
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
    38
import static java.util.zip.ZipConstants.ENDHDR;
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
    39
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    40
class ZipUtils {
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    41
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    42
    // used to adjust values between Windows and java epoch
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    43
    private static final long WINDOWS_EPOCH_IN_MICROSECONDS = -11644473600000000L;
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    44
39772
c2a5d2de5253 8161942: java.util.zip.ZipEntry.java not covering UpperLimit range of DOS epoch
sherman
parents: 34686
diff changeset
    45
    // used to indicate the corresponding windows time is not available
c2a5d2de5253 8161942: java.util.zip.ZipEntry.java not covering UpperLimit range of DOS epoch
sherman
parents: 34686
diff changeset
    46
    public static final long WINDOWS_TIME_NOT_AVAILABLE = Long.MIN_VALUE;
c2a5d2de5253 8161942: java.util.zip.ZipEntry.java not covering UpperLimit range of DOS epoch
sherman
parents: 34686
diff changeset
    47
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    48
    /**
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    49
     * Converts Windows time (in microseconds, UTC/GMT) time to FileTime.
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    50
     */
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    51
    public static final FileTime winTimeToFileTime(long wtime) {
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    52
        return FileTime.from(wtime / 10 + WINDOWS_EPOCH_IN_MICROSECONDS,
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    53
                             TimeUnit.MICROSECONDS);
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    54
    }
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    55
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    56
    /**
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    57
     * Converts FileTime to Windows time.
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    58
     */
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    59
    public static final long fileTimeToWinTime(FileTime ftime) {
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    60
        return (ftime.to(TimeUnit.MICROSECONDS) - WINDOWS_EPOCH_IN_MICROSECONDS) * 10;
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    61
    }
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    62
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    63
    /**
39772
c2a5d2de5253 8161942: java.util.zip.ZipEntry.java not covering UpperLimit range of DOS epoch
sherman
parents: 34686
diff changeset
    64
     * The upper bound of the 32-bit unix time, the "year 2038 problem".
c2a5d2de5253 8161942: java.util.zip.ZipEntry.java not covering UpperLimit range of DOS epoch
sherman
parents: 34686
diff changeset
    65
     */
c2a5d2de5253 8161942: java.util.zip.ZipEntry.java not covering UpperLimit range of DOS epoch
sherman
parents: 34686
diff changeset
    66
    public static final long UPPER_UNIXTIME_BOUND = 0x7fffffff;
c2a5d2de5253 8161942: java.util.zip.ZipEntry.java not covering UpperLimit range of DOS epoch
sherman
parents: 34686
diff changeset
    67
c2a5d2de5253 8161942: java.util.zip.ZipEntry.java not covering UpperLimit range of DOS epoch
sherman
parents: 34686
diff changeset
    68
    /**
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    69
     * Converts "standard Unix time"(in seconds, UTC/GMT) to FileTime
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    70
     */
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    71
    public static final FileTime unixTimeToFileTime(long utime) {
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    72
        return FileTime.from(utime, TimeUnit.SECONDS);
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    73
    }
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    74
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    75
    /**
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    76
     * Converts FileTime to "standard Unix time".
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    77
     */
19374
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    78
    public static final long fileTimeToUnixTime(FileTime ftime) {
6773349693eb 8015666: test/tools/pack200/TimeStamp.java failing
sherman
parents: 17910
diff changeset
    79
        return ftime.to(TimeUnit.SECONDS);
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    80
    }
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    81
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    82
    /**
47331
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    83
     /*
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    84
     * Converts DOS time to Java time (number of milliseconds since epoch).
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
    85
     */
33405
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
    86
    public static long dosToJavaTime(long dtime) {
47331
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    87
        int year = (int) (((dtime >> 25) & 0x7f) + 1980);
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    88
        int month = (int) ((dtime >> 21) & 0x0f);
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    89
        int day = (int) ((dtime >> 16) & 0x1f);
46154
fcef65412084 8184940: JDK 9 rejects zip files where the modified day or month is 0
cushon
parents: 45924
diff changeset
    90
        int hour = (int) ((dtime >> 11) & 0x1f);
fcef65412084 8184940: JDK 9 rejects zip files where the modified day or month is 0
cushon
parents: 45924
diff changeset
    91
        int minute = (int) ((dtime >> 5) & 0x3f);
fcef65412084 8184940: JDK 9 rejects zip files where the modified day or month is 0
cushon
parents: 45924
diff changeset
    92
        int second = (int) ((dtime << 1) & 0x3e);
47331
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    93
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    94
        if (month > 0 && month < 13 && day > 0 && hour < 24 && minute < 60 && second < 60) {
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    95
            try {
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    96
                LocalDateTime ldt = LocalDateTime.of(year, month, day, hour, minute, second);
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    97
                return TimeUnit.MILLISECONDS.convert(ldt.toEpochSecond(
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    98
                        ZoneId.systemDefault().getRules().getOffset(ldt)), TimeUnit.SECONDS);
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
    99
            } catch (DateTimeException dte) {
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   100
                // ignore
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   101
            }
46154
fcef65412084 8184940: JDK 9 rejects zip files where the modified day or month is 0
cushon
parents: 45924
diff changeset
   102
        }
47331
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   103
        return overflowDosToJavaTime(year, month, day, hour, minute, second);
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   104
    }
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   105
47331
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   106
    /*
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   107
     * Deal with corner cases where an arguably mal-formed DOS time is used
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   108
     */
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   109
    @SuppressWarnings("deprecation") // Use of Date constructor
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   110
    private static long overflowDosToJavaTime(int year, int month, int day,
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   111
                                              int hour, int minute, int second) {
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   112
        return new Date(year - 1900, month - 1, day, hour, minute, second).getTime();
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   113
    }
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   114
39d1de71faca 8188869: jdk9/10 reject zip/jar files where seconds value of timestamp is out of supported range 0 - 59
redestad
parents: 47216
diff changeset
   115
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   116
    /**
29226
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   117
     * Converts extended DOS time to Java time, where up to 1999 milliseconds
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   118
     * might be encoded into the upper half of the returned long.
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   119
     *
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   120
     * @param xdostime the extended DOS time value
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   121
     * @return milliseconds since epoch
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   122
     */
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   123
    public static long extendedDosToJavaTime(long xdostime) {
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   124
        long time = dosToJavaTime(xdostime);
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   125
        return time + (xdostime >> 32);
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   126
    }
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   127
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   128
    /**
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   129
     * Converts Java time to DOS time.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   130
     */
29226
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   131
    private static long javaToDosTime(long time) {
33405
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   132
        Instant instant = Instant.ofEpochMilli(time);
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   133
        LocalDateTime ldt = LocalDateTime.ofInstant(
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   134
                instant, ZoneId.systemDefault());
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   135
        int year = ldt.getYear() - 1980;
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   136
        if (year < 0) {
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   137
            return (1 << 21) | (1 << 16);
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   138
        }
33405
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   139
        return (year << 25 |
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   140
            ldt.getMonthValue() << 21 |
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   141
            ldt.getDayOfMonth() << 16 |
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   142
            ldt.getHour() << 11 |
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   143
            ldt.getMinute() << 5 |
24ee3a0ba28f 8066644: Fix deprecation warnings in jdk.zipfs module
redestad
parents: 31820
diff changeset
   144
            ldt.getSecond() >> 1) & 0xffffffffL;
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   145
    }
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   146
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   147
    /**
29226
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   148
     * Converts Java time to DOS time, encoding any milliseconds lost
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   149
     * in the conversion into the upper half of the returned long.
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   150
     *
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   151
     * @param time milliseconds since epoch
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   152
     * @return DOS time with 2s remainder encoded into upper half
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   153
     */
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   154
    public static long javaToExtendedDosTime(long time) {
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   155
        if (time < 0) {
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   156
            return ZipEntry.DOSTIME_BEFORE_1980;
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   157
        }
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   158
        long dostime = javaToDosTime(time);
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   159
        return (dostime != ZipEntry.DOSTIME_BEFORE_1980)
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   160
                ? dostime + ((time % 2000) << 32)
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   161
                : ZipEntry.DOSTIME_BEFORE_1980;
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   162
    }
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   163
b675016fabfd 8073497: Lazy conversion of ZipEntry time
redestad
parents: 25859
diff changeset
   164
    /**
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   165
     * Fetches unsigned 16-bit value from byte array at specified offset.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   166
     * The bytes are assumed to be in Intel (little-endian) byte order.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   167
     */
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   168
    public static final int get16(byte b[], int off) {
34686
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   169
        return (b[off] & 0xff) | ((b[off + 1] & 0xff) << 8);
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   170
    }
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   171
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   172
    /**
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   173
     * Fetches unsigned 32-bit value from byte array at specified offset.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   174
     * The bytes are assumed to be in Intel (little-endian) byte order.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   175
     */
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   176
    public static final long get32(byte b[], int off) {
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   177
        return (get16(b, off) | ((long)get16(b, off+2) << 16)) & 0xffffffffL;
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   178
    }
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   179
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   180
    /**
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   181
     * Fetches signed 64-bit value from byte array at specified offset.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   182
     * The bytes are assumed to be in Intel (little-endian) byte order.
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   183
     */
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   184
    public static final long get64(byte b[], int off) {
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   185
        return get32(b, off) | (get32(b, off+4) << 32);
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   186
    }
31819
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   187
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   188
    /**
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   189
     * Fetches signed 32-bit value from byte array at specified offset.
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   190
     * The bytes are assumed to be in Intel (little-endian) byte order.
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   191
     *
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   192
     */
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   193
    public static final int get32S(byte b[], int off) {
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   194
        return (get16(b, off) | (get16(b, off+2) << 16));
ba7cde5a611a 8075526: Need a way to read and write ZipEntry timestamp using local date/time without tz conversion
sherman
parents: 29226
diff changeset
   195
    }
34686
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   196
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   197
    // fields access methods
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   198
    static final int CH(byte[] b, int n) {
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   199
        return b[n] & 0xff ;
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   200
    }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   201
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   202
    static final int SH(byte[] b, int n) {
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   203
        return (b[n] & 0xff) | ((b[n + 1] & 0xff) << 8);
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   204
    }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   205
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   206
    static final long LG(byte[] b, int n) {
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   207
        return ((SH(b, n)) | (SH(b, n + 2) << 16)) & 0xffffffffL;
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   208
    }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   209
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   210
    static final long LL(byte[] b, int n) {
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   211
        return (LG(b, n)) | (LG(b, n + 4) << 32);
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   212
    }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   213
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   214
    static final long GETSIG(byte[] b) {
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   215
        return LG(b, 0);
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   216
    }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   217
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   218
    // local file (LOC) header fields
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   219
    static final long LOCSIG(byte[] b) { return LG(b, 0); } // signature
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   220
    static final int  LOCVER(byte[] b) { return SH(b, 4); } // version needed to extract
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   221
    static final int  LOCFLG(byte[] b) { return SH(b, 6); } // general purpose bit flags
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   222
    static final int  LOCHOW(byte[] b) { return SH(b, 8); } // compression method
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   223
    static final long LOCTIM(byte[] b) { return LG(b, 10);} // modification time
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   224
    static final long LOCCRC(byte[] b) { return LG(b, 14);} // crc of uncompressed data
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   225
    static final long LOCSIZ(byte[] b) { return LG(b, 18);} // compressed data size
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   226
    static final long LOCLEN(byte[] b) { return LG(b, 22);} // uncompressed data size
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   227
    static final int  LOCNAM(byte[] b) { return SH(b, 26);} // filename length
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   228
    static final int  LOCEXT(byte[] b) { return SH(b, 28);} // extra field length
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   229
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   230
    // extra local (EXT) header fields
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   231
    static final long EXTCRC(byte[] b) { return LG(b, 4);}  // crc of uncompressed data
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   232
    static final long EXTSIZ(byte[] b) { return LG(b, 8);}  // compressed size
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   233
    static final long EXTLEN(byte[] b) { return LG(b, 12);} // uncompressed size
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   234
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   235
    // end of central directory header (END) fields
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   236
    static final int  ENDSUB(byte[] b) { return SH(b, 8); }  // number of entries on this disk
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   237
    static final int  ENDTOT(byte[] b) { return SH(b, 10);}  // total number of entries
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   238
    static final long ENDSIZ(byte[] b) { return LG(b, 12);}  // central directory size
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   239
    static final long ENDOFF(byte[] b) { return LG(b, 16);}  // central directory offset
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   240
    static final int  ENDCOM(byte[] b) { return SH(b, 20);}  // size of zip file comment
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   241
    static final int  ENDCOM(byte[] b, int off) { return SH(b, off + 20);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   242
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   243
    // zip64 end of central directory recoder fields
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   244
    static final long ZIP64_ENDTOD(byte[] b) { return LL(b, 24);}  // total number of entries on disk
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   245
    static final long ZIP64_ENDTOT(byte[] b) { return LL(b, 32);}  // total number of entries
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   246
    static final long ZIP64_ENDSIZ(byte[] b) { return LL(b, 40);}  // central directory size
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   247
    static final long ZIP64_ENDOFF(byte[] b) { return LL(b, 48);}  // central directory offset
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   248
    static final long ZIP64_LOCOFF(byte[] b) { return LL(b, 8);}   // zip64 end offset
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   249
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   250
    // central directory header (CEN) fields
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   251
    static final long CENSIG(byte[] b, int pos) { return LG(b, pos + 0); }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   252
    static final int  CENVEM(byte[] b, int pos) { return SH(b, pos + 4); }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   253
    static final int  CENVER(byte[] b, int pos) { return SH(b, pos + 6); }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   254
    static final int  CENFLG(byte[] b, int pos) { return SH(b, pos + 8); }
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   255
    static final int  CENHOW(byte[] b, int pos) { return SH(b, pos + 10);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   256
    static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   257
    static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   258
    static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   259
    static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   260
    static final int  CENNAM(byte[] b, int pos) { return SH(b, pos + 28);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   261
    static final int  CENEXT(byte[] b, int pos) { return SH(b, pos + 30);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   262
    static final int  CENCOM(byte[] b, int pos) { return SH(b, pos + 32);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   263
    static final int  CENDSK(byte[] b, int pos) { return SH(b, pos + 34);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   264
    static final int  CENATT(byte[] b, int pos) { return SH(b, pos + 36);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   265
    static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   266
    static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);}
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   267
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   268
    // The END header is followed by a variable length comment of size < 64k.
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   269
    static final long END_MAXLEN = 0xFFFF + ENDHDR;
29ea8310a27a 8145260: To bring j.u.z.ZipFile's native implementation to Java to remove the expensive jni cost and mmap crash risk [2]
sherman
parents: 34526
diff changeset
   270
    static final int READBLOCKSZ = 128;
45924
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   271
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   272
    /**
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   273
     * Loads zip native library, if not already laoded
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   274
     */
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   275
    static void loadLibrary() {
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   276
        SecurityManager sm = System.getSecurityManager();
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   277
        if (sm == null) {
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   278
            System.loadLibrary("zip");
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   279
        } else {
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   280
            PrivilegedAction<Void> pa = () -> { System.loadLibrary("zip"); return null; };
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   281
            AccessController.doPrivileged(pa);
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   282
        }
8bbd04c0791e 8184917: System.initPhase1 does not need to pre-load libzip
alanb
parents: 39772
diff changeset
   283
    }
17910
82d10099a8a6 4759491: method ZipEntry.setTime(long) works incorrectly
sherman
parents:
diff changeset
   284
}