History log of /libcore/ojluni/src/main/native/java_util_zip_ZipFile.c
Revision Date Author Comments
6c970474e9416807cabde3620045906ad3903c6c 01-Nov-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> java.util.zip.Zip* port from openJdk8u60

- Added missing android-changed tags for various changes.
- Fixed buggy extended DOS timestamp generation/reading
in ZipEntry and ZipUtils.

ZipEntry:
-Support for extended dos time (better timestamp resolution).
-Support for last modification, access time and creation time
stored in optional extra data.
-Because of last modification field, setTime works for ranges
outside of dos time range (< 1980 && > 2099). THIS change breaks
ZipEntryTest.test_setTimeJ. IMHO it's worth to adopt new
behavior.

ZipFile:
-Added spliterator support.
-Moved entries() iterator implementation to inner named class.
-ZipFileInputStream#read modifies pos/rem field in a
synchronized block.

ZipInputStream:
-Removed code for parsing optional extra data in .readLOC
(moved to ZipEntry).

ZipOutputStream:
-New property for inhibiting Zip64 for > 64k entries
-ZipEntry last modification, access time and creation time
support

ZipUtils.java:
-New file with common, time and byte-array related methods extracted
from ZipEntry and ZipFile

java_util_zip_ZipFile.c
-Use of ZIP_GetEntry2 with explicit addSlash param

zip_util.c/h:
-hash(const char *s) no longer used.
-New method, ZIP_GetEntry2, with explicit handling
of adding slash at the name end
-Zip entry name may include embedded null character.

Test: CtsLibcoreTestCases
Bug: 29935305
Change-Id: Ib691c81b158ec37419a903bfa4261a12139fbff7
ce27766ff2cb33432017df70f74f0732adaabd97 09-Nov-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

Test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

Bug: 30407219
Change-Id: Ic770a6ab6aca7f123a90002327d7f0a321e9afef
(cherry picked from commit 0393d3c84ed9bd24bcf0dac3782a1cc23400ace8)
36d074286912d876489c6ff21bc0c41016180dad 18-Aug-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

bug: 30407219
bug: 30904760

(cherry picked from commit 0393d3c84ed9bd24bcf0dac3782a1cc23400ace8)

(cherry picked from commit 50c5924a4a1f78b7722d97dc958317027e25e214)

Change-Id: I1d2be54e768f668616e5b53e038d80fab5aa7e18
d47251ed255544b60de615907eb83f64073dccfa 18-Aug-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

bug: 30407219
Change-Id: Ic770a6ab6aca7f123a90002327d7f0a321e9afef
50c5924a4a1f78b7722d97dc958317027e25e214 18-Aug-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

bug: 30407219

(cherry picked from commit 0393d3c84ed9bd24bcf0dac3782a1cc23400ace8)

Change-Id: Ic770a6ab6aca7f123a90002327d7f0a321e9afef
0393d3c84ed9bd24bcf0dac3782a1cc23400ace8 18-Aug-2016 Narayan Kamath <narayan@google.com> ZipFile: Never change file offset during I/O operations.

Use pread instead read and eliminate unnecessary calls to lseek.

dalvik.system.VMClassLoader maintains a cache of JarFile objects
that it creates whenever it loads resources from them. This cache may
be populated in the zygote as a side effect of preloading classes. When
processes are forked from the zygote, the file descriptors associated
with these JarFile objects point to the same kernel file description
and may end up stepping on each others toes. To avoid such issues, we
never make any offset changes to the associated file.

Note that we have a guarantee that the file will never be closed in
any forked process because the associated JarFile objects can never be
collected.

test: run cts -m CtsLibcoreTestCases / ZipStressTest / manual testing
to trigger the race condition.

bug: 30407219
Change-Id: Ic770a6ab6aca7f123a90002327d7f0a321e9afef
a128ef7c6913e8b5f2ef4678ade5f97d7f7f452f 26-May-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Fix java.util.zip.ZipFile with OPEN_DELETE.

openJdk java.util.zip.ZipFile with OPEN_DELETE flag
uses unlink to remove the file just after it's opened.

This is causing trouble on /storage partition, we
can read/write unlinked file easily, but lseek seems
to fail with ENOENT.

This change introduces alternative implementation that
doesn't use unlink before closing the file.

Bug: 28901232
Bug: 28950284
Change-Id: I871a84e9a14bc1b4b9d5b0faa207579e27bcfc81
(cherry picked from commit ae6b1b85c67401fc9d986c3ffb7d9e8a9c804c30)
ae6b1b85c67401fc9d986c3ffb7d9e8a9c804c30 26-May-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Fix java.util.zip.ZipFile with OPEN_DELETE.

openJdk java.util.zip.ZipFile with OPEN_DELETE flag
uses unlink to remove the file just after it's opened.

This is causing trouble on /storage partition, we
can read/write unlinked file easily, but lseek seems
to fail with ENOENT.

This change introduces alternative implementation that
doesn't use unlink before closing the file.

Bug: 28901232
Bug: 28950284
Change-Id: I871a84e9a14bc1b4b9d5b0faa207579e27bcfc81
de81def7a777e4423771ee15b49bedd05c7fdbf5 11-May-2016 Narayan Kamath <narayan@google.com> JarFile: Optimize getMetaInfEntryNames.

Bring back the OpenJDK implementation but make sure that it's
case sensitive in its matching.

Also update JarFile benchmark to use a different set of JarFiles
(ones that actually have resources and are signed).

AFTER:

Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/framework/core-oj.jar}}
runtime(ns): min=89200.91, 1st qu.=92035.88, median=96248.38, mean=95636.11, 3rd qu.=97204.71, max=104263.73
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/priv-app/Phonesky/Phonesky.apk}}
runtime(ns): min=32815012.40, 1st qu.=33074432.68, median=34521206.63, mean=34974008.88, 3rd qu.=36545497.61, max=39179367.36

BEFORE:
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/framework/core-oj.jar}}
runtime(ns): min=317222.97, 1st qu.=333416.42, median=339164.45, mean=344867.65, 3rd qu.=352596.11, max=392011.29
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/priv-app/Phonesky/Phonesky.apk}}
runtime(ns): min=36966924.00, 1st qu.=39058659.29, median=43041285.43, mean=42476010.68, 3rd qu.=45566839.83, max=46848927.18

This isn't a perfect benchmark, because a lot of time is spent constructing the JarFile each time.
However, we've shaved times by a third for files with a "reasonable"
number of entries.

bug: 28713954

(cherry picked from commit ff96d13467fa65856c19aaf06b151ce60e0edd8f)

Change-Id: I7d26fe9ce17af0f3ed9f8a5aab21dca9c76febb8
ff96d13467fa65856c19aaf06b151ce60e0edd8f 11-May-2016 Narayan Kamath <narayan@google.com> JarFile: Optimize getMetaInfEntryNames.

Bring back the OpenJDK implementation but make sure that it's
case sensitive in its matching.

Also update JarFile benchmark to use a different set of JarFiles
(ones that actually have resources and are signed).

AFTER:

Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/framework/core-oj.jar}}
runtime(ns): min=89200.91, 1st qu.=92035.88, median=96248.38, mean=95636.11, 3rd qu.=97204.71, max=104263.73
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/priv-app/Phonesky/Phonesky.apk}}
runtime(ns): min=32815012.40, 1st qu.=33074432.68, median=34521206.63, mean=34974008.88, 3rd qu.=36545497.61, max=39179367.36

BEFORE:
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/framework/core-oj.jar}}
runtime(ns): min=317222.97, 1st qu.=333416.42, median=339164.45, mean=344867.65, 3rd qu.=352596.11, max=392011.29
Experiment {instrument=runtime, benchmarkMethod=time, vm=default, parameters={filename=/system/priv-app/Phonesky/Phonesky.apk}}
runtime(ns): min=36966924.00, 1st qu.=39058659.29, median=43041285.43, mean=42476010.68, 3rd qu.=45566839.83, max=46848927.18

This isn't a perfect benchmark, because a lot of time is spent constructing the JarFile each time.
However, we've shaved times by a third for files with a "reasonable"
number of entries.

bug: 28713954

Change-Id: Ic0de000be683dc8009818930658ae4a443d81559
d66fb8e8bb26b1d294a7c42d740acaf427a3a0a3 03-May-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Move clinit code to registration funtions

Moved clinit code that fetches field/method ids
to JNI registration funcitons. This will allow to
compile-time initialize these classes.

More classes will follow.

Bug: 28153851
Change-Id: I5918e281a65a2ca2168dfe1bdd18cc3c5df8f2f6
(cherry picked from commit 2798490baa8ee586e38bdd09707f4fb18ef0d023)
2798490baa8ee586e38bdd09707f4fb18ef0d023 03-May-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Move clinit code to registration funtions

Moved clinit code that fetches field/method ids
to JNI registration funcitons. This will allow to
compile-time initialize these classes.

More classes will follow.

Bug: 28153851
Change-Id: I5918e281a65a2ca2168dfe1bdd18cc3c5df8f2f6
6786911a58e65bad88d08a0d1f8d32ab067edaa9 02-Mar-2016 George Burgess IV <gbiv@google.com> Cleanup uses of sprintf so we can deprecate it.

Change-Id: I54cb8b609e4d465a6a1e5b9d85fc85b7ef7efeae
a8ed084745590c5e4a0e8559b5821809d60fe242 21-Apr-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.util.zip.*

- Move some of the internal implementation details of libcore's
zipfile into StrictJarFile.
- TODO: Adler32 continues to use old native code from libcore, this
must be switched over.
- InflaterInputStream: |closed| becomes protected.
- ZipFile : Always use mmap.
- ZipEntry : Add a long dataOffset.
- Switch all native code over to explicit registration.

Change-Id: Id5519b4548ea1eb22fd182edfbd2c804dc6f3bb5
51b1b6997fd3f980076b8081f7f1165ccc2a4008 16-Feb-2015 Piotr Jastrzebski <haaawk@google.com> Initial import of OpenJdk files.

Create new libcore/ojluni directory with src/main/java and
src/main/native subdirectiories.

Build ojluni into core-oj jar.

Use openjdk classes from java.awt.font package.

Copy all files from jdk/src/share/classes and jdk/src/solaris/classes
directories in openjdk into libcore/ojluni/src/main/java.

Copy following native files from openjdk to
libcore/ojluni/src/main/native:
jdk/src/solaris/native/java/io/canonicalize_md.c
build/linux-amd64/include/classfile_constants.h
jdk/src/share/native/java/net/DatagramPacket.c
jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c
jdk/src/share/native/java/lang/Double.c
jdk/src/share/native/java/lang/fdlibm/include/fdlibm.h
jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c
jdk/src/solaris/native/java/io/FileDescriptor_md.c
jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
jdk/src/share/native/java/io/FileInputStream.c
jdk/src/solaris/native/sun/nio/ch/FileKey.c
jdk/src/solaris/native/java/io/FileOutputStream_md.c
jdk/src/solaris/native/java/io/FileSystem_md.c
jdk/src/share/native/java/lang/Float.c
jdk/src/share/native/java/net/Inet4Address.c
jdk/src/solaris/native/java/net/Inet4AddressImpl.c
jdk/src/share/native/java/net/Inet6Address.c
jdk/src/solaris/native/java/net/Inet6AddressImpl.c
jdk/src/share/native/java/net/InetAddress.c
jdk/src/solaris/native/java/net/InetAddressImplFactory.c
jdk/src/share/native/java/io/io_util.c
jdk/src/solaris/native/sun/nio/ch/IOUtil.c
jdk/src/share/native/java/io/io_util.h
jdk/src/solaris/native/java/io/io_util_md.c
jdk/src/solaris/native/java/io/io_util_md.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/java_io_FileDescriptor.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileInputStream.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileOutputStream.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileSystem.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_ObjectStreamClass.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_UnixFileSystem.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Double.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Float.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Integer.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Long.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Runtime.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Shutdown.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_StrictMath.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_String.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_System.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Thread.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Throwable.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_DatagramPacket.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet4Address.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet4AddressImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet6Address.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet6AddressImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_InetAddress.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_InetAddressImplFactory.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_NetworkInterface.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_PlainDatagramSocketImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_PlainSocketImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketInputStream.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketOptions.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketOutputStream.h
jdk/src/share/native/java/lang/java_props.h
jdk/src/solaris/native/java/lang/java_props_md.c
jdk/src/share/native/java/util/zip/Adler32.c as java_util_zip_Adler32.c
jdk/src/share/native/java/util/zip/CRC32.c as java_util_zip_CRC32.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_CRC32.h
jdk/src/share/native/java/util/zip/Deflater.c as java_util_zip_Deflater.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_Deflater.h
jdk/src/share/native/java/util/zip/Inflater.c as java_util_zip_Inflater.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_Inflater.h
jdk/src/share/native/java/util/zip/ZipFile.c as java_util_zip_ZipFile.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_ZipFile.h
jdk/src/share/native/java/lang/fdlibm/include/jfdlibm.h
jdk/src/share/native/common/jlong.h
jdk/src/solaris/native/common/jlong_md.h
jdk/src/share/native/common/jni_util.c
jdk/src/share/native/common/jni_util.h
jdk/src/solaris/native/common/jni_util_md.c
jdk/src/share/javavm/export/jvm.h
jdk/src/solaris/javavm/export/jvm_md.h
jdk/src/solaris/native/java/net/linux_close.c
jdk/src/share/native/sun/misc/NativeSignalHandler.c
jdk/src/solaris/native/sun/nio/ch/NativeThread.c
jdk/src/share/native/java/net/net_util.c
jdk/src/share/native/java/net/net_util.h
jdk/src/solaris/native/java/net/net_util_md.c
jdk/src/solaris/native/java/net/net_util_md.h
jdk/src/solaris/native/java/net/NetworkInterface.c
jdk/src/share/native/sun/nio/ch/nio.h
jdk/src/solaris/native/sun/nio/ch/nio_util.h
jdk/src/share/native/java/io/ObjectStreamClass.c
jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
jdk/src/solaris/native/java/net/PlainSocketImpl.c
jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c
jdk/src/share/native/java/lang/Runtime.c
jdk/src/share/native/java/lang/Shutdown.c
jdk/src/share/native/sun/misc/Signal.c
jdk/src/solaris/native/java/net/SocketInputStream.c
jdk/src/solaris/native/java/net/SocketOutputStream.c
jdk/src/share/native/java/lang/StrictMath.c
jdk/src/share/native/java/lang/String.c
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/sun_misc_NativeSignalHandler.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/sun_misc_Signal.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/sun_net_spi_DefaultProxySelector.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileChannelImpl.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileDispatcherImpl.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileKey.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_IOStatus.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_IOUtil.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_NativeThread.h
jdk/src/share/native/java/lang/System.c
jdk/src/share/native/java/lang/Thread.c
jdk/src/share/native/java/lang/Throwable.c
jdk/src/solaris/native/java/io/UnixFileSystem_md.c
jdk/src/solaris/native/java/lang/UNIXProcess_md.c
jdk/src/share/native/java/util/zip/zip_util.c
jdk/src/share/native/java/util/zip/zip_util.h

Change-Id: Ib237df4e1b7b5b4d9f12e74d189e6ec9eed3c31d