summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorJerome Dochez <jedo@google.com>2017-01-24 14:39:37 -0800
committerJerome Dochez <jedo@google.com>2017-01-24 14:39:37 -0800
commitc8e3f66e8239b4d026b5ff37fc30c1884864af45 (patch)
treebfb83af33b4a8d547c646045fbc6af3641547c04 /src/main/java
parent303c8ab014df5769504ad0352ee10b6d7da7c328 (diff)
downloadapkzlib-c8e3f66e8239b4d026b5ff37fc30c1884864af45.tar.gz
Workaround for not handling Zip64.
In the PackageAndroidArtifact, when receiving a Zip64 not handled exception, we will copy the zip64 file into a new one stripping all the .class files. This should hopefully generate a much smaller Zip file that's below the 64K limit. Bug : b.android.com/232803 Test: added unit tests. Change-Id: I536568dd86a4015a8dbc2fdfd8c896c2c4831543
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/android/apkzlib/zip/ZFile.java7
-rw-r--r--src/main/java/com/android/apkzlib/zip/compress/Zip64NotSupportedException.java27
2 files changed, 32 insertions, 2 deletions
diff --git a/src/main/java/com/android/apkzlib/zip/ZFile.java b/src/main/java/com/android/apkzlib/zip/ZFile.java
index 69eee12..bf16b59 100644
--- a/src/main/java/com/android/apkzlib/zip/ZFile.java
+++ b/src/main/java/com/android/apkzlib/zip/ZFile.java
@@ -19,6 +19,7 @@ package com.android.apkzlib.zip;
import com.android.apkzlib.utils.CachedFileContents;
import com.android.apkzlib.utils.IOExceptionFunction;
import com.android.apkzlib.utils.IOExceptionRunnable;
+import com.android.apkzlib.zip.compress.Zip64NotSupportedException;
import com.android.apkzlib.zip.utils.ByteTracker;
import com.android.apkzlib.zip.utils.CloseableByteSource;
import com.android.apkzlib.zip.utils.LittleEndianUtils;
@@ -452,6 +453,8 @@ public class ZFile implements Closeable {
notify(ZFileExtension::open);
}
+ } catch (Zip64NotSupportedException e) {
+ throw e;
} catch (IOException e) {
throw new IOException("Failed to read zip file '" + file.getAbsolutePath() + "'.", e);
}
@@ -678,8 +681,8 @@ public class ZFile implements Closeable {
directFullyRead(zip64LocatorStart, possibleZip64Locator);
if (LittleEndianUtils.readUnsigned4Le(ByteBuffer.wrap(possibleZip64Locator)) ==
ZIP64_EOCD_LOCATOR_SIGNATURE) {
- throw new IOException("Zip64 EOCD locator found but Zip64 format is not "
- + "supported.");
+ throw new Zip64NotSupportedException(
+ "Zip64 EOCD locator found but Zip64 format is not supported.");
}
}
diff --git a/src/main/java/com/android/apkzlib/zip/compress/Zip64NotSupportedException.java b/src/main/java/com/android/apkzlib/zip/compress/Zip64NotSupportedException.java
new file mode 100644
index 0000000..3b7411e
--- /dev/null
+++ b/src/main/java/com/android/apkzlib/zip/compress/Zip64NotSupportedException.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.apkzlib.zip.compress;
+
+import java.io.IOException;
+
+/** Exception raised by ZFile when encountering unsupported Zip64 format jar files. */
+public class Zip64NotSupportedException extends IOException {
+
+ public Zip64NotSupportedException(String message) {
+ super(message);
+ }
+}