summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPierre Lecesne <lecesne@google.com>2016-11-16 18:21:16 +0000
committerPierre Lecesne <lecesne@google.com>2016-11-20 19:59:25 +0000
commit735d241f799c336887ee80fc6d0019331aa622c6 (patch)
tree4463ff257ae475a4d44c84ff213234b742888563 /src
parentbd8b3ed9d3882a9ba70e1dddc8ff3e1e13dec761 (diff)
downloadapkzlib-735d241f799c336887ee80fc6d0019331aa622c6.tar.gz
Replacing com.android.annotations.* with JSR305 annotations.
Test: Ran bazel build Change-Id: Iea73e46d3fd090bead2978f4960722cff59bcaaf
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/android/apkzlib/sign/DigestAlgorithm.java14
-rw-r--r--src/main/java/com/android/apkzlib/sign/FullApkSignExtension.java23
-rw-r--r--src/main/java/com/android/apkzlib/sign/ManifestGenerationExtension.java35
-rw-r--r--src/main/java/com/android/apkzlib/sign/SignatureAlgorithm.java17
-rw-r--r--src/main/java/com/android/apkzlib/sign/SignatureExtension.java36
-rw-r--r--src/main/java/com/android/apkzlib/sign/v2/ApkSignerV2.java26
-rw-r--r--src/main/java/com/android/apkzlib/sign/v2/ByteArrayDigestSource.java9
-rw-r--r--src/main/java/com/android/apkzlib/sign/v2/DigestSource.java5
-rw-r--r--src/main/java/com/android/apkzlib/sign/v2/ZFileDigestSource.java11
-rw-r--r--src/main/java/com/android/apkzlib/utils/CachedFileContents.java11
-rw-r--r--src/main/java/com/android/apkzlib/utils/CachedSupplier.java7
-rw-r--r--src/main/java/com/android/apkzlib/utils/IOExceptionConsumer.java8
-rw-r--r--src/main/java/com/android/apkzlib/utils/IOExceptionFunction.java9
-rw-r--r--src/main/java/com/android/apkzlib/utils/IOExceptionRunnable.java6
-rw-r--r--src/main/java/com/android/apkzlib/utils/IOExceptionWrapper.java7
-rw-r--r--src/main/java/com/android/apkzlib/zfile/ApkCreator.java11
-rw-r--r--src/main/java/com/android/apkzlib/zfile/ApkCreatorFactory.java25
-rw-r--r--src/main/java/com/android/apkzlib/zfile/ApkZFileCreator.java18
-rw-r--r--src/main/java/com/android/apkzlib/zfile/ApkZFileCreatorFactory.java10
-rw-r--r--src/main/java/com/android/apkzlib/zfile/ZFiles.java15
-rw-r--r--src/main/java/com/android/apkzlib/zip/AlignmentRule.java4
-rw-r--r--src/main/java/com/android/apkzlib/zip/AlignmentRules.java6
-rw-r--r--src/main/java/com/android/apkzlib/zip/CentralDirectory.java21
-rw-r--r--src/main/java/com/android/apkzlib/zip/CentralDirectoryHeader.java41
-rw-r--r--src/main/java/com/android/apkzlib/zip/CentralDirectoryHeaderCompressInfo.java12
-rw-r--r--src/main/java/com/android/apkzlib/zip/CompressionMethod.java2
-rw-r--r--src/main/java/com/android/apkzlib/zip/CompressionResult.java12
-rw-r--r--src/main/java/com/android/apkzlib/zip/Compressor.java6
-rw-r--r--src/main/java/com/android/apkzlib/zip/EncodeUtils.java19
-rw-r--r--src/main/java/com/android/apkzlib/zip/Eocd.java13
-rw-r--r--src/main/java/com/android/apkzlib/zip/ExtraField.java30
-rw-r--r--src/main/java/com/android/apkzlib/zip/FileUseMap.java36
-rw-r--r--src/main/java/com/android/apkzlib/zip/FileUseMapEntry.java7
-rw-r--r--src/main/java/com/android/apkzlib/zip/GPFlags.java7
-rw-r--r--src/main/java/com/android/apkzlib/zip/InflaterByteSource.java7
-rw-r--r--src/main/java/com/android/apkzlib/zip/LazyDelegateByteSource.java19
-rw-r--r--src/main/java/com/android/apkzlib/zip/ProcessedAndRawByteSources.java15
-rw-r--r--src/main/java/com/android/apkzlib/zip/StoredEntry.java49
-rw-r--r--src/main/java/com/android/apkzlib/zip/ZFile.java108
-rw-r--r--src/main/java/com/android/apkzlib/zip/ZFileExtension.java9
-rw-r--r--src/main/java/com/android/apkzlib/zip/ZFileOptions.java18
-rw-r--r--src/main/java/com/android/apkzlib/zip/ZipField.java33
-rw-r--r--src/main/java/com/android/apkzlib/zip/compress/BestAndDefaultDeflateExecutorCompressor.java15
-rw-r--r--src/main/java/com/android/apkzlib/zip/compress/DeflateExecutionCompressor.java11
-rw-r--r--src/main/java/com/android/apkzlib/zip/compress/ExecutorCompressor.java15
-rw-r--r--src/main/java/com/android/apkzlib/zip/utils/ByteTracker.java9
-rw-r--r--src/main/java/com/android/apkzlib/zip/utils/CloseableDelegateByteSource.java17
-rw-r--r--src/main/java/com/android/apkzlib/zip/utils/LittleEndianUtils.java11
-rw-r--r--src/main/java/com/android/apkzlib/zip/utils/RandomAccessFileUtils.java5
-rw-r--r--src/test/java/com/android/apkzlib/sign/SignatureTestUtils.java12
-rw-r--r--src/test/java/com/android/apkzlib/utils/ApkZFileTestUtils.java14
-rw-r--r--src/test/java/com/android/apkzlib/zip/ZFileNotificationTest.java18
-rw-r--r--src/test/java/com/android/apkzlib/zip/ZFileSortTest.java2
-rw-r--r--src/test/java/com/android/apkzlib/zip/ZFileTest.java14
-rw-r--r--src/test/java/com/android/apkzlib/zip/ZipTestUtils.java14
-rw-r--r--src/test/java/com/android/apkzlib/zip/ZipToolsTest.java8
56 files changed, 452 insertions, 490 deletions
diff --git a/src/main/java/com/android/apkzlib/sign/DigestAlgorithm.java b/src/main/java/com/android/apkzlib/sign/DigestAlgorithm.java
index cf484b2..6833d2f 100644
--- a/src/main/java/com/android/apkzlib/sign/DigestAlgorithm.java
+++ b/src/main/java/com/android/apkzlib/sign/DigestAlgorithm.java
@@ -16,7 +16,7 @@
package com.android.apkzlib.sign;
-import com.android.annotations.NonNull;
+import javax.annotation.Nonnull;
/**
* Message digest algorithms.
@@ -54,19 +54,19 @@ public enum DigestAlgorithm {
/**
* Name of algorithm for message digest.
*/
- @NonNull
+ @Nonnull
public final String messageDigestName;
/**
* Name of attribute in signature file with the manifest digest.
*/
- @NonNull
+ @Nonnull
public final String manifestAttributeName;
/**
* Name of attribute in entry (both manifest and signature file) with the entry's digest.
*/
- @NonNull
+ @Nonnull
public final String entryAttributeName;
/**
@@ -75,7 +75,7 @@ public enum DigestAlgorithm {
* @param attributeName attribute name in the signature file
* @param messageDigestName name of algorithm for message digest
*/
- DigestAlgorithm(@NonNull String attributeName, @NonNull String messageDigestName) {
+ DigestAlgorithm(@Nonnull String attributeName, @Nonnull String messageDigestName) {
this.messageDigestName = messageDigestName;
this.entryAttributeName = attributeName + "-Digest";
this.manifestAttributeName = attributeName + "-Digest-Manifest";
@@ -88,10 +88,10 @@ public enum DigestAlgorithm {
* @param signatureAlgorithm signature algorithm used
* @return the best algorithm found
*/
- @NonNull
+ @Nonnull
public static DigestAlgorithm findBest(
int minSdk,
- @NonNull SignatureAlgorithm signatureAlgorithm) {
+ @Nonnull SignatureAlgorithm signatureAlgorithm) {
if (signatureAlgorithm == SignatureAlgorithm.RSA) {
// PKCS #7 RSA signatures with SHA-256 are
// supported only since API Level 18 (JB MR2).
diff --git a/src/main/java/com/android/apkzlib/sign/FullApkSignExtension.java b/src/main/java/com/android/apkzlib/sign/FullApkSignExtension.java
index c1b56a1..ef5f547 100644
--- a/src/main/java/com/android/apkzlib/sign/FullApkSignExtension.java
+++ b/src/main/java/com/android/apkzlib/sign/FullApkSignExtension.java
@@ -16,8 +16,6 @@
package com.android.apkzlib.sign;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.sign.v2.ApkSignerV2;
import com.android.apkzlib.sign.v2.ByteArrayDigestSource;
import com.android.apkzlib.sign.v2.DigestSource;
@@ -29,13 +27,14 @@ import com.android.apkzlib.zip.ZFileExtension;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
-
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.PrivateKey;
import java.security.SignatureException;
import java.security.cert.X509Certificate;
import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Extension that adds full APK signing. This extension will:
@@ -59,19 +58,19 @@ public class FullApkSignExtension {
/**
* The zip file this extension is registered with.
*/
- @NonNull
+ @Nonnull
private final ZFile mFile;
/**
* Signer certificate.
*/
- @NonNull
+ @Nonnull
private final X509Certificate mCertificate;
/**
* Signer private key.
*/
- @NonNull
+ @Nonnull
private final PrivateKey mPrivateKey;
/**
@@ -101,10 +100,10 @@ public class FullApkSignExtension {
*
* @throws InvalidKeyException if the signing key is not suitable for signing this APK.
*/
- public FullApkSignExtension(@NonNull ZFile file,
+ public FullApkSignExtension(@Nonnull ZFile file,
int minSdkVersion,
- @NonNull X509Certificate certificate,
- @NonNull PrivateKey privateKey) throws InvalidKeyException {
+ @Nonnull X509Certificate certificate,
+ @Nonnull PrivateKey privateKey) throws InvalidKeyException {
mFile = file;
mCertificate = certificate;
mPrivateKey = privateKey;
@@ -129,7 +128,7 @@ public class FullApkSignExtension {
@Nullable
@Override
- public IOExceptionRunnable added(@NonNull StoredEntry entry,
+ public IOExceptionRunnable added(@Nonnull StoredEntry entry,
@Nullable StoredEntry replaced) {
onZipChanged();
return null;
@@ -137,7 +136,7 @@ public class FullApkSignExtension {
@Nullable
@Override
- public IOExceptionRunnable removed(@NonNull StoredEntry entry) {
+ public IOExceptionRunnable removed(@Nonnull StoredEntry entry) {
onZipChanged();
return null;
}
@@ -183,7 +182,7 @@ public class FullApkSignExtension {
* @return the signature data block
* @throws IOException failed to generate a signature
*/
- @NonNull
+ @Nonnull
private byte[] generateApkSigningBlock() throws IOException {
byte[] centralDirectoryData = mFile.getCentralDirectoryBytes();
byte[] eocdData = mFile.getEocdBytes();
diff --git a/src/main/java/com/android/apkzlib/sign/ManifestGenerationExtension.java b/src/main/java/com/android/apkzlib/sign/ManifestGenerationExtension.java
index 3afd00a..02e8f06 100644
--- a/src/main/java/com/android/apkzlib/sign/ManifestGenerationExtension.java
+++ b/src/main/java/com/android/apkzlib/sign/ManifestGenerationExtension.java
@@ -16,18 +16,15 @@
package com.android.apkzlib.sign;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.utils.CachedSupplier;
import com.android.apkzlib.utils.IOExceptionRunnable;
+import com.android.apkzlib.zfile.ManifestAttributes;
import com.android.apkzlib.zip.StoredEntry;
import com.android.apkzlib.zip.ZFile;
import com.android.apkzlib.zip.ZFileExtension;
-import com.android.apkzlib.zfile.ManifestAttributes;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.Maps;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -35,6 +32,8 @@ import java.io.UncheckedIOException;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Extension to {@link ZFile} that will generate a manifest. The extension will register
@@ -67,13 +66,13 @@ public class ManifestGenerationExtension {
/**
* Who should be reported as the manifest builder.
*/
- @NonNull
+ @Nonnull
private final String mBuiltBy;
/**
* Who should be reported as the manifest creator.
*/
- @NonNull
+ @Nonnull
private final String mCreatedBy;
/**
@@ -85,7 +84,7 @@ public class ManifestGenerationExtension {
/**
* The zip file's manifest.
*/
- @NonNull
+ @Nonnull
private final Manifest mManifest;
/**
@@ -101,7 +100,7 @@ public class ManifestGenerationExtension {
* and will cache it. All further requests of the manifest's byte representation will
* receive the same byte array.
*/
- @NonNull
+ @Nonnull
private CachedSupplier<byte[]> mManifestBytes;
/**
@@ -126,7 +125,7 @@ public class ManifestGenerationExtension {
* @param builtBy who built the manifest?
* @param createdBy who created the manifest?
*/
- public ManifestGenerationExtension(@NonNull String builtBy, @NonNull String createdBy) {
+ public ManifestGenerationExtension(@Nonnull String builtBy, @Nonnull String createdBy) {
mBuiltBy = builtBy;
mCreatedBy = createdBy;
mManifest = new Manifest();
@@ -158,7 +157,7 @@ public class ManifestGenerationExtension {
* @param zFile the zip file to add the extension to
* @throws IOException failed to analyze the zip
*/
- public void register(@NonNull ZFile zFile) throws IOException {
+ public void register(@Nonnull ZFile zFile) throws IOException {
Preconditions.checkState(mExtension == null, "register() has already been invoked.");
mZFile = zFile;
@@ -220,7 +219,7 @@ public class ManifestGenerationExtension {
* @param attribute the attribute
* @param value the value
*/
- private void setMainAttribute(@NonNull String attribute, @NonNull String value) {
+ private void setMainAttribute(@Nonnull String attribute, @Nonnull String value) {
Attributes mainAttributes = mManifest.getMainAttributes();
String current = mainAttributes.getValue(attribute);
if (!value.equals(current)) {
@@ -251,7 +250,7 @@ public class ManifestGenerationExtension {
*
* @return the {@link ZFile}
*/
- @NonNull
+ @Nonnull
public ZFile zFile() {
Preconditions.checkNotNull(mZFile, "mZFile == null");
return mZFile;
@@ -278,7 +277,7 @@ public class ManifestGenerationExtension {
* if it doesn't have the specified attribute
*/
@Nullable
- public String getAttribute(@NonNull String entryName, @NonNull String attr) {
+ public String getAttribute(@Nonnull String entryName, @Nonnull String attr) {
Attributes attrs = mManifest.getAttributes(entryName);
if (attrs == null) {
return null;
@@ -295,8 +294,8 @@ public class ManifestGenerationExtension {
* @param attr the name of the attribute
* @param value the attribute value
*/
- public void setAttribute(@NonNull String entryName, @NonNull String attr,
- @NonNull String value) {
+ public void setAttribute(@Nonnull String entryName, @Nonnull String attr,
+ @Nonnull String value) {
Attributes attrs = mManifest.getAttributes(entryName);
if (attrs == null) {
attrs = new Attributes();
@@ -318,7 +317,7 @@ public class ManifestGenerationExtension {
* the manifest is not modified
* @throws IOException failed to compute the manifest's byte representation
*/
- @NonNull
+ @Nonnull
public byte[] getManifestBytes() throws IOException {
return mManifestBytes.get();
}
@@ -328,7 +327,7 @@ public class ManifestGenerationExtension {
*
* @return a map that relates entry names to entry attributes
*/
- @NonNull
+ @Nonnull
public Map<String, Attributes> allEntries() {
return Maps.newHashMap(mManifest.getEntries());
}
@@ -339,7 +338,7 @@ public class ManifestGenerationExtension {
*
* @param name the entry's name
*/
- public void removeEntry(@NonNull String name) {
+ public void removeEntry(@Nonnull String name) {
if (mManifest.getEntries().remove(name) != null) {
markDirty();
}
diff --git a/src/main/java/com/android/apkzlib/sign/SignatureAlgorithm.java b/src/main/java/com/android/apkzlib/sign/SignatureAlgorithm.java
index aaeefb5..4166767 100644
--- a/src/main/java/com/android/apkzlib/sign/SignatureAlgorithm.java
+++ b/src/main/java/com/android/apkzlib/sign/SignatureAlgorithm.java
@@ -16,9 +16,8 @@
package com.android.apkzlib.sign;
-import com.android.annotations.NonNull;
-
import java.security.NoSuchAlgorithmException;
+import javax.annotation.Nonnull;
/**
* Signature algorithm.
@@ -42,7 +41,7 @@ public enum SignatureAlgorithm {
/**
* Name of the private key as reported by {@code PrivateKey}.
*/
- @NonNull
+ @Nonnull
public final String keyAlgorithm;
/**
@@ -53,7 +52,7 @@ public enum SignatureAlgorithm {
/**
* Suffix appended to digest algorithm to obtain signature algorithm.
*/
- @NonNull
+ @Nonnull
public final String signatureAlgorithmSuffix;
/**
@@ -64,7 +63,7 @@ public enum SignatureAlgorithm {
* @param signatureAlgorithmSuffix suffix for signature name with used with a digest
*/
SignatureAlgorithm(
- @NonNull String keyAlgorithm, int minSdkVersion, @NonNull String signatureAlgorithmSuffix) {
+ @Nonnull String keyAlgorithm, int minSdkVersion, @Nonnull String signatureAlgorithmSuffix) {
this.keyAlgorithm = keyAlgorithm;
this.minSdkVersion = minSdkVersion;
this.signatureAlgorithmSuffix = signatureAlgorithmSuffix;
@@ -80,8 +79,8 @@ public enum SignatureAlgorithm {
* @throws NoSuchAlgorithmException if no algorithm was found for the given private key; an
* algorithm was found but is not applicable to the given SDK version
*/
- @NonNull
- public static SignatureAlgorithm fromKeyAlgorithm(@NonNull String keyAlgorithm,
+ @Nonnull
+ public static SignatureAlgorithm fromKeyAlgorithm(@Nonnull String keyAlgorithm,
int minSdkVersion) throws NoSuchAlgorithmException {
for (SignatureAlgorithm alg : values()) {
if (alg.keyAlgorithm.equalsIgnoreCase(keyAlgorithm)) {
@@ -106,8 +105,8 @@ public enum SignatureAlgorithm {
* @param digestAlgorithm the digest algorithm to use
* @return the name of the signature algorithm
*/
- @NonNull
- public String signatureAlgorithmName(@NonNull DigestAlgorithm digestAlgorithm) {
+ @Nonnull
+ public String signatureAlgorithmName(@Nonnull DigestAlgorithm digestAlgorithm) {
return digestAlgorithm.messageDigestName.replace("-", "") + signatureAlgorithmSuffix;
}
}
diff --git a/src/main/java/com/android/apkzlib/sign/SignatureExtension.java b/src/main/java/com/android/apkzlib/sign/SignatureExtension.java
index 9f2196f..49049b6 100644
--- a/src/main/java/com/android/apkzlib/sign/SignatureExtension.java
+++ b/src/main/java/com/android/apkzlib/sign/SignatureExtension.java
@@ -16,8 +16,6 @@
package com.android.apkzlib.sign;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.utils.IOExceptionRunnable;
import com.android.apkzlib.zip.StoredEntry;
import com.android.apkzlib.zip.ZFile;
@@ -40,6 +38,8 @@ import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.DEROutputStream;
import org.bouncycastle.cert.jcajce.JcaCertStore;
@@ -186,20 +186,20 @@ public class SignatureExtension {
/**
* Extension maintaining the manifest.
*/
- @NonNull
+ @Nonnull
private final ManifestGenerationExtension mManifestExtension;
/**
* Message digest to use.
*/
- @NonNull
+ @Nonnull
private final MessageDigest mMessageDigest;
/**
* Signature file. Note that the signature file is itself a manifest file but it is
* a different one from the "standard" MANIFEST.MF.
*/
- @NonNull
+ @Nonnull
private final Manifest mSignatureFile;
/**
@@ -210,25 +210,25 @@ public class SignatureExtension {
/**
* Signer certificate.
*/
- @NonNull
+ @Nonnull
private final X509Certificate mCertificate;
/**
* The private key used to sign the jar.
*/
- @NonNull
+ @Nonnull
private final PrivateKey mPrivateKey;
/**
* Algorithm with which .SF file is signed.
*/
- @NonNull
+ @Nonnull
private final SignatureAlgorithm mSignatureAlgorithm;
/**
* Digest algorithm to use for MANIFEST.MF and contents of APK entries.
*/
- @NonNull
+ @Nonnull
private final DigestAlgorithm mDigestAlgorithm;
/**
@@ -256,8 +256,8 @@ public class SignatureExtension {
*
* @throws NoSuchAlgorithmException failed to obtain the digest algorithm.
*/
- public SignatureExtension(@NonNull ManifestGenerationExtension manifestExtension,
- int minSdkVersion, @NonNull X509Certificate certificate, @NonNull PrivateKey privateKey,
+ public SignatureExtension(@Nonnull ManifestGenerationExtension manifestExtension,
+ int minSdkVersion, @Nonnull X509Certificate certificate, @Nonnull PrivateKey privateKey,
@Nullable String apkSignedHeaderValue)
throws NoSuchAlgorithmException {
mManifestExtension = manifestExtension;
@@ -292,7 +292,7 @@ public class SignatureExtension {
@Nullable
@Override
- public IOExceptionRunnable added(@NonNull final StoredEntry entry,
+ public IOExceptionRunnable added(@Nonnull final StoredEntry entry,
@Nullable final StoredEntry replaced) {
if (replaced != null) {
Preconditions.checkArgument(entry.getCentralDirectoryHeader().getName().equals(
@@ -314,7 +314,7 @@ public class SignatureExtension {
@Nullable
@Override
- public IOExceptionRunnable removed(@NonNull final StoredEntry entry) {
+ public IOExceptionRunnable removed(@Nonnull final StoredEntry entry) {
if (isIgnoredFile(entry.getCentralDirectoryHeader().getName())) {
return null;
}
@@ -480,7 +480,7 @@ public class SignatureExtension {
* @throws IOException failed to add the entry to the signature file (or failed to compute the
* entry's signature)
*/
- private void added(@NonNull StoredEntry entry) throws IOException {
+ private void added(@Nonnull StoredEntry entry) throws IOException {
setDigestForEntry(entry);
}
@@ -491,7 +491,7 @@ public class SignatureExtension {
* @param entry the entry
* @throws IOException failed to compute the entry's digest
*/
- private void setDigestForEntry(@NonNull StoredEntry entry) throws IOException {
+ private void setDigestForEntry(@Nonnull StoredEntry entry) throws IOException {
String entryName = entry.getCentralDirectoryHeader().getName();
byte[] entryDigestArray = mMessageDigest.digest(entry.read());
String entryDigest = Base64.getEncoder().encodeToString(entryDigestArray);
@@ -522,7 +522,7 @@ public class SignatureExtension {
*
* @param entry the entry removed
*/
- private void removed(@NonNull StoredEntry entry) {
+ private void removed(@Nonnull StoredEntry entry) {
mSignatureFile.getEntries().remove(entry.getCentralDirectoryHeader().getName());
mManifestExtension.removeEntry(entry.getCentralDirectoryHeader().getName());
mDirty = true;
@@ -534,7 +534,7 @@ public class SignatureExtension {
* @param name the file name
* @return should it be ignored
*/
- public static boolean isIgnoredFile(@NonNull String name) {
+ public static boolean isIgnoredFile(@Nonnull String name) {
String metaInfPfx = ManifestGenerationExtension.META_INF_DIR + "/";
boolean inMetaInf = name.startsWith(metaInfPfx)
&& !name.substring(metaInfPfx.length()).contains("/");
@@ -581,7 +581,7 @@ public class SignatureExtension {
* @throws OperatorCreationException failed to sign the data
* @throws CMSException failed to sign the data
*/
- private byte[] computePkcs7Signature(@NonNull byte[] data) throws IOException,
+ private byte[] computePkcs7Signature(@Nonnull byte[] data) throws IOException,
CertificateEncodingException, OperatorCreationException, CMSException {
CMSProcessableByteArray cmsData = new CMSProcessableByteArray(data);
diff --git a/src/main/java/com/android/apkzlib/sign/v2/ApkSignerV2.java b/src/main/java/com/android/apkzlib/sign/v2/ApkSignerV2.java
index 659cca4..71cf026 100644
--- a/src/main/java/com/android/apkzlib/sign/v2/ApkSignerV2.java
+++ b/src/main/java/com/android/apkzlib/sign/v2/ApkSignerV2.java
@@ -16,7 +16,6 @@
package com.android.apkzlib.sign.v2;
-import com.android.annotations.NonNull;
import com.android.apkzlib.utils.ApkZLibPair;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -45,6 +44,7 @@ import java.security.spec.X509EncodedKeySpec;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.annotation.Nonnull;
/**
* APK Signature Scheme v2 signer.
@@ -91,21 +91,21 @@ public abstract class ApkSignerV2 {
/**
* Private key.
*/
- @NonNull
+ @Nonnull
public PrivateKey privateKey;
/**
* Certificates, with the first certificate containing the public key corresponding to
* {@link #privateKey}.
*/
- @NonNull
+ @Nonnull
public List<X509Certificate> certificates;
/**
* List of signature algorithms with which to sign. At least one algorithm must be
* provided.
*/
- @NonNull
+ @Nonnull
public List<SignatureAlgorithm> signatureAlgorithms;
}
@@ -120,7 +120,7 @@ public abstract class ApkSignerV2 {
* APK Signature Scheme v2
*/
public static List<SignatureAlgorithm> getSuggestedSignatureAlgorithms(
- @NonNull PublicKey signingKey, int minSdkVersion) throws InvalidKeyException {
+ @Nonnull PublicKey signingKey, int minSdkVersion) throws InvalidKeyException {
String keyAlgorithm = signingKey.getAlgorithm();
if ("RSA".equalsIgnoreCase(keyAlgorithm)) {
// Use RSASSA-PKCS1-v1_5 signature scheme instead of RSASSA-PSS to guarantee
@@ -172,12 +172,12 @@ public abstract class ApkSignerV2 {
* @throws SignatureException if an error occurs when computing digests of generating
* signatures
*/
- @NonNull
+ @Nonnull
public static byte[] generateApkSigningBlock(
- @NonNull DigestSource beforeCentralDir,
- @NonNull DigestSource centralDir,
- @NonNull DigestSource eocd,
- @NonNull List<SignerConfig> signerConfigs)
+ @Nonnull DigestSource beforeCentralDir,
+ @Nonnull DigestSource centralDir,
+ @Nonnull DigestSource eocd,
+ @Nonnull List<SignerConfig> signerConfigs)
throws InvalidKeyException, SignatureException {
if (signerConfigs.isEmpty()) {
throw new IllegalArgumentException(
@@ -207,10 +207,10 @@ public abstract class ApkSignerV2 {
return generateApkSigningBlock(signerConfigs, contentDigests);
}
- @NonNull
+ @Nonnull
private static Map<ContentDigestAlgorithm, byte[]> computeContentDigests(
- @NonNull Set<ContentDigestAlgorithm> digestAlgorithms,
- @NonNull DigestSource[] contents) throws DigestException {
+ @Nonnull Set<ContentDigestAlgorithm> digestAlgorithms,
+ @Nonnull DigestSource[] contents) throws DigestException {
// For each digest algorithm the result is computed as follows:
// 1. Each segment of contents is split into consecutive chunks of 1 MB in size.
// The final chunk will be shorter iff the length of segment is not a multiple of 1 MB.
diff --git a/src/main/java/com/android/apkzlib/sign/v2/ByteArrayDigestSource.java b/src/main/java/com/android/apkzlib/sign/v2/ByteArrayDigestSource.java
index a8ac5fd..cd2ed1d 100644
--- a/src/main/java/com/android/apkzlib/sign/v2/ByteArrayDigestSource.java
+++ b/src/main/java/com/android/apkzlib/sign/v2/ByteArrayDigestSource.java
@@ -16,10 +16,9 @@
package com.android.apkzlib.sign.v2;
-import java.security.MessageDigest;
-
-import com.android.annotations.NonNull;
import com.google.common.base.Preconditions;
+import java.security.MessageDigest;
+import javax.annotation.Nonnull;
/**
* {@code byte[]} which is fed into {@link MessageDigest} instances.
@@ -32,7 +31,7 @@ public class ByteArrayDigestSource implements DigestSource {
* provided byte array. Changes to the byte array's contents are reflected visible in this
* source.
*/
- public ByteArrayDigestSource(@NonNull byte[] buf) {
+ public ByteArrayDigestSource(@Nonnull byte[] buf) {
mBuf = buf;
}
@@ -42,7 +41,7 @@ public class ByteArrayDigestSource implements DigestSource {
}
@Override
- public void feedDigests(long offset, int size, @NonNull MessageDigest[] digests) {
+ public void feedDigests(long offset, int size, @Nonnull MessageDigest[] digests) {
Preconditions.checkArgument(offset >= 0, "offset: %s", offset);
Preconditions.checkArgument(size >= 0, "size: %s", size);
Preconditions.checkArgument(offset <= mBuf.length, "offset too large: %s", offset);
diff --git a/src/main/java/com/android/apkzlib/sign/v2/DigestSource.java b/src/main/java/com/android/apkzlib/sign/v2/DigestSource.java
index 1887805..4a9cc19 100644
--- a/src/main/java/com/android/apkzlib/sign/v2/DigestSource.java
+++ b/src/main/java/com/android/apkzlib/sign/v2/DigestSource.java
@@ -18,8 +18,7 @@ package com.android.apkzlib.sign.v2;
import java.io.IOException;
import java.security.MessageDigest;
-
-import com.android.annotations.NonNull;
+import javax.annotation.Nonnull;
/**
* Source of data which is fed into {@link MessageDigest} instances.
@@ -47,5 +46,5 @@ public interface DigestSource {
* source.
* @param size size (in bytes) of the chunk.
*/
- void feedDigests(long offset, int size, @NonNull MessageDigest[] digests) throws IOException;
+ void feedDigests(long offset, int size, @Nonnull MessageDigest[] digests) throws IOException;
}
diff --git a/src/main/java/com/android/apkzlib/sign/v2/ZFileDigestSource.java b/src/main/java/com/android/apkzlib/sign/v2/ZFileDigestSource.java
index 7513987..31ae812 100644
--- a/src/main/java/com/android/apkzlib/sign/v2/ZFileDigestSource.java
+++ b/src/main/java/com/android/apkzlib/sign/v2/ZFileDigestSource.java
@@ -16,12 +16,11 @@
package com.android.apkzlib.sign.v2;
-import java.io.IOException;
-import java.security.MessageDigest;
-
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.ZFile;
import com.google.common.base.Preconditions;
+import java.io.IOException;
+import java.security.MessageDigest;
+import javax.annotation.Nonnull;
/**
* Contiguous section of {@link ZFile} which is fed into {@link MessageDigest} instances.
@@ -35,7 +34,7 @@ public class ZFileDigestSource implements DigestSource {
* Constructs a new {@code ZFileDigestSource} representing the section of the file starting
* at the provided {@code offset} and extending for the provided {@code size} number of bytes.
*/
- public ZFileDigestSource(@NonNull ZFile file, long offset, long size) {
+ public ZFileDigestSource(@Nonnull ZFile file, long offset, long size) {
Preconditions.checkArgument(offset >= 0, "offset: %s", offset);
Preconditions.checkArgument(size >= 0, "size: %s", size);
mFile = file;
@@ -50,7 +49,7 @@ public class ZFileDigestSource implements DigestSource {
}
@Override
- public void feedDigests(long offset, int size, @NonNull MessageDigest[] digests)
+ public void feedDigests(long offset, int size, @Nonnull MessageDigest[] digests)
throws IOException {
Preconditions.checkArgument(offset >= 0, "offset: %s", offset);
Preconditions.checkArgument(size >= 0, "size: %s", size);
diff --git a/src/main/java/com/android/apkzlib/utils/CachedFileContents.java b/src/main/java/com/android/apkzlib/utils/CachedFileContents.java
index 00446d5..f649692 100644
--- a/src/main/java/com/android/apkzlib/utils/CachedFileContents.java
+++ b/src/main/java/com/android/apkzlib/utils/CachedFileContents.java
@@ -16,15 +16,14 @@
package com.android.apkzlib.utils;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.google.common.base.Objects;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
import com.google.common.io.Files;
-
import java.io.File;
import java.io.IOException;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* A cache for file contents. The cache allows closing a file and saving in memory its contents
@@ -53,7 +52,7 @@ public class CachedFileContents<T> {
/**
* The file.
*/
- @NonNull
+ @Nonnull
private File mFile;
/**
@@ -84,7 +83,7 @@ public class CachedFileContents<T> {
*
* @param file the file
*/
- public CachedFileContents(@NonNull File file) {
+ public CachedFileContents(@Nonnull File file) {
mFile = file;
}
@@ -168,7 +167,7 @@ public class CachedFileContents<T> {
* @return the file; this file always exists and contains the old (cached) contents of the
* file
*/
- @NonNull
+ @Nonnull
public File getFile() {
return mFile;
}
diff --git a/src/main/java/com/android/apkzlib/utils/CachedSupplier.java b/src/main/java/com/android/apkzlib/utils/CachedSupplier.java
index b8c9a53..3f0e79f 100644
--- a/src/main/java/com/android/apkzlib/utils/CachedSupplier.java
+++ b/src/main/java/com/android/apkzlib/utils/CachedSupplier.java
@@ -16,9 +16,8 @@
package com.android.apkzlib.utils;
-import com.android.annotations.NonNull;
-
import java.util.function.Supplier;
+import javax.annotation.Nonnull;
/**
* Supplier that will cache a computed value and always supply the same value. It can be used to
@@ -58,13 +57,13 @@ public class CachedSupplier<T> {
/**
* Actual supplier of data, if computation is needed.
*/
- @NonNull
+ @Nonnull
private final Supplier<T> supplier;
/**
* Creates a new supplier.
*/
- public CachedSupplier(@NonNull Supplier<T> supplier) {
+ public CachedSupplier(@Nonnull Supplier<T> supplier) {
valid = false;
this.supplier = supplier;
}
diff --git a/src/main/java/com/android/apkzlib/utils/IOExceptionConsumer.java b/src/main/java/com/android/apkzlib/utils/IOExceptionConsumer.java
index 11c03b7..fcf3ab0 100644
--- a/src/main/java/com/android/apkzlib/utils/IOExceptionConsumer.java
+++ b/src/main/java/com/android/apkzlib/utils/IOExceptionConsumer.java
@@ -16,11 +16,11 @@
package com.android.apkzlib.utils;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.function.Consumer;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Consumer that can throw an {@link IOException}.
@@ -40,8 +40,8 @@ public interface IOExceptionConsumer<T> {
*
* @param c the consumer
*/
- @NonNull
- static <T> Consumer<T> asConsumer(@NonNull IOExceptionConsumer<T> c) {
+ @Nonnull
+ static <T> Consumer<T> asConsumer(@Nonnull IOExceptionConsumer<T> c) {
return i -> {
try {
c.accept(i);
diff --git a/src/main/java/com/android/apkzlib/utils/IOExceptionFunction.java b/src/main/java/com/android/apkzlib/utils/IOExceptionFunction.java
index 11460a2..6d84b5b 100644
--- a/src/main/java/com/android/apkzlib/utils/IOExceptionFunction.java
+++ b/src/main/java/com/android/apkzlib/utils/IOExceptionFunction.java
@@ -16,12 +16,11 @@
package com.android.apkzlib.utils;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.function.Function;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Function that can throw an I/O Exception
@@ -41,8 +40,8 @@ public interface IOExceptionFunction<F, T> {
*
* @param f the function
*/
- @NonNull
- static <F, T> Function<F, T> asFunction(@NonNull IOExceptionFunction<F, T> f) {
+ @Nonnull
+ static <F, T> Function<F, T> asFunction(@Nonnull IOExceptionFunction<F, T> f) {
return i -> {
try {
return f.apply(i);
diff --git a/src/main/java/com/android/apkzlib/utils/IOExceptionRunnable.java b/src/main/java/com/android/apkzlib/utils/IOExceptionRunnable.java
index f1b181a..d3bd02a 100644
--- a/src/main/java/com/android/apkzlib/utils/IOExceptionRunnable.java
+++ b/src/main/java/com/android/apkzlib/utils/IOExceptionRunnable.java
@@ -16,9 +16,9 @@
package com.android.apkzlib.utils;
-import com.android.annotations.NonNull;
import java.io.IOException;
import java.io.UncheckedIOException;
+import javax.annotation.Nonnull;
/**
* Runnable that can throw I/O exceptions.
@@ -37,8 +37,8 @@ public interface IOExceptionRunnable {
*
* @param r the runnable
*/
- @NonNull
- public static Runnable asRunnable(@NonNull IOExceptionRunnable r) {
+ @Nonnull
+ public static Runnable asRunnable(@Nonnull IOExceptionRunnable r) {
return () -> {
try {
r.run();
diff --git a/src/main/java/com/android/apkzlib/utils/IOExceptionWrapper.java b/src/main/java/com/android/apkzlib/utils/IOExceptionWrapper.java
index 604a90f..067b260 100644
--- a/src/main/java/com/android/apkzlib/utils/IOExceptionWrapper.java
+++ b/src/main/java/com/android/apkzlib/utils/IOExceptionWrapper.java
@@ -16,9 +16,8 @@
package com.android.apkzlib.utils;
-import com.android.annotations.NonNull;
-
import java.io.IOException;
+import javax.annotation.Nonnull;
/**
* Runtime exception used to encapsulate an IO Exception. This is used to allow throwing I/O
@@ -31,12 +30,12 @@ public class IOExceptionWrapper extends RuntimeException {
*
* @param e the I/O exception to encapsulate
*/
- public IOExceptionWrapper(@NonNull IOException e) {
+ public IOExceptionWrapper(@Nonnull IOException e) {
super(e);
}
@Override
- @NonNull
+ @Nonnull
public IOException getCause() {
return (IOException) super.getCause();
}
diff --git a/src/main/java/com/android/apkzlib/zfile/ApkCreator.java b/src/main/java/com/android/apkzlib/zfile/ApkCreator.java
index 10cac94..d39891d 100644
--- a/src/main/java/com/android/apkzlib/zfile/ApkCreator.java
+++ b/src/main/java/com/android/apkzlib/zfile/ApkCreator.java
@@ -16,14 +16,13 @@
package com.android.apkzlib.zfile;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.function.Function;
import java.util.function.Predicate;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Creates or updates APKs based on provided entries.
@@ -43,7 +42,7 @@ public interface ApkCreator extends Closeable {
* predicate applies after transformation
* @throws IOException I/O error
*/
- void writeZip(@NonNull File zip, @Nullable Function<String, String> transform,
+ void writeZip(@Nonnull File zip, @Nullable Function<String, String> transform,
@Nullable Predicate<String> isIgnored) throws IOException;
/**
@@ -54,7 +53,7 @@ public interface ApkCreator extends Closeable {
* @param apkPath the filepath inside the archive.
* @throws IOException I/O error
*/
- void writeFile(@NonNull File inputFile, @NonNull String apkPath) throws IOException;
+ void writeFile(@Nonnull File inputFile, @Nonnull String apkPath) throws IOException;
/**
* Deletes a file in a given path.
@@ -62,5 +61,5 @@ public interface ApkCreator extends Closeable {
* @param apkPath the path to remove
* @throws IOException failed to remove the entry
*/
- void deleteFile(@NonNull String apkPath) throws IOException;
+ void deleteFile(@Nonnull String apkPath) throws IOException;
}
diff --git a/src/main/java/com/android/apkzlib/zfile/ApkCreatorFactory.java b/src/main/java/com/android/apkzlib/zfile/ApkCreatorFactory.java
index d4fcdf9..67f6900 100644
--- a/src/main/java/com/android/apkzlib/zfile/ApkCreatorFactory.java
+++ b/src/main/java/com/android/apkzlib/zfile/ApkCreatorFactory.java
@@ -18,14 +18,13 @@ package com.android.apkzlib.zfile;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.google.common.base.Preconditions;
-
import java.io.File;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.function.Predicate;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Factory that creates instances of {@link ApkCreator}.
@@ -37,7 +36,7 @@ public interface ApkCreatorFactory {
*
* @param creationData the information to create the APK
*/
- ApkCreator make(@NonNull CreationData creationData);
+ ApkCreator make(@Nonnull CreationData creationData);
/**
* Data structure with the required information to initiate the creation of an APK. See
@@ -49,7 +48,7 @@ public interface ApkCreatorFactory {
* The path where the APK should be located. May already exist or not (if it does, then
* the APK may be updated instead of created).
*/
- @NonNull
+ @Nonnull
private final File mApkPath;
/**
@@ -92,10 +91,10 @@ public interface ApkCreatorFactory {
*/
private final int mMinSdkVersion;
- @NonNull
+ @Nonnull
private final NativeLibrariesPackagingMode mNativeLibrariesPackagingMode;
- @NonNull
+ @Nonnull
private final Predicate<String> mNoCompressPredicate;
/**
@@ -118,7 +117,7 @@ public interface ApkCreatorFactory {
* @param noCompressPredicate predicate to decide which file paths should be uncompressed
*/
public CreationData(
- @NonNull File apkPath,
+ @Nonnull File apkPath,
@Nullable PrivateKey key,
@Nullable X509Certificate certificate,
boolean v1SigningEnabled,
@@ -126,8 +125,8 @@ public interface ApkCreatorFactory {
@Nullable String builtBy,
@Nullable String createdBy,
int minSdkVersion,
- @NonNull NativeLibrariesPackagingMode nativeLibrariesPackagingMode,
- @NonNull Predicate<String> noCompressPredicate) {
+ @Nonnull NativeLibrariesPackagingMode nativeLibrariesPackagingMode,
+ @Nonnull Predicate<String> noCompressPredicate) {
Preconditions.checkArgument((key == null) == (certificate == null),
"(key == null) != (certificate == null)");
Preconditions.checkArgument(minSdkVersion >= 0, "minSdkVersion < 0");
@@ -150,7 +149,7 @@ public interface ApkCreatorFactory {
*
* @return the path that may already exist or not
*/
- @NonNull
+ @Nonnull
public File getApkPath() {
return mApkPath;
}
@@ -224,7 +223,7 @@ public interface ApkCreatorFactory {
/**
* Returns the packaging policy that the {@link ApkCreator} should use for native libraries.
*/
- @NonNull
+ @Nonnull
public NativeLibrariesPackagingMode getNativeLibrariesPackagingMode() {
return mNativeLibrariesPackagingMode;
}
@@ -232,7 +231,7 @@ public interface ApkCreatorFactory {
/**
* Returns the predicate to decide which file paths should be uncompressed.
*/
- @NonNull
+ @Nonnull
public Predicate<String> getNoCompressPredicate() {
return mNoCompressPredicate;
}
diff --git a/src/main/java/com/android/apkzlib/zfile/ApkZFileCreator.java b/src/main/java/com/android/apkzlib/zfile/ApkZFileCreator.java
index a21c297..69289f7 100644
--- a/src/main/java/com/android/apkzlib/zfile/ApkZFileCreator.java
+++ b/src/main/java/com/android/apkzlib/zfile/ApkZFileCreator.java
@@ -16,8 +16,6 @@
package com.android.apkzlib.zfile;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.zip.AlignmentRule;
import com.android.apkzlib.zip.AlignmentRules;
import com.android.apkzlib.zip.StoredEntry;
@@ -30,6 +28,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.function.Function;
import java.util.function.Predicate;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* {@link ApkCreator} that uses {@link ZFileOptions} to generate the APK.
@@ -50,7 +50,7 @@ class ApkZFileCreator implements ApkCreator {
/**
* The zip file.
*/
- @NonNull
+ @Nonnull
private final ZFile mZip;
/**
@@ -61,7 +61,7 @@ class ApkZFileCreator implements ApkCreator {
/**
* Predicate defining which files should not be compressed.
*/
- @NonNull
+ @Nonnull
private final Predicate<String> mNoCompressPredicate;
/**
@@ -72,8 +72,8 @@ class ApkZFileCreator implements ApkCreator {
* @throws IOException failed to create the zip
*/
ApkZFileCreator(
- @NonNull ApkCreatorFactory.CreationData creationData,
- @NonNull ZFileOptions options)
+ @Nonnull ApkCreatorFactory.CreationData creationData,
+ @Nonnull ZFileOptions options)
throws IOException {
switch (creationData.getNativeLibrariesPackagingMode()) {
@@ -105,7 +105,7 @@ class ApkZFileCreator implements ApkCreator {
}
@Override
- public void writeZip(@NonNull File zip, @Nullable Function<String, String> transform,
+ public void writeZip(@Nonnull File zip, @Nullable Function<String, String> transform,
@Nullable Predicate<String> isIgnored) throws IOException {
Preconditions.checkState(!mClosed, "mClosed == true");
Preconditions.checkArgument(zip.isFile(), "!zip.isFile()");
@@ -130,7 +130,7 @@ class ApkZFileCreator implements ApkCreator {
}
@Override
- public void writeFile(@NonNull File inputFile, @NonNull String apkPath) throws IOException {
+ public void writeFile(@Nonnull File inputFile, @Nonnull String apkPath) throws IOException {
Preconditions.checkState(!mClosed, "mClosed == true");
boolean mayCompress = !mNoCompressPredicate.test(apkPath);
@@ -149,7 +149,7 @@ class ApkZFileCreator implements ApkCreator {
}
@Override
- public void deleteFile(@NonNull String apkPath) throws IOException {
+ public void deleteFile(@Nonnull String apkPath) throws IOException {
Preconditions.checkState(!mClosed, "mClosed == true");
StoredEntry entry = mZip.get(apkPath);
diff --git a/src/main/java/com/android/apkzlib/zfile/ApkZFileCreatorFactory.java b/src/main/java/com/android/apkzlib/zfile/ApkZFileCreatorFactory.java
index aecbf68..5f05b28 100644
--- a/src/main/java/com/android/apkzlib/zfile/ApkZFileCreatorFactory.java
+++ b/src/main/java/com/android/apkzlib/zfile/ApkZFileCreatorFactory.java
@@ -16,10 +16,10 @@
package com.android.apkzlib.zfile;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.ZFileOptions;
import java.io.IOException;
import java.io.UncheckedIOException;
+import javax.annotation.Nonnull;
/**
* Creates instances of {@link ApkZFileCreator}.
@@ -29,7 +29,7 @@ public class ApkZFileCreatorFactory implements ApkCreatorFactory {
/**
* Options for the {@link ZFileOptions} to use in all APKs.
*/
- @NonNull
+ @Nonnull
private final ZFileOptions mOptions;
/**
@@ -37,14 +37,14 @@ public class ApkZFileCreatorFactory implements ApkCreatorFactory {
*
* @param options the options to use for all instances created
*/
- public ApkZFileCreatorFactory(@NonNull ZFileOptions options) {
+ public ApkZFileCreatorFactory(@Nonnull ZFileOptions options) {
mOptions = options;
}
@Override
- @NonNull
- public ApkCreator make(@NonNull CreationData creationData) {
+ @Nonnull
+ public ApkCreator make(@Nonnull CreationData creationData) {
try {
return new ApkZFileCreator(creationData, mOptions);
} catch (IOException e) {
diff --git a/src/main/java/com/android/apkzlib/zfile/ZFiles.java b/src/main/java/com/android/apkzlib/zfile/ZFiles.java
index 0c288ee..fdf6983 100644
--- a/src/main/java/com/android/apkzlib/zfile/ZFiles.java
+++ b/src/main/java/com/android/apkzlib/zfile/ZFiles.java
@@ -16,8 +16,6 @@
package com.android.apkzlib.zfile;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.sign.FullApkSignExtension;
import com.android.apkzlib.sign.ManifestGenerationExtension;
import com.android.apkzlib.sign.SignatureExtension;
@@ -26,13 +24,14 @@ import com.android.apkzlib.zip.AlignmentRules;
import com.android.apkzlib.zip.StoredEntry;
import com.android.apkzlib.zip.ZFile;
import com.android.apkzlib.zip.ZFileOptions;
-
import java.io.File;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Factory for {@link ZFile}s that are specifically configured to be APKs, AARs, ...
@@ -64,8 +63,8 @@ public class ZFiles {
* @return the zip file
* @throws IOException failed to create the zip file
*/
- @NonNull
- public static ZFile apk(@NonNull File f, @NonNull ZFileOptions options) throws IOException {
+ @Nonnull
+ public static ZFile apk(@Nonnull File f, @Nonnull ZFileOptions options) throws IOException {
options.setAlignmentRule(
AlignmentRules.compose(options.getAlignmentRule(), APK_DEFAULT_RULE));
return new ZFile(f, options);
@@ -91,10 +90,10 @@ public class ZFiles {
* @return the zip file
* @throws IOException failed to create the zip file
*/
- @NonNull
+ @Nonnull
public static ZFile apk(
- @NonNull File f,
- @NonNull ZFileOptions options,
+ @Nonnull File f,
+ @Nonnull ZFileOptions options,
@Nullable PrivateKey key,
@Nullable X509Certificate certificate,
boolean v1SigningEnabled,
diff --git a/src/main/java/com/android/apkzlib/zip/AlignmentRule.java b/src/main/java/com/android/apkzlib/zip/AlignmentRule.java
index 5cfe732..bb5b0e5 100644
--- a/src/main/java/com/android/apkzlib/zip/AlignmentRule.java
+++ b/src/main/java/com/android/apkzlib/zip/AlignmentRule.java
@@ -16,7 +16,7 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
+import javax.annotation.Nonnull;
/**
* An alignment rule defines how to a file should be aligned in a zip, based on its name.
@@ -35,7 +35,7 @@ public interface AlignmentRule {
* @return the alignment value, always greater than {@code 0}; if this rule places no
* restrictions on the provided path, then {@link AlignmentRule#NO_ALIGNMENT} is returned
*/
- int alignment(@NonNull String path);
+ int alignment(@Nonnull String path);
}
diff --git a/src/main/java/com/android/apkzlib/zip/AlignmentRules.java b/src/main/java/com/android/apkzlib/zip/AlignmentRules.java
index 519c3da..b06a596 100644
--- a/src/main/java/com/android/apkzlib/zip/AlignmentRules.java
+++ b/src/main/java/com/android/apkzlib/zip/AlignmentRules.java
@@ -16,8 +16,8 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
/**
* Factory for instances of {@link AlignmentRule}.
@@ -46,7 +46,7 @@ public final class AlignmentRules {
* @param alignment the alignment for paths that match the provided suffix
* @return the rule
*/
- public static AlignmentRule constantForSuffix(@NonNull String suffix, int alignment) {
+ public static AlignmentRule constantForSuffix(@Nonnull String suffix, int alignment) {
Preconditions.checkArgument(!suffix.isEmpty(), "suffix.isEmpty()");
Preconditions.checkArgument(alignment > 0, "alignment <= 0");
@@ -62,7 +62,7 @@ public final class AlignmentRules {
* {@link AlignmentRule#NO_ALIGNMENT} is returned
* @return the composition rule
*/
- public static AlignmentRule compose(@NonNull AlignmentRule... rules) {
+ public static AlignmentRule compose(@Nonnull AlignmentRule... rules) {
return (String path) -> {
for (AlignmentRule r : rules) {
int align = r.alignment(path);
diff --git a/src/main/java/com/android/apkzlib/zip/CentralDirectory.java b/src/main/java/com/android/apkzlib/zip/CentralDirectory.java
index 53706b1..083bc65 100644
--- a/src/main/java/com/android/apkzlib/zip/CentralDirectory.java
+++ b/src/main/java/com/android/apkzlib/zip/CentralDirectory.java
@@ -16,7 +16,6 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.utils.CachedSupplier;
import com.android.apkzlib.zip.utils.MsDosDateTimeUtils;
import com.google.common.base.Preconditions;
@@ -26,7 +25,6 @@ import com.google.common.collect.Maps;
import com.google.common.primitives.Ints;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.ByteBuffer;
@@ -34,6 +32,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.annotation.Nonnull;
/**
* Representation of the central directory of a zip archive.
@@ -174,19 +173,19 @@ class CentralDirectory {
/**
* Contains all entries in the directory mapped from their names.
*/
- @NonNull
+ @Nonnull
private final Map<String, StoredEntry> mEntries;
/**
* The file where this directory belongs to.
*/
- @NonNull
+ @Nonnull
private final ZFile mFile;
/**
* Supplier that provides a byte representation of the central directory.
*/
- @NonNull
+ @Nonnull
private final CachedSupplier<byte[]> mBytesSupplier;
/**
@@ -194,7 +193,7 @@ class CentralDirectory {
*
* @param file the file
*/
- CentralDirectory(@NonNull ZFile file) {
+ CentralDirectory(@Nonnull ZFile file) {
mEntries = Maps.newHashMap();
mFile = file;
mBytesSupplier = new CachedSupplier<>(this::computeByteRepresentation);
@@ -214,7 +213,7 @@ class CentralDirectory {
* @throws IOException failed to read data from the zip, or the central directory is corrupted
* or has unsupported features
*/
- static CentralDirectory makeFromData(@NonNull ByteBuffer bytes, int count, @NonNull ZFile file)
+ static CentralDirectory makeFromData(@Nonnull ByteBuffer bytes, int count, @Nonnull ZFile file)
throws IOException {
Preconditions.checkNotNull(bytes, "bytes == null");
Preconditions.checkArgument(count >= 0, "count < 0");
@@ -247,8 +246,8 @@ class CentralDirectory {
* @param file the zip file itself
* @return the created central directory
*/
- static CentralDirectory makeFromEntries(@NonNull Set<StoredEntry> entries,
- @NonNull ZFile file) {
+ static CentralDirectory makeFromEntries(@Nonnull Set<StoredEntry> entries,
+ @Nonnull ZFile file) {
CentralDirectory directory = new CentralDirectory(file);
for (StoredEntry entry : entries) {
CentralDirectoryHeader cdr = entry.getCentralDirectoryHeader();
@@ -271,7 +270,7 @@ class CentralDirectory {
* @throws IOException failed to read the directory entry, either because of an I/O error,
* because it is corrupt or contains unsupported features
*/
- private void readEntry(@NonNull ByteBuffer bytes, @NonNull ZFile file) throws IOException {
+ private void readEntry(@Nonnull ByteBuffer bytes, @Nonnull ZFile file) throws IOException {
F_SIGNATURE.verify(bytes);
long madeBy = F_MADE_BY.read(bytes);
@@ -380,7 +379,7 @@ class CentralDirectory {
*
* @return all entries on a non-modifiable map
*/
- @NonNull
+ @Nonnull
Map<String, StoredEntry> getEntries() {
return ImmutableMap.copyOf(mEntries);
}
diff --git a/src/main/java/com/android/apkzlib/zip/CentralDirectoryHeader.java b/src/main/java/com/android/apkzlib/zip/CentralDirectoryHeader.java
index c6792d5..b5b5226 100644
--- a/src/main/java/com/android/apkzlib/zip/CentralDirectoryHeader.java
+++ b/src/main/java/com/android/apkzlib/zip/CentralDirectoryHeader.java
@@ -16,14 +16,13 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.utils.MsDosDateTimeUtils;
import com.google.common.base.Verify;
-
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
/**
* The Central Directory Header contains information about files stored in the zip. Instances of
@@ -45,7 +44,7 @@ public class CentralDirectoryHeader implements Cloneable {
/**
* Name of the file.
*/
- @NonNull
+ @Nonnull
private String mName;
/**
@@ -66,7 +65,7 @@ public class CentralDirectoryHeader implements Cloneable {
/**
* General-purpose bit flag.
*/
- @NonNull
+ @Nonnull
private GPFlags mGpBit;
/**
@@ -83,13 +82,13 @@ public class CentralDirectoryHeader implements Cloneable {
* Extra data field contents. This field follows a specific structure according to the
* specification.
*/
- @NonNull
+ @Nonnull
private ExtraField mExtraField;
/**
* File comment.
*/
- @NonNull
+ @Nonnull
private byte[] mComment;
/**
@@ -116,13 +115,13 @@ public class CentralDirectoryHeader implements Cloneable {
/**
* Compress information that may not have been computed yet due to lazy compression.
*/
- @NonNull
+ @Nonnull
private Future<CentralDirectoryHeaderCompressInfo> mCompressInfo;
/**
* The file this header belongs to.
*/
- @NonNull
+ @Nonnull
private final ZFile mFile;
/**
@@ -135,11 +134,11 @@ public class CentralDirectoryHeader implements Cloneable {
* @param zFile the file this header belongs to
*/
CentralDirectoryHeader(
- @NonNull String name,
+ @Nonnull String name,
long uncompressedSize,
- @NonNull Future<CentralDirectoryHeaderCompressInfo> compressInfo,
- @NonNull GPFlags flags,
- @NonNull ZFile zFile) {
+ @Nonnull Future<CentralDirectoryHeaderCompressInfo> compressInfo,
+ @Nonnull GPFlags flags,
+ @Nonnull ZFile zFile) {
mName = name;
mUncompressedSize = uncompressedSize;
mCrc32 = 0;
@@ -167,7 +166,7 @@ public class CentralDirectoryHeader implements Cloneable {
*
* @return the name
*/
- @NonNull
+ @Nonnull
public String getName() {
return mName;
}
@@ -222,7 +221,7 @@ public class CentralDirectoryHeader implements Cloneable {
*
* @return the bit flag
*/
- @NonNull
+ @Nonnull
public GPFlags getGpBit() {
return mGpBit;
}
@@ -272,7 +271,7 @@ public class CentralDirectoryHeader implements Cloneable {
*
* @return the data (returns an empty array if there is none)
*/
- @NonNull
+ @Nonnull
public ExtraField getExtraField() {
return mExtraField;
}
@@ -282,7 +281,7 @@ public class CentralDirectoryHeader implements Cloneable {
*
* @param extraField the data to set
*/
- public void setExtraField(@NonNull ExtraField extraField) {
+ public void setExtraField(@Nonnull ExtraField extraField) {
setExtraFieldNoNotify(extraField);
mFile.centralDirectoryChanged();
}
@@ -293,7 +292,7 @@ public class CentralDirectoryHeader implements Cloneable {
*
* @param extraField the data to set
*/
- void setExtraFieldNoNotify(@NonNull ExtraField extraField) {
+ void setExtraFieldNoNotify(@Nonnull ExtraField extraField) {
mExtraField = extraField;
}
@@ -302,7 +301,7 @@ public class CentralDirectoryHeader implements Cloneable {
*
* @return the comment (returns an empty array if there is no comment)
*/
- @NonNull
+ @Nonnull
public byte[] getComment() {
return mComment;
}
@@ -312,7 +311,7 @@ public class CentralDirectoryHeader implements Cloneable {
*
* @param comment the comment
*/
- void setComment(@NonNull byte[] comment) {
+ void setComment(@Nonnull byte[] comment) {
mComment = comment;
}
@@ -405,7 +404,7 @@ public class CentralDirectoryHeader implements Cloneable {
*
* @return the information
*/
- @NonNull
+ @Nonnull
public Future<CentralDirectoryHeaderCompressInfo> getCompressionInfo() {
return mCompressInfo;
}
@@ -417,7 +416,7 @@ public class CentralDirectoryHeader implements Cloneable {
* @return the result of the future
* @throws IOException failed to get the information
*/
- @NonNull
+ @Nonnull
public CentralDirectoryHeaderCompressInfo getCompressionInfoWithWait()
throws IOException {
try {
diff --git a/src/main/java/com/android/apkzlib/zip/CentralDirectoryHeaderCompressInfo.java b/src/main/java/com/android/apkzlib/zip/CentralDirectoryHeaderCompressInfo.java
index c8453b5..305f120 100644
--- a/src/main/java/com/android/apkzlib/zip/CentralDirectoryHeaderCompressInfo.java
+++ b/src/main/java/com/android/apkzlib/zip/CentralDirectoryHeaderCompressInfo.java
@@ -16,7 +16,7 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
+import javax.annotation.Nonnull;
/**
* Information stored in the {@link CentralDirectoryHeader} that is related to compression and may
@@ -37,7 +37,7 @@ public class CentralDirectoryHeaderCompressInfo {
/**
* The compression method.
*/
- @NonNull
+ @Nonnull
private final CompressionMethod mMethod;
/**
@@ -59,7 +59,7 @@ public class CentralDirectoryHeaderCompressInfo {
* {@link #VERSION_WITH_STORE_FILES_ONLY} or {@link #VERSION_WITH_DIRECTORIES_AND_DEFLATE})
*/
public CentralDirectoryHeaderCompressInfo(
- @NonNull CompressionMethod method,
+ @Nonnull CompressionMethod method,
long compressedSize,
long versionToExtract) {
mMethod = method;
@@ -74,8 +74,8 @@ public class CentralDirectoryHeaderCompressInfo {
* @param method the compression method
* @param compressedSize the compressed size
*/
- public CentralDirectoryHeaderCompressInfo(@NonNull CentralDirectoryHeader header,
- @NonNull CompressionMethod method, long compressedSize) {
+ public CentralDirectoryHeaderCompressInfo(@Nonnull CentralDirectoryHeader header,
+ @Nonnull CompressionMethod method, long compressedSize) {
mMethod = method;
mCompressedSize = compressedSize;
@@ -103,7 +103,7 @@ public class CentralDirectoryHeaderCompressInfo {
*
* @return the compression method
*/
- @NonNull
+ @Nonnull
public CompressionMethod getMethod() {
return mMethod;
}
diff --git a/src/main/java/com/android/apkzlib/zip/CompressionMethod.java b/src/main/java/com/android/apkzlib/zip/CompressionMethod.java
index 5ac970f..dd2ee8d 100644
--- a/src/main/java/com/android/apkzlib/zip/CompressionMethod.java
+++ b/src/main/java/com/android/apkzlib/zip/CompressionMethod.java
@@ -16,7 +16,7 @@
package com.android.apkzlib.zip;
-import com.android.annotations.Nullable;
+import javax.annotation.Nullable;
/**
* Enumeration with all known compression methods.
diff --git a/src/main/java/com/android/apkzlib/zip/CompressionResult.java b/src/main/java/com/android/apkzlib/zip/CompressionResult.java
index d182f28..f051f1e 100644
--- a/src/main/java/com/android/apkzlib/zip/CompressionResult.java
+++ b/src/main/java/com/android/apkzlib/zip/CompressionResult.java
@@ -16,8 +16,8 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.utils.CloseableByteSource;
+import javax.annotation.Nonnull;
/**
* Result of compressing data.
@@ -27,13 +27,13 @@ public class CompressionResult {
/**
* The compression method used.
*/
- @NonNull
+ @Nonnull
private final CompressionMethod mCompressionMethod;
/**
* The resulting data.
*/
- @NonNull
+ @Nonnull
private final CloseableByteSource mSource;
/**
@@ -47,7 +47,7 @@ public class CompressionResult {
* @param source the data source
* @param method the compression method
*/
- public CompressionResult(@NonNull CloseableByteSource source, @NonNull CompressionMethod method,
+ public CompressionResult(@Nonnull CloseableByteSource source, @Nonnull CompressionMethod method,
long size) {
mCompressionMethod = method;
mSource = source;
@@ -58,7 +58,7 @@ public class CompressionResult {
* Obtains the compression method.
* @return the compression method
*/
- @NonNull
+ @Nonnull
public CompressionMethod getCompressionMethod() {
return mCompressionMethod;
}
@@ -67,7 +67,7 @@ public class CompressionResult {
* Obtains the compressed data.
* @return the data, the resulting array should not be modified
*/
- @NonNull
+ @Nonnull
public CloseableByteSource getSource() {
return mSource;
}
diff --git a/src/main/java/com/android/apkzlib/zip/Compressor.java b/src/main/java/com/android/apkzlib/zip/Compressor.java
index d94cdf9..9cec463 100644
--- a/src/main/java/com/android/apkzlib/zip/Compressor.java
+++ b/src/main/java/com/android/apkzlib/zip/Compressor.java
@@ -16,9 +16,9 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.utils.CloseableByteSource;
import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
/**
* A compressor is capable of, well, compressing data. Data is read from an {@code ByteSource}.
@@ -32,6 +32,6 @@ public interface Compressor {
* @param source the source to compress
* @return a future that will eventually contain the compression result
*/
- @NonNull
- ListenableFuture<CompressionResult> compress(@NonNull CloseableByteSource source);
+ @Nonnull
+ ListenableFuture<CompressionResult> compress(@Nonnull CloseableByteSource source);
}
diff --git a/src/main/java/com/android/apkzlib/zip/EncodeUtils.java b/src/main/java/com/android/apkzlib/zip/EncodeUtils.java
index 9daaa00..6579d1c 100644
--- a/src/main/java/com/android/apkzlib/zip/EncodeUtils.java
+++ b/src/main/java/com/android/apkzlib/zip/EncodeUtils.java
@@ -16,12 +16,11 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.google.common.base.Charsets;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
+import javax.annotation.Nonnull;
/**
* Utilities to encode and decode file names in zips.
@@ -45,8 +44,8 @@ public class EncodeUtils {
* @param flags the zip entry flags
* @return the decode file name
*/
- @NonNull
- public static String decode(@NonNull ByteBuffer bytes, int length, @NonNull GPFlags flags)
+ @Nonnull
+ public static String decode(@Nonnull ByteBuffer bytes, int length, @Nonnull GPFlags flags)
throws IOException {
if (bytes.remaining() < length) {
throw new IOException("Only " + bytes.remaining() + " bytes exist in the buffer, but "
@@ -66,8 +65,8 @@ public class EncodeUtils {
* @param flags the zip entry flags
* @return the decode file name
*/
- @NonNull
- public static String decode(@NonNull byte[] data, @NonNull GPFlags flags) {
+ @Nonnull
+ public static String decode(@Nonnull byte[] data, @Nonnull GPFlags flags) {
Charset charset = flagsCharset(flags);
return charset.decode(ByteBuffer.wrap(data)).toString();
}
@@ -79,8 +78,8 @@ public class EncodeUtils {
* @param flags the zip entry flags
* @return the encoded file name
*/
- @NonNull
- public static byte[] encode(@NonNull String name, @NonNull GPFlags flags) {
+ @Nonnull
+ public static byte[] encode(@Nonnull String name, @Nonnull GPFlags flags) {
Charset charset = flagsCharset(flags);
ByteBuffer bytes = charset.encode(name);
byte[] result = new byte[bytes.remaining()];
@@ -94,8 +93,8 @@ public class EncodeUtils {
* @param flags the flags
* @return the charset to use
*/
- @NonNull
- private static Charset flagsCharset(@NonNull GPFlags flags) {
+ @Nonnull
+ private static Charset flagsCharset(@Nonnull GPFlags flags) {
if (flags.isUtf8FileName()) {
return Charsets.UTF_8;
} else {
diff --git a/src/main/java/com/android/apkzlib/zip/Eocd.java b/src/main/java/com/android/apkzlib/zip/Eocd.java
index a5a53be..47cbf5a 100644
--- a/src/main/java/com/android/apkzlib/zip/Eocd.java
+++ b/src/main/java/com/android/apkzlib/zip/Eocd.java
@@ -16,16 +16,15 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.utils.CachedSupplier;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.primitives.Ints;
-
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.ByteBuffer;
+import javax.annotation.Nonnull;
/**
* End Of Central Directory record in a zip file.
@@ -105,13 +104,13 @@ class Eocd {
/**
* Contents of the EOCD comment.
*/
- @NonNull
+ @Nonnull
private final byte[] mComment;
/**
* Supplier of the byte representation of the EOCD.
*/
- @NonNull
+ @Nonnull
private final CachedSupplier<byte[]> mByteSupplier;
/**
@@ -122,7 +121,7 @@ class Eocd {
* buffer's position will have moved to the end of the EOCD
* @throws IOException failed to read information or the EOCD data is corrupt or invalid
*/
- Eocd(@NonNull ByteBuffer bytes) throws IOException {
+ Eocd(@Nonnull ByteBuffer bytes) throws IOException {
/*
* Read the EOCD record.
@@ -224,7 +223,7 @@ class Eocd {
* @return a byte representation of the EOCD that has exactly {@link #getEocdSize()} bytes
* @throws IOException failed to generate the EOCD data
*/
- @NonNull
+ @Nonnull
byte[] toBytes() throws IOException {
return mByteSupplier.get();
}
@@ -235,7 +234,7 @@ class Eocd {
* @return a byte representation of the EOCD that has exactly {@link #getEocdSize()} bytes
* @throws UncheckedIOException failed to generate the EOCD data
*/
- @NonNull
+ @Nonnull
private byte[] computeByteRepresentation() {
ByteBuffer out = ByteBuffer.allocate(F_COMMENT_SIZE.endOffset() + mComment.length);
diff --git a/src/main/java/com/android/apkzlib/zip/ExtraField.java b/src/main/java/com/android/apkzlib/zip/ExtraField.java
index 05f139b..113ef64 100644
--- a/src/main/java/com/android/apkzlib/zip/ExtraField.java
+++ b/src/main/java/com/android/apkzlib/zip/ExtraField.java
@@ -16,18 +16,16 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.zip.utils.LittleEndianUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
-
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Contains an extra field.
@@ -76,7 +74,7 @@ public class ExtraField {
*
* @param rawData the raw data; will not be parsed unless needed
*/
- public ExtraField(@NonNull byte[] rawData) {
+ public ExtraField(@Nonnull byte[] rawData) {
mRawData = rawData;
mSegments = null;
}
@@ -94,7 +92,7 @@ public class ExtraField {
*
* @param segments the segments
*/
- public ExtraField(@NonNull ImmutableList<Segment> segments) {
+ public ExtraField(@Nonnull ImmutableList<Segment> segments) {
mRawData = null;
mSegments = segments;
}
@@ -196,7 +194,7 @@ public class ExtraField {
* written
* @throws IOException failed to write the extra fields
*/
- public void write(@NonNull ByteBuffer out) throws IOException {
+ public void write(@Nonnull ByteBuffer out) throws IOException {
if (mRawData != null) {
out.put(mRawData);
} else {
@@ -213,7 +211,7 @@ public class ExtraField {
* @param headerId the header ID
* @return the segmnet factory that creates segments with the given header
*/
- @NonNull
+ @Nonnull
private static SegmentFactory identifySegmentFactory(int headerId) {
if (headerId == ALIGNMENT_ZIP_EXTRA_DATA_FIELD_HEADER_ID) {
return AlignmentSegment::new;
@@ -249,7 +247,7 @@ public class ExtraField {
* be written
* @throws IOException failed to write segment data
*/
- void write(@NonNull ByteBuffer out) throws IOException;
+ void write(@Nonnull ByteBuffer out) throws IOException;
}
/**
@@ -266,8 +264,8 @@ public class ExtraField {
* @return the created segment
* @throws IOException failed to create the segment from the data
*/
- @NonNull
- Segment make(int headerId, @NonNull byte[] data) throws IOException;
+ @Nonnull
+ Segment make(int headerId, @Nonnull byte[] data) throws IOException;
}
/**
@@ -284,7 +282,7 @@ public class ExtraField {
/**
* Data in the segment.
*/
- @NonNull
+ @Nonnull
private final byte[] mData;
/**
@@ -293,7 +291,7 @@ public class ExtraField {
* @param headerId the header ID
* @param data the segment data
*/
- RawDataSegment(int headerId, @NonNull byte[] data) {
+ RawDataSegment(int headerId, @Nonnull byte[] data) {
mHeaderId = headerId;
mData = data;
}
@@ -304,7 +302,7 @@ public class ExtraField {
}
@Override
- public void write(@NonNull ByteBuffer out) throws IOException {
+ public void write(@Nonnull ByteBuffer out) throws IOException {
LittleEndianUtils.writeUnsigned2Le(out, mHeaderId);
LittleEndianUtils.writeUnsigned2Le(out, mData.length);
out.put(mData);
@@ -360,7 +358,7 @@ public class ExtraField {
* @param data the segment data
* @throws IOException failed to create the segment from the data
*/
- public AlignmentSegment(int headerId, @NonNull byte[] data) throws IOException {
+ public AlignmentSegment(int headerId, @Nonnull byte[] data) throws IOException {
Preconditions.checkArgument(headerId == ALIGNMENT_ZIP_EXTRA_DATA_FIELD_HEADER_ID);
ByteBuffer dataBuffer = ByteBuffer.wrap(data);
@@ -373,7 +371,7 @@ public class ExtraField {
}
@Override
- public void write(@NonNull ByteBuffer out) throws IOException {
+ public void write(@Nonnull ByteBuffer out) throws IOException {
LittleEndianUtils.writeUnsigned2Le(out, ALIGNMENT_ZIP_EXTRA_DATA_FIELD_HEADER_ID);
LittleEndianUtils.writeUnsigned2Le(out, mPadding + 2);
LittleEndianUtils.writeUnsigned2Le(out, mAlignment);
diff --git a/src/main/java/com/android/apkzlib/zip/FileUseMap.java b/src/main/java/com/android/apkzlib/zip/FileUseMap.java
index 7d1ca86..2070aad 100644
--- a/src/main/java/com/android/apkzlib/zip/FileUseMap.java
+++ b/src/main/java/com/android/apkzlib/zip/FileUseMap.java
@@ -16,8 +16,6 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.Lists;
@@ -28,6 +26,8 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.StringJoiner;
import java.util.TreeSet;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* The file use map keeps track of which parts of the zip file are used which parts are not.
@@ -59,14 +59,14 @@ class FileUseMap {
* If {@link #mSize} is zero then this set is empty. This is the only situation in which the map
* will be empty.
*/
- @NonNull
+ @Nonnull
private TreeSet<FileUseMapEntry<?>> mMap;
/**
* Tree with all free blocks ordered by size. This is essentially a view over {@link #mMap}
* containing only the free blocks, but in a different order.
*/
- @NonNull
+ @Nonnull
private TreeSet<FileUseMapEntry<?>> mFree;
/**
@@ -99,7 +99,7 @@ class FileUseMap {
*
* @param entry the entry to add
*/
- private void internalAdd(@NonNull FileUseMapEntry<?> entry) {
+ private void internalAdd(@Nonnull FileUseMapEntry<?> entry) {
mMap.add(entry);
if (entry.isFree()) {
@@ -112,7 +112,7 @@ class FileUseMap {
*
* @param entry the entry to remove
*/
- private void internalRemove(@NonNull FileUseMapEntry<?> entry) {
+ private void internalRemove(@Nonnull FileUseMapEntry<?> entry) {
boolean wasRemoved = mMap.remove(entry);
Preconditions.checkState(wasRemoved, "entry not in mMap");
@@ -128,7 +128,7 @@ class FileUseMap {
*
* @param entry the entry to add
*/
- private void add(@NonNull FileUseMapEntry<?> entry) {
+ private void add(@Nonnull FileUseMapEntry<?> entry) {
Preconditions.checkArgument(entry.getStart() < mSize, "entry.getStart() >= mSize");
Preconditions.checkArgument(entry.getEnd() <= mSize, "entry.getEnd() > mSize");
Preconditions.checkArgument(!entry.isFree(), "entry.isFree()");
@@ -149,7 +149,7 @@ class FileUseMap {
*
* @param entry the entry
*/
- void remove(@NonNull FileUseMapEntry<?> entry) {
+ void remove(@Nonnull FileUseMapEntry<?> entry) {
Preconditions.checkState(mMap.contains(entry), "!mMap.contains(entry)");
Preconditions.checkArgument(!entry.isFree(), "entry.isFree()");
@@ -174,7 +174,7 @@ class FileUseMap {
* @param <T> the type of data to store in the entry
* @return the new entry
*/
- <T> FileUseMapEntry<T> add(long start, long end, @NonNull T store) {
+ <T> FileUseMapEntry<T> add(long start, long end, @Nonnull T store) {
Preconditions.checkArgument(start >= 0, "start < 0");
Preconditions.checkArgument(end > start, "end < start");
@@ -189,8 +189,8 @@ class FileUseMap {
* @param entry the entry whose container we're looking for
* @return the container
*/
- @NonNull
- private FileUseMapEntry<?> findContainer(@NonNull FileUseMapEntry<?> entry) {
+ @Nonnull
+ private FileUseMapEntry<?> findContainer(@Nonnull FileUseMapEntry<?> entry) {
FileUseMapEntry container = mMap.floor(entry);
Verify.verifyNotNull(container);
Verify.verify(container.getStart() <= entry.getStart());
@@ -209,9 +209,9 @@ class FileUseMap {
* @return a set of non-overlapping entries that completely covers {@code container} and that
* includes {@code entry}
*/
- @NonNull
- private static Set<FileUseMapEntry<?>> split(@NonNull FileUseMapEntry<?> container,
- @NonNull FileUseMapEntry<?> entry) {
+ @Nonnull
+ private static Set<FileUseMapEntry<?>> split(@Nonnull FileUseMapEntry<?> container,
+ @Nonnull FileUseMapEntry<?> entry) {
Preconditions.checkArgument(container.isFree(), "!container.isFree()");
long farStart = container.getStart();
@@ -243,7 +243,7 @@ class FileUseMap {
*
* @param entry the free entry to coalesce with neighbors
*/
- private void coalesce(@NonNull FileUseMapEntry<?> entry) {
+ private void coalesce(@Nonnull FileUseMapEntry<?> entry) {
Preconditions.checkArgument(entry.isFree(), "!entry.isFree()");
FileUseMapEntry<?> prevToMerge = null;
@@ -381,7 +381,7 @@ class FileUseMap {
* @param alg which algorithm to use
* @return the location of the contiguous area; this may be located at the end of the map
*/
- long locateFree(long size, long alignOffset, long align, @NonNull PositionAlgorithm alg) {
+ long locateFree(long size, long alignOffset, long align, @Nonnull PositionAlgorithm alg) {
Preconditions.checkArgument(size > 0, "size <= 0");
FileUseMapEntry<?> minimumSizedEntry = FileUseMapEntry.makeFree(0, size);
@@ -511,7 +511,7 @@ class FileUseMap {
* in file order, that is, if area {@code x} starts before area {@code y}, then area {@code x}
* will be stored before area {@code y} in the list
*/
- @NonNull
+ @Nonnull
List<FileUseMapEntry<?>> getFreeAreas() {
List<FileUseMapEntry<?>> freeAreas = Lists.newArrayList();
@@ -532,7 +532,7 @@ class FileUseMap {
* in the map
*/
@Nullable
- FileUseMapEntry<?> before(@NonNull FileUseMapEntry<?> entry) {
+ FileUseMapEntry<?> before(@Nonnull FileUseMapEntry<?> entry) {
Preconditions.checkNotNull(entry, "entry == null");
return mMap.lower(entry);
diff --git a/src/main/java/com/android/apkzlib/zip/FileUseMapEntry.java b/src/main/java/com/android/apkzlib/zip/FileUseMapEntry.java
index e041ae5..bc68a89 100644
--- a/src/main/java/com/android/apkzlib/zip/FileUseMapEntry.java
+++ b/src/main/java/com/android/apkzlib/zip/FileUseMapEntry.java
@@ -16,13 +16,12 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
-
import java.util.Comparator;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Represents an entry in the {@link FileUseMap}. Each entry contains an interval of bytes. The
@@ -100,7 +99,7 @@ class FileUseMapEntry<T> {
* @param <T> the type of data to store in the entry
* @return the entry
*/
- public static <T> FileUseMapEntry<T> makeUsed(long start, long end, @NonNull T store) {
+ public static <T> FileUseMapEntry<T> makeUsed(long start, long end, @Nonnull T store) {
Preconditions.checkNotNull(store, "store == null");
return new FileUseMapEntry<>(start, end, store);
}
diff --git a/src/main/java/com/android/apkzlib/zip/GPFlags.java b/src/main/java/com/android/apkzlib/zip/GPFlags.java
index 40965e8..356eb70 100644
--- a/src/main/java/com/android/apkzlib/zip/GPFlags.java
+++ b/src/main/java/com/android/apkzlib/zip/GPFlags.java
@@ -16,9 +16,8 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
-
import java.io.IOException;
+import javax.annotation.Nonnull;
/**
* General purpose bit flags. Contains the encoding of the zip's general purpose bits.
@@ -128,7 +127,7 @@ class GPFlags {
* @param utf8Encoding should UTF-8 encoding be used?
* @return the new bit mask
*/
- @NonNull
+ @Nonnull
static GPFlags make(boolean utf8Encoding) {
long flags = 0;
@@ -147,7 +146,7 @@ class GPFlags {
* @return the created flag information
* @throws IOException unsupported options are used in the bit mask
*/
- @NonNull
+ @Nonnull
static GPFlags from(long bits) throws IOException {
if ((bits & BIT_ENCRYPTION) != 0) {
throw new IOException("Zip files with encrypted of entries not supported.");
diff --git a/src/main/java/com/android/apkzlib/zip/InflaterByteSource.java b/src/main/java/com/android/apkzlib/zip/InflaterByteSource.java
index 8fcf783..cd1cd36 100644
--- a/src/main/java/com/android/apkzlib/zip/InflaterByteSource.java
+++ b/src/main/java/com/android/apkzlib/zip/InflaterByteSource.java
@@ -16,15 +16,14 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.utils.CloseableByteSource;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
+import javax.annotation.Nonnull;
/**
* Byte source that inflates another byte source. It assumed the inner byte source has deflated
@@ -35,14 +34,14 @@ public class InflaterByteSource extends CloseableByteSource {
/**
* The stream factory for the deflated data.
*/
- @NonNull
+ @Nonnull
private final CloseableByteSource mDeflatedSource;
/**
* Creates a new source.
* @param byteSource the factory for deflated data
*/
- public InflaterByteSource(@NonNull CloseableByteSource byteSource) {
+ public InflaterByteSource(@Nonnull CloseableByteSource byteSource) {
mDeflatedSource = byteSource;
}
diff --git a/src/main/java/com/android/apkzlib/zip/LazyDelegateByteSource.java b/src/main/java/com/android/apkzlib/zip/LazyDelegateByteSource.java
index bf1b46b..ebabad7 100644
--- a/src/main/java/com/android/apkzlib/zip/LazyDelegateByteSource.java
+++ b/src/main/java/com/android/apkzlib/zip/LazyDelegateByteSource.java
@@ -17,7 +17,6 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.utils.CloseableByteSource;
import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
@@ -26,12 +25,12 @@ import com.google.common.io.ByteSink;
import com.google.common.io.ByteSource;
import com.google.common.io.CharSource;
import com.google.common.util.concurrent.ListenableFuture;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
+import javax.annotation.Nonnull;
/**
* {@code ByteSource} that delegates all operations to another {@code ByteSource}. The other
@@ -42,14 +41,14 @@ public class LazyDelegateByteSource extends CloseableByteSource {
/**
* Byte source where we delegate operations to.
*/
- @NonNull
+ @Nonnull
private final ListenableFuture<CloseableByteSource> mDelegate;
/**
* Creates a new byte source that delegates operations to the provided source.
* @param delegate the source that will receive all operations
*/
- public LazyDelegateByteSource(@NonNull ListenableFuture<CloseableByteSource> delegate) {
+ public LazyDelegateByteSource(@Nonnull ListenableFuture<CloseableByteSource> delegate) {
mDelegate = delegate;
}
@@ -57,7 +56,7 @@ public class LazyDelegateByteSource extends CloseableByteSource {
* Obtains the delegate future.
* @return the delegate future, that may be computed or not
*/
- @NonNull
+ @Nonnull
public ListenableFuture<CloseableByteSource> getDelegate() {
return mDelegate;
}
@@ -67,7 +66,7 @@ public class LazyDelegateByteSource extends CloseableByteSource {
* @return the byte source
* @throws IOException failed to compute the future :)
*/
- @NonNull
+ @Nonnull
private CloseableByteSource get() throws IOException {
try {
CloseableByteSource r = mDelegate.get();
@@ -117,12 +116,12 @@ public class LazyDelegateByteSource extends CloseableByteSource {
}
@Override
- public long copyTo(@NonNull OutputStream output) throws IOException {
+ public long copyTo(@Nonnull OutputStream output) throws IOException {
return get().copyTo(output);
}
@Override
- public long copyTo(@NonNull ByteSink sink) throws IOException {
+ public long copyTo(@Nonnull ByteSink sink) throws IOException {
return get().copyTo(sink);
}
@@ -132,7 +131,7 @@ public class LazyDelegateByteSource extends CloseableByteSource {
}
@Override
- public <T> T read(@NonNull ByteProcessor<T> processor) throws IOException {
+ public <T> T read(@Nonnull ByteProcessor<T> processor) throws IOException {
return get().read(processor);
}
@@ -142,7 +141,7 @@ public class LazyDelegateByteSource extends CloseableByteSource {
}
@Override
- public boolean contentEquals(@NonNull ByteSource other) throws IOException {
+ public boolean contentEquals(@Nonnull ByteSource other) throws IOException {
return get().contentEquals(other);
}
diff --git a/src/main/java/com/android/apkzlib/zip/ProcessedAndRawByteSources.java b/src/main/java/com/android/apkzlib/zip/ProcessedAndRawByteSources.java
index f108419..acea3df 100644
--- a/src/main/java/com/android/apkzlib/zip/ProcessedAndRawByteSources.java
+++ b/src/main/java/com/android/apkzlib/zip/ProcessedAndRawByteSources.java
@@ -16,12 +16,11 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.utils.CloseableByteSource;
import com.google.common.io.Closer;
-
import java.io.Closeable;
import java.io.IOException;
+import javax.annotation.Nonnull;
/**
* Container that has two bytes sources: one representing raw data and another processed data.
@@ -34,13 +33,13 @@ public class ProcessedAndRawByteSources implements Closeable {
/**
* The processed byte source.
*/
- @NonNull
+ @Nonnull
private final CloseableByteSource mProcessedSource;
/**
* The processed raw source.
*/
- @NonNull
+ @Nonnull
private final CloseableByteSource mRawSource;
/**
@@ -48,8 +47,8 @@ public class ProcessedAndRawByteSources implements Closeable {
* @param processedSource the processed source
* @param rawSource the raw source
*/
- public ProcessedAndRawByteSources(@NonNull CloseableByteSource processedSource,
- @NonNull CloseableByteSource rawSource) {
+ public ProcessedAndRawByteSources(@Nonnull CloseableByteSource processedSource,
+ @Nonnull CloseableByteSource rawSource) {
mProcessedSource = processedSource;
mRawSource = rawSource;
}
@@ -58,7 +57,7 @@ public class ProcessedAndRawByteSources implements Closeable {
* Obtains a byte source that read the processed contents of the entry.
* @return a byte source
*/
- @NonNull
+ @Nonnull
public CloseableByteSource getProcessedByteSource() {
return mProcessedSource;
}
@@ -69,7 +68,7 @@ public class ProcessedAndRawByteSources implements Closeable {
* source returned by {@link #getProcessedByteSource()}.
* @return a byte source
*/
- @NonNull
+ @Nonnull
public CloseableByteSource getRawByteSource() {
return mRawSource;
}
diff --git a/src/main/java/com/android/apkzlib/zip/StoredEntry.java b/src/main/java/com/android/apkzlib/zip/StoredEntry.java
index 3057e3c..83b9ca3 100644
--- a/src/main/java/com/android/apkzlib/zip/StoredEntry.java
+++ b/src/main/java/com/android/apkzlib/zip/StoredEntry.java
@@ -16,8 +16,6 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.zip.utils.CloseableByteSource;
import com.android.apkzlib.zip.utils.CloseableDelegateByteSource;
import com.google.common.base.Preconditions;
@@ -25,11 +23,12 @@ import com.google.common.base.Verify;
import com.google.common.io.ByteSource;
import com.google.common.io.ByteStreams;
import com.google.common.primitives.Ints;
-
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Comparator;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* A stored entry represents a file in the zip. The entry may or may not be written to the zip
@@ -152,19 +151,19 @@ public class StoredEntry {
/**
* Type of entry.
*/
- @NonNull
+ @Nonnull
private StoredEntryType mType;
/**
* The central directory header with information about the file.
*/
- @NonNull
+ @Nonnull
private CentralDirectoryHeader mCdh;
/**
* The file this entry is associated with
*/
- @NonNull
+ @Nonnull
private ZFile mFile;
/**
@@ -175,20 +174,20 @@ public class StoredEntry {
/**
* Extra field specified in the local directory.
*/
- @NonNull
+ @Nonnull
private ExtraField mLocalExtra;
/**
* Type of data descriptor associated with the entry.
*/
- @NonNull
+ @Nonnull
private DataDescriptorType mDataDescriptorType;
/**
* Source for this entry's data. If this entry is a directory, this source has to have zero
* size.
*/
- @NonNull
+ @Nonnull
private ProcessedAndRawByteSources mSource;
/**
@@ -201,7 +200,7 @@ public class StoredEntry {
* read from the zip file, that is, if {@code header.getOffset()} is non-negative
* @throws IOException failed to create the entry
*/
- StoredEntry(@NonNull CentralDirectoryHeader header, @NonNull ZFile file,
+ StoredEntry(@Nonnull CentralDirectoryHeader header, @Nonnull ZFile file,
@Nullable ProcessedAndRawByteSources source) throws IOException {
mCdh = header;
mFile = file;
@@ -210,7 +209,7 @@ public class StoredEntry {
if (header.getOffset() >= 0) {
/*
* This will be overwritten during readLocalHeader. However, IJ complains if we don't
- * assign a value to mLocalExtra because of the @NonNull annotation.
+ * assign a value to mLocalExtra because of the @Nonnull annotation.
*/
mLocalExtra = new ExtraField();
@@ -311,7 +310,7 @@ public class StoredEntry {
* @return a stream that will return as many bytes as the uncompressed entry size
* @throws IOException failed to open the stream
*/
- @NonNull
+ @Nonnull
public InputStream open() throws IOException {
return mSource.getProcessedByteSource().openStream();
}
@@ -322,7 +321,7 @@ public class StoredEntry {
* @return a byte array with the contents of the file (uncompressed if the file was compressed)
* @throws IOException failed to read the file
*/
- @NonNull
+ @Nonnull
public byte[] read() throws IOException {
try (InputStream is = open()) {
return ByteStreams.toByteArray(is);
@@ -334,7 +333,7 @@ public class StoredEntry {
*
* @return the type of entry
*/
- @NonNull
+ @Nonnull
public StoredEntryType getType() {
Preconditions.checkState(!mDeleted, "mDeleted");
return mType;
@@ -370,7 +369,7 @@ public class StoredEntry {
*
* @return the CDH
*/
- @NonNull
+ @Nonnull
public CentralDirectoryHeader getCentralDirectoryHeader() {
return mCdh;
}
@@ -487,7 +486,7 @@ public class StoredEntry {
* @throws IOException failed to close the old source
* @return the created source
*/
- @NonNull
+ @Nonnull
private ProcessedAndRawByteSources createSourceFromZip(final long zipOffset)
throws IOException {
Preconditions.checkArgument(zipOffset >= 0, "zipOffset < 0");
@@ -509,7 +508,7 @@ public class StoredEntry {
return compressInfo.getCompressedSize();
}
- @NonNull
+ @Nonnull
@Override
public InputStream openStream() throws IOException {
Preconditions.checkState(!mDeleted, "mDeleted");
@@ -540,9 +539,9 @@ public class StoredEntry {
* @param rawContents the raw data to create the source from
* @return the sources for this entry
*/
- @NonNull
+ @Nonnull
private ProcessedAndRawByteSources createSourcesFromRawContents(
- @NonNull CloseableByteSource rawContents) {
+ @Nonnull CloseableByteSource rawContents) {
CentralDirectoryHeaderCompressInfo compressInfo;
try {
compressInfo = mCdh.getCompressionInfoWithWait();
@@ -613,7 +612,7 @@ public class StoredEntry {
*
* @return the entry source
*/
- @NonNull
+ @Nonnull
ProcessedAndRawByteSources getSource() {
return mSource;
}
@@ -623,7 +622,7 @@ public class StoredEntry {
*
* @return the type of data descriptor
*/
- @NonNull
+ @Nonnull
public DataDescriptorType getDataDescriptorType() {
return mDataDescriptorType;
}
@@ -634,7 +633,7 @@ public class StoredEntry {
* @return the header data
* @throws IOException failed to get header byte data
*/
- @NonNull
+ @Nonnull
byte[] toHeaderData() throws IOException {
byte[] encodedFileName = mCdh.getEncodedFileName();
@@ -693,7 +692,7 @@ public class StoredEntry {
*
* @return the contents of the local extra field
*/
- @NonNull
+ @Nonnull
public ExtraField getLocalExtra() {
return mLocalExtra;
}
@@ -704,7 +703,7 @@ public class StoredEntry {
* @param localExtra the contents of the local extra field
* @throws IOException failed to update the zip file
*/
- public void setLocalExtra(@NonNull ExtraField localExtra) throws IOException {
+ public void setLocalExtra(@Nonnull ExtraField localExtra) throws IOException {
boolean resized = setLocalExtraNoNotify(localExtra);
mFile.localHeaderChanged(this, resized);
}
@@ -718,7 +717,7 @@ public class StoredEntry {
* @return has the local header size changed?
* @throws IOException failed to load the file
*/
- boolean setLocalExtraNoNotify(@NonNull ExtraField localExtra) throws IOException {
+ boolean setLocalExtraNoNotify(@Nonnull ExtraField localExtra) throws IOException {
boolean sizeChanged;
/*
diff --git a/src/main/java/com/android/apkzlib/zip/ZFile.java b/src/main/java/com/android/apkzlib/zip/ZFile.java
index abba7ce..e8798a5 100644
--- a/src/main/java/com/android/apkzlib/zip/ZFile.java
+++ b/src/main/java/com/android/apkzlib/zip/ZFile.java
@@ -16,8 +16,6 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.utils.CachedFileContents;
import com.android.apkzlib.utils.IOExceptionFunction;
import com.android.apkzlib.utils.IOExceptionRunnable;
@@ -60,6 +58,8 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Function;
import java.util.function.Predicate;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* The {@code ZFile} provides the main interface for interacting with zip files. A {@code ZFile}
@@ -232,7 +232,7 @@ public class ZFile implements Closeable {
/**
* File zip file.
*/
- @NonNull
+ @Nonnull
private final File mFile;
/**
@@ -246,7 +246,7 @@ public class ZFile implements Closeable {
* The map containing the in-memory contents of the zip file. It keeps track of which parts of
* the zip file are used and which are not.
*/
- @NonNull
+ @Nonnull
private final FileUseMap mMap;
/**
@@ -268,7 +268,7 @@ public class ZFile implements Closeable {
* All entries in the zip file. It includes in-memory changes and may not reflect what is
* written on disk. Only entries that have been compressed are in this list.
*/
- @NonNull
+ @Nonnull
private final Map<String, FileUseMapEntry<StoredEntry>> mEntries;
/**
@@ -285,13 +285,13 @@ public class ZFile implements Closeable {
* <p>Moving files out of this list to {@link #mEntries} is done by
* {@link #processAllReadyEntries()}.
*/
- @NonNull
+ @Nonnull
private final List<StoredEntry> mUncompressedEntries;
/**
* Current state of the zip file.
*/
- @NonNull
+ @Nonnull
private ZipFileState mState;
/**
@@ -310,13 +310,13 @@ public class ZFile implements Closeable {
/**
* The alignment rule.
*/
- @NonNull
+ @Nonnull
private final AlignmentRule mAlignmentRule;
/**
* Extensions registered with the file.
*/
- @NonNull
+ @Nonnull
private final List<ZFileExtension> mExtensions;
/**
@@ -324,7 +324,7 @@ public class ZFile implements Closeable {
* list collects all runnables by the order they were requested. Together with
* {@link #mIsNotifying}, it is used to avoid reordering notifications.
*/
- @NonNull
+ @Nonnull
private final List<IOExceptionRunnable> mToRun;
/**
@@ -347,13 +347,13 @@ public class ZFile implements Closeable {
/**
* Compressor to use.
*/
- @NonNull
+ @Nonnull
private Compressor mCompressor;
/**
* Byte tracker to use.
*/
- @NonNull
+ @Nonnull
private final ByteTracker mTracker;
/**
@@ -382,7 +382,7 @@ public class ZFile implements Closeable {
* @param file the zip file
* @throws IOException some file exists but could not be read
*/
- public ZFile(@NonNull File file) throws IOException {
+ public ZFile(@Nonnull File file) throws IOException {
this(file, new ZFileOptions());
}
@@ -396,7 +396,7 @@ public class ZFile implements Closeable {
* @param options configuration options
* @throws IOException some file exists but could not be read
*/
- public ZFile(@NonNull File file, @NonNull ZFileOptions options) throws IOException {
+ public ZFile(@Nonnull File file, @Nonnull ZFileOptions options) throws IOException {
mFile = file;
mMap = new FileUseMap(
0,
@@ -454,7 +454,7 @@ public class ZFile implements Closeable {
*
* @return all entries in the zip
*/
- @NonNull
+ @Nonnull
public Set<StoredEntry> entries() {
Map<String, StoredEntry> entries = Maps.newHashMap();
@@ -482,7 +482,7 @@ public class ZFile implements Closeable {
* @return the entry at the path or {@code null} if none exists
*/
@Nullable
- public StoredEntry get(@NonNull String path) {
+ public StoredEntry get(@Nonnull String path) {
/*
* The latest entries are the last ones in uncompressed and they may eventually override
* files in mEntries.
@@ -726,7 +726,7 @@ public class ZFile implements Closeable {
* returned <em>as is</em>
* @throws IOException failed to open the zip file
*/
- @NonNull
+ @Nonnull
public InputStream directOpen(final long start, final long end) throws IOException {
Preconditions.checkState(mState != ZipFileState.CLOSED, "mState == ZipFileState.CLOSED");
Preconditions.checkState(mRaf != null, "mRaf == null");
@@ -754,7 +754,7 @@ public class ZFile implements Closeable {
}
@Override
- public int read(@NonNull byte[] b, int off, int len) throws IOException {
+ public int read(@Nonnull byte[] b, int off, int len) throws IOException {
Preconditions.checkNotNull(b, "b == null");
Preconditions.checkArgument(off >= 0, "off < 0");
Preconditions.checkArgument(off <= b.length, "off > b.length");
@@ -791,7 +791,7 @@ public class ZFile implements Closeable {
* {@code false} if the entry is being removed as part of a replacement
* @throws IOException failed to delete the entry
*/
- void delete(@NonNull final StoredEntry entry, boolean notify) throws IOException {
+ void delete(@Nonnull final StoredEntry entry, boolean notify) throws IOException {
String path = entry.getCentralDirectoryHeader().getName();
FileUseMapEntry<StoredEntry> mapEntry = mEntries.get(path);
Preconditions.checkNotNull(mapEntry, "mapEntry == null");
@@ -1052,7 +1052,7 @@ public class ZFile implements Closeable {
* @param positionHint hint to where the file should be positioned when re-adding
* @throws IOException failed to load the entry into memory
*/
- private void reAdd(@NonNull StoredEntry entry, @NonNull PositionHint positionHint)
+ private void reAdd(@Nonnull StoredEntry entry, @Nonnull PositionHint positionHint)
throws IOException {
String name = entry.getCentralDirectoryHeader().getName();
FileUseMapEntry<StoredEntry> mapEntry = mEntries.get(name);
@@ -1076,7 +1076,7 @@ public class ZFile implements Closeable {
* @param resized was the local header resized?
* @throws IOException failed to load the entry into memory
*/
- void localHeaderChanged(@NonNull StoredEntry entry, boolean resized) throws IOException {
+ void localHeaderChanged(@Nonnull StoredEntry entry, boolean resized) throws IOException {
mDirty = true;
if (resized) {
@@ -1134,7 +1134,7 @@ public class ZFile implements Closeable {
* @param offset the offset at which the entry should be written
* @throws IOException failed to write the entry
*/
- private void writeEntry(@NonNull StoredEntry entry, long offset) throws IOException {
+ private void writeEntry(@Nonnull StoredEntry entry, long offset) throws IOException {
Preconditions.checkArgument(entry.getDataDescriptorType()
== DataDescriptorType. NO_DATA_DESCRIPTOR, "Cannot write entries with a data "
+ "descriptor.");
@@ -1249,7 +1249,7 @@ public class ZFile implements Closeable {
* @return the byte representation, or an empty array if there are no entries in the zip
* @throws IOException failed to compute the central directory byte representation
*/
- @NonNull
+ @Nonnull
public byte[] getCentralDirectoryBytes() throws IOException {
if (mEntries.isEmpty()) {
Preconditions.checkState(mDirectoryEntry == null, "mDirectoryEntry != null");
@@ -1333,7 +1333,7 @@ public class ZFile implements Closeable {
* @return the byte representation of the EOCD
* @throws IOException failed to obtain the byte representation of the EOCD
*/
- @NonNull
+ @Nonnull
public byte[] getEocdBytes() throws IOException {
Preconditions.checkNotNull(mEocdEntry, "mEocdEntry == null");
@@ -1429,7 +1429,7 @@ public class ZFile implements Closeable {
* @param stream the source for the file's data
* @throws IOException failed to read the source data
*/
- public void add(@NonNull String name, @NonNull InputStream stream) throws IOException {
+ public void add(@Nonnull String name, @Nonnull InputStream stream) throws IOException {
add(name, stream, true);
}
@@ -1443,10 +1443,10 @@ public class ZFile implements Closeable {
* @return the created entry
* @throws IOException failed to create the entry
*/
- @NonNull
+ @Nonnull
private StoredEntry makeStoredEntry(
- @NonNull String name,
- @NonNull InputStream stream,
+ @Nonnull String name,
+ @Nonnull InputStream stream,
boolean mayCompress)
throws IOException {
CloseableByteSource source = mTracker.fromStream(stream);
@@ -1489,12 +1489,12 @@ public class ZFile implements Closeable {
* @return the sources whose data may or may not be already defined
* @throws IOException failed to create the raw sources
*/
- @NonNull
+ @Nonnull
private ProcessedAndRawByteSources createSources(
boolean mayCompress,
- @NonNull CloseableByteSource source,
- @NonNull SettableFuture<CentralDirectoryHeaderCompressInfo> compressInfo,
- @NonNull CentralDirectoryHeader newFileData)
+ @Nonnull CloseableByteSource source,
+ @Nonnull SettableFuture<CentralDirectoryHeaderCompressInfo> compressInfo,
+ @Nonnull CentralDirectoryHeader newFileData)
throws IOException {
if (mayCompress) {
ListenableFuture<CompressionResult> result = mCompressor.compress(source);
@@ -1506,7 +1506,7 @@ public class ZFile implements Closeable {
}
@Override
- public void onFailure(@NonNull Throwable t) {
+ public void onFailure(@Nonnull Throwable t) {
compressInfo.setException(t);
}
});
@@ -1539,7 +1539,7 @@ public class ZFile implements Closeable {
* rules force the file to be aligned, in which case the file will not be compressed.
* @throws IOException failed to read the source data
*/
- public void add(@NonNull String name, @NonNull InputStream stream, boolean mayCompress)
+ public void add(@Nonnull String name, @Nonnull InputStream stream, boolean mayCompress)
throws IOException {
/*
@@ -1564,7 +1564,7 @@ public class ZFile implements Closeable {
* @throws IOException failed to process this entry (or a previous one whose future only
* completed now)
*/
- private void add(@NonNull final StoredEntry newEntry) throws IOException {
+ private void add(@Nonnull final StoredEntry newEntry) throws IOException {
mUncompressedEntries.add(newEntry);
processAllReadyEntries();
}
@@ -1641,7 +1641,7 @@ public class ZFile implements Closeable {
* @param newEntry the new entry to add
* @throws IOException failed to add the file
*/
- private void addToEntries(@NonNull final StoredEntry newEntry) throws IOException {
+ private void addToEntries(@Nonnull final StoredEntry newEntry) throws IOException {
Preconditions.checkArgument(newEntry.getDataDescriptorType() ==
DataDescriptorType.NO_DATA_DESCRIPTOR, "newEntry has data descriptor");
@@ -1685,10 +1685,10 @@ public class ZFile implements Closeable {
* @param positionHint hint to where the file should be positioned
* @return the position in the file where the entry should be placed
*/
- @NonNull
+ @Nonnull
private FileUseMapEntry<StoredEntry> positionInFile(
- @NonNull StoredEntry entry,
- @NonNull PositionHint positionHint)
+ @Nonnull StoredEntry entry,
+ @Nonnull PositionHint positionHint)
throws IOException {
deleteDirectoryAndEocd();
long size = entry.getInFileSize();
@@ -1725,7 +1725,7 @@ public class ZFile implements Closeable {
* required for the entry
* @throws IOException failed to determine the alignment
*/
- private int chooseAlignment(@NonNull StoredEntry entry) throws IOException {
+ private int chooseAlignment(@Nonnull StoredEntry entry) throws IOException {
CentralDirectoryHeader cdh = entry.getCentralDirectoryHeader();
CentralDirectoryHeaderCompressInfo compressionInfo = cdh.getCompressionInfoWithWait();
@@ -1751,7 +1751,7 @@ public class ZFile implements Closeable {
* should be ignored by merging; merging will behave as if these files were not there
* @throws IOException failed to read from <em>src</em> or write on the output
*/
- public void mergeFrom(@NonNull ZFile src, @NonNull Predicate<String> ignoreFilter)
+ public void mergeFrom(@Nonnull ZFile src, @Nonnull Predicate<String> ignoreFilter)
throws IOException {
for (StoredEntry fromEntry : src.entries()) {
if (ignoreFilter.test(fromEntry.getCentralDirectoryHeader().getName())) {
@@ -1890,7 +1890,7 @@ public class ZFile implements Closeable {
* @throws IOException failed to read/write an entry; the entry may no longer exist in the
* file
*/
- boolean realign(@NonNull StoredEntry entry) throws IOException {
+ boolean realign(@Nonnull StoredEntry entry) throws IOException {
FileUseMapEntry<StoredEntry> mapEntry =
mEntries.get(entry.getCentralDirectoryHeader().getName());
Verify.verify(entry == mapEntry.getStore());
@@ -1982,7 +1982,7 @@ public class ZFile implements Closeable {
*
* @param extension the listener to add
*/
- public void addZFileExtension(@NonNull ZFileExtension extension) {
+ public void addZFileExtension(@Nonnull ZFileExtension extension) {
mExtensions.add(extension);
}
@@ -1991,7 +1991,7 @@ public class ZFile implements Closeable {
*
* @param extension the listener to remove
*/
- public void removeZFileExtension(@NonNull ZFileExtension extension) {
+ public void removeZFileExtension(@Nonnull ZFileExtension extension) {
mExtensions.remove(extension);
}
@@ -2002,7 +2002,7 @@ public class ZFile implements Closeable {
* notification method on the listener and return the result of that invocation
* @throws IOException failed to process some extensions
*/
- private void notify(@NonNull IOExceptionFunction<ZFileExtension, IOExceptionRunnable> function)
+ private void notify(@Nonnull IOExceptionFunction<ZFileExtension, IOExceptionRunnable> function)
throws IOException {
for (ZFileExtension fl : Lists.newArrayList(mExtensions)) {
IOExceptionRunnable r = function.apply(fl);
@@ -2036,7 +2036,7 @@ public class ZFile implements Closeable {
* @param count number of bytes of data to write
* @throws IOException failed to write the data
*/
- public void directWrite(long offset, @NonNull byte[] data, int start, int count)
+ public void directWrite(long offset, @Nonnull byte[] data, int start, int count)
throws IOException {
Preconditions.checkArgument(offset >= 0, "offset < 0");
Preconditions.checkArgument(start >= 0, "start >= 0");
@@ -2063,7 +2063,7 @@ public class ZFile implements Closeable {
* @param data the data to write, may be an empty array
* @throws IOException failed to write the data
*/
- public void directWrite(long offset, @NonNull byte[] data) throws IOException {
+ public void directWrite(long offset, @Nonnull byte[] data) throws IOException {
directWrite(offset, data, 0, data.length);
}
@@ -2079,7 +2079,7 @@ public class ZFile implements Closeable {
* to be read
* @throws IOException failed to write the data
*/
- public int directRead(long offset, @NonNull byte[] data, int start, int count)
+ public int directRead(long offset, @Nonnull byte[] data, int start, int count)
throws IOException {
Preconditions.checkArgument(offset >= 0, "offset < 0");
Preconditions.checkArgument(start >= 0, "start >= 0");
@@ -2111,7 +2111,7 @@ public class ZFile implements Closeable {
* @param data receives the read data, may be an empty array
* @throws IOException failed to read the data
*/
- public int directRead(long offset, @NonNull byte[] data) throws IOException {
+ public int directRead(long offset, @Nonnull byte[] data) throws IOException {
return directRead(offset, data, 0, data.length);
}
@@ -2123,7 +2123,7 @@ public class ZFile implements Closeable {
* @param data the array that receives the data read
* @throws IOException failed to read some data or there is not enough data to read
*/
- public void directFullyRead(long offset, @NonNull byte[] data) throws IOException {
+ public void directFullyRead(long offset, @Nonnull byte[] data) throws IOException {
Preconditions.checkArgument(offset >= 0, "offset < 0");
Preconditions.checkNotNull(mRaf, "File is closed");
@@ -2141,7 +2141,7 @@ public class ZFile implements Closeable {
* added recursively
* @throws IOException failed to some (or all ) of the files
*/
- public void addAllRecursively(@NonNull File file) throws IOException {
+ public void addAllRecursively(@Nonnull File file) throws IOException {
addAllRecursively(file, f -> true);
}
@@ -2153,8 +2153,8 @@ public class ZFile implements Closeable {
* @param mayCompress a function that decides whether files may be compressed
* @throws IOException failed to some (or all ) of the files
*/
- public void addAllRecursively(@NonNull File file,
- @NonNull Function<? super File, Boolean> mayCompress) throws IOException {
+ public void addAllRecursively(@Nonnull File file,
+ @Nonnull Function<? super File, Boolean> mayCompress) throws IOException {
/*
* The case of file.isFile() is different because if file.isFile() we will add it to the
* zip in the root. However, if file.isDirectory() we won't add it and add its children.
@@ -2340,7 +2340,7 @@ public class ZFile implements Closeable {
* @return the file that may or may not exist (depending on whether something existed there
* before the zip was created and on whether the zip has been updated or not)
*/
- @NonNull
+ @Nonnull
public File getFile() {
return mFile;
}
diff --git a/src/main/java/com/android/apkzlib/zip/ZFileExtension.java b/src/main/java/com/android/apkzlib/zip/ZFileExtension.java
index fc9484d..fdb6ca4 100644
--- a/src/main/java/com/android/apkzlib/zip/ZFileExtension.java
+++ b/src/main/java/com/android/apkzlib/zip/ZFileExtension.java
@@ -16,11 +16,10 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-
import com.android.apkzlib.utils.IOExceptionRunnable;
import java.io.IOException;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* An extension of a {@link ZFile}. Extensions are notified when files are open, updated, closed and
@@ -127,7 +126,7 @@ public abstract class ZFileExtension {
* @return an optional runnable to run when notification of all listeners has ended
*/
@Nullable
- public IOExceptionRunnable added(@NonNull StoredEntry entry, @Nullable StoredEntry replaced) {
+ public IOExceptionRunnable added(@Nonnull StoredEntry entry, @Nullable StoredEntry replaced) {
return null;
}
@@ -141,7 +140,7 @@ public abstract class ZFileExtension {
* @return an optional runnable to run when notification of all listeners has ended
*/
@Nullable
- public IOExceptionRunnable removed(@NonNull StoredEntry entry) {
+ public IOExceptionRunnable removed(@Nonnull StoredEntry entry) {
return null;
}
}
diff --git a/src/main/java/com/android/apkzlib/zip/ZFileOptions.java b/src/main/java/com/android/apkzlib/zip/ZFileOptions.java
index 0e87046..cc523c5 100644
--- a/src/main/java/com/android/apkzlib/zip/ZFileOptions.java
+++ b/src/main/java/com/android/apkzlib/zip/ZFileOptions.java
@@ -16,10 +16,10 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.compress.DeflateExecutionCompressor;
import com.android.apkzlib.zip.utils.ByteTracker;
import java.util.zip.Deflater;
+import javax.annotation.Nonnull;
/**
* Options to create a {@link ZFile}.
@@ -29,13 +29,13 @@ public class ZFileOptions {
/**
* The byte tracker.
*/
- @NonNull
+ @Nonnull
private ByteTracker mTracker;
/**
* The compressor to use.
*/
- @NonNull
+ @Nonnull
private Compressor mCompressor;
/**
@@ -46,7 +46,7 @@ public class ZFileOptions {
/**
* The alignment rule to use.
*/
- @NonNull
+ @Nonnull
private AlignmentRule mAlignmentRule;
/**
@@ -83,7 +83,7 @@ public class ZFileOptions {
*
* @return the byte tracker
*/
- @NonNull
+ @Nonnull
public ByteTracker getTracker() {
return mTracker;
}
@@ -93,7 +93,7 @@ public class ZFileOptions {
*
* @return the compressor
*/
- @NonNull
+ @Nonnull
public Compressor getCompressor() {
return mCompressor;
}
@@ -103,7 +103,7 @@ public class ZFileOptions {
*
* @param compressor the compressor
*/
- public void setCompressor(@NonNull Compressor compressor) {
+ public void setCompressor(@Nonnull Compressor compressor) {
mCompressor = compressor;
}
@@ -130,7 +130,7 @@ public class ZFileOptions {
*
* @return the alignment rule
*/
- @NonNull
+ @Nonnull
public AlignmentRule getAlignmentRule() {
return mAlignmentRule;
}
@@ -140,7 +140,7 @@ public class ZFileOptions {
*
* @param alignmentRule the alignment rule
*/
- public void setAlignmentRule(@NonNull AlignmentRule alignmentRule) {
+ public void setAlignmentRule(@Nonnull AlignmentRule alignmentRule) {
mAlignmentRule = alignmentRule;
}
diff --git a/src/main/java/com/android/apkzlib/zip/ZipField.java b/src/main/java/com/android/apkzlib/zip/ZipField.java
index d6cbcca..3551e71 100644
--- a/src/main/java/com/android/apkzlib/zip/ZipField.java
+++ b/src/main/java/com/android/apkzlib/zip/ZipField.java
@@ -16,18 +16,17 @@
package com.android.apkzlib.zip;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.zip.utils.LittleEndianUtils;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.Sets;
import com.google.common.primitives.Ints;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Set;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* The ZipField class represents a field in a record in a zip file. Zip files are made with records
@@ -58,7 +57,7 @@ abstract class ZipField {
/**
* Field name. Used for providing (more) useful error messages.
*/
- @NonNull
+ @Nonnull
private final String mName;
/**
@@ -80,7 +79,7 @@ abstract class ZipField {
/**
* All invariants that this field must verify.
*/
- @NonNull
+ @Nonnull
private Set<ZipFieldInvariant> mInvariants;
/**
@@ -91,7 +90,7 @@ abstract class ZipField {
* @param name the field's name
* @param invariants the invariants that must be verified by the field
*/
- ZipField(int offset, int size, @NonNull String name, ZipFieldInvariant... invariants) {
+ ZipField(int offset, int size, @Nonnull String name, ZipFieldInvariant... invariants) {
Preconditions.checkArgument(offset >= 0, "offset >= 0");
Preconditions.checkArgument(size == 2 || size == 4, "size != 2 && size != 4");
@@ -110,7 +109,7 @@ abstract class ZipField {
* @param expected the expected field value
* @param name the field's name
*/
- ZipField(int offset, int size, long expected, @NonNull String name) {
+ ZipField(int offset, int size, long expected, @Nonnull String name) {
Preconditions.checkArgument(offset >= 0, "offset >= 0");
Preconditions.checkArgument(size == 2 || size == 4, "size != 2 && size != 4");
@@ -144,7 +143,7 @@ abstract class ZipField {
* the size of this field
* @throws IOException failed to advance the buffer
*/
- void skip(@NonNull ByteBuffer bytes) throws IOException {
+ void skip(@Nonnull ByteBuffer bytes) throws IOException {
if (bytes.remaining() < mSize) {
throw new IOException("Cannot skip field " + mName + " because only "
+ bytes.remaining() + " remain in the buffer.");
@@ -161,7 +160,7 @@ abstract class ZipField {
* @return the value of the field
* @throws IOException failed to read the field
*/
- long read(@NonNull ByteBuffer bytes) throws IOException {
+ long read(@Nonnull ByteBuffer bytes) throws IOException {
if (bytes.remaining() < mSize) {
throw new IOException("Cannot skip field " + mName + " because only "
+ bytes.remaining() + " remain in the buffer.");
@@ -188,7 +187,7 @@ abstract class ZipField {
* will be positioned at the first byte after the field
* @throws IOException failed to read the field or the field does not have the expected value
*/
- void verify(@NonNull ByteBuffer bytes) throws IOException {
+ void verify(@Nonnull ByteBuffer bytes) throws IOException {
Preconditions.checkState(mExpected != null, "mExpected == null");
verify(bytes, mExpected);
}
@@ -202,7 +201,7 @@ abstract class ZipField {
* value must verify them
* @throws IOException failed to read the data or the field does not have the expected value
*/
- void verify(@NonNull ByteBuffer bytes, long expected) throws IOException {
+ void verify(@Nonnull ByteBuffer bytes, long expected) throws IOException {
checkVerifiesInvariants(expected);
long r = read(bytes);
if (r != expected) {
@@ -219,7 +218,7 @@ abstract class ZipField {
* @param value the value to write
* @throws IOException failed to write the value in the stream
*/
- void write(@NonNull ByteBuffer output, long value) throws IOException {
+ void write(@Nonnull ByteBuffer output, long value) throws IOException {
checkVerifiesInvariants(value);
Preconditions.checkArgument(value >= 0, "value (%s) < 0", value);
@@ -242,7 +241,7 @@ abstract class ZipField {
* of the buffer
* @throws IOException failed to write the value in the stream
*/
- void write(@NonNull ByteBuffer output) throws IOException {
+ void write(@Nonnull ByteBuffer output) throws IOException {
Preconditions.checkState(mExpected != null, "mExpected == null");
write(output, mExpected);
}
@@ -269,7 +268,7 @@ abstract class ZipField {
* @param name the field's name
* @param invariants the invariants that must be verified by the field
*/
- F2(int offset, @NonNull String name, ZipFieldInvariant... invariants) {
+ F2(int offset, @Nonnull String name, ZipFieldInvariant... invariants) {
super(offset, 2, name, invariants);
}
@@ -280,7 +279,7 @@ abstract class ZipField {
* @param expected the expected field value
* @param name the field's name
*/
- F2(int offset, long expected, @NonNull String name) {
+ F2(int offset, long expected, @Nonnull String name) {
super(offset, 2, expected, name);
}
}
@@ -296,7 +295,7 @@ abstract class ZipField {
* @param name the field's name
* @param invariants the invariants that must be verified by the field
*/
- F4(int offset, @NonNull String name, ZipFieldInvariant... invariants) {
+ F4(int offset, @Nonnull String name, ZipFieldInvariant... invariants) {
super(offset, 4, name, invariants);
}
@@ -307,7 +306,7 @@ abstract class ZipField {
* @param expected the expected field value
* @param name the field's name
*/
- F4(int offset, long expected, @NonNull String name) {
+ F4(int offset, long expected, @Nonnull String name) {
super(offset, 4, expected, name);
}
}
diff --git a/src/main/java/com/android/apkzlib/zip/compress/BestAndDefaultDeflateExecutorCompressor.java b/src/main/java/com/android/apkzlib/zip/compress/BestAndDefaultDeflateExecutorCompressor.java
index fe19765..20ef477 100644
--- a/src/main/java/com/android/apkzlib/zip/compress/BestAndDefaultDeflateExecutorCompressor.java
+++ b/src/main/java/com/android/apkzlib/zip/compress/BestAndDefaultDeflateExecutorCompressor.java
@@ -16,14 +16,13 @@
package com.android.apkzlib.zip.compress;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.CompressionResult;
import com.android.apkzlib.zip.utils.ByteTracker;
import com.android.apkzlib.zip.utils.CloseableByteSource;
import com.google.common.base.Preconditions;
-
import java.util.concurrent.Executor;
import java.util.zip.Deflater;
+import javax.annotation.Nonnull;
/**
* Compressor that tries both the best and default compression algorithms and picks the default
@@ -34,13 +33,13 @@ public class BestAndDefaultDeflateExecutorCompressor extends ExecutorCompressor
/**
* Deflater using the default compression level.
*/
- @NonNull
+ @Nonnull
private final DeflateExecutionCompressor mDefaultDeflater;
/**
* Deflater using the best compression level.
*/
- @NonNull
+ @Nonnull
private final DeflateExecutionCompressor mBestDeflater;
/**
@@ -59,8 +58,8 @@ public class BestAndDefaultDeflateExecutorCompressor extends ExecutorCompressor
* if {@code 1.0} then the best compression is always picked unless it produces the exact same
* size as the default compression.
*/
- public BestAndDefaultDeflateExecutorCompressor(@NonNull Executor executor,
- @NonNull ByteTracker tracker, double minRatio) {
+ public BestAndDefaultDeflateExecutorCompressor(@Nonnull Executor executor,
+ @Nonnull ByteTracker tracker, double minRatio) {
super(executor);
Preconditions.checkArgument(minRatio >= 0.0, "minRatio < 0.0");
@@ -73,9 +72,9 @@ public class BestAndDefaultDeflateExecutorCompressor extends ExecutorCompressor
mMinRatio = minRatio;
}
- @NonNull
+ @Nonnull
@Override
- protected CompressionResult immediateCompress(@NonNull CloseableByteSource source)
+ protected CompressionResult immediateCompress(@Nonnull CloseableByteSource source)
throws Exception {
CompressionResult defaultResult = mDefaultDeflater.immediateCompress(source);
CompressionResult bestResult = mBestDeflater.immediateCompress(source);
diff --git a/src/main/java/com/android/apkzlib/zip/compress/DeflateExecutionCompressor.java b/src/main/java/com/android/apkzlib/zip/compress/DeflateExecutionCompressor.java
index 7eaba11..b7e87f4 100644
--- a/src/main/java/com/android/apkzlib/zip/compress/DeflateExecutionCompressor.java
+++ b/src/main/java/com/android/apkzlib/zip/compress/DeflateExecutionCompressor.java
@@ -16,16 +16,15 @@
package com.android.apkzlib.zip.compress;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.CompressionMethod;
import com.android.apkzlib.zip.CompressionResult;
import com.android.apkzlib.zip.utils.ByteTracker;
import com.android.apkzlib.zip.utils.CloseableByteSource;
-
import java.io.ByteArrayOutputStream;
import java.util.concurrent.Executor;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
+import javax.annotation.Nonnull;
/**
* Compressor that uses deflate with an executor.
@@ -41,7 +40,7 @@ public class DeflateExecutionCompressor extends ExecutorCompressor {
/**
* Byte tracker to use to create byte sources.
*/
- @NonNull
+ @Nonnull
private final ByteTracker mTracker;
/**
@@ -51,7 +50,7 @@ public class DeflateExecutionCompressor extends ExecutorCompressor {
* @param tracker the byte tracker to use to keep track of memory usage
* @param level the compression level
*/
- public DeflateExecutionCompressor(@NonNull Executor executor, @NonNull ByteTracker tracker,
+ public DeflateExecutionCompressor(@Nonnull Executor executor, @Nonnull ByteTracker tracker,
int level) {
super(executor);
@@ -59,9 +58,9 @@ public class DeflateExecutionCompressor extends ExecutorCompressor {
mTracker = tracker;
}
- @NonNull
+ @Nonnull
@Override
- protected CompressionResult immediateCompress(@NonNull CloseableByteSource source)
+ protected CompressionResult immediateCompress(@Nonnull CloseableByteSource source)
throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
Deflater deflater = new Deflater(mLevel, true);
diff --git a/src/main/java/com/android/apkzlib/zip/compress/ExecutorCompressor.java b/src/main/java/com/android/apkzlib/zip/compress/ExecutorCompressor.java
index 955feb4..b136558 100644
--- a/src/main/java/com/android/apkzlib/zip/compress/ExecutorCompressor.java
+++ b/src/main/java/com/android/apkzlib/zip/compress/ExecutorCompressor.java
@@ -16,14 +16,13 @@
package com.android.apkzlib.zip.compress;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.CompressionResult;
import com.android.apkzlib.zip.Compressor;
import com.android.apkzlib.zip.utils.CloseableByteSource;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
-
import java.util.concurrent.Executor;
+import javax.annotation.Nonnull;
/**
* A synchronous compressor is a compressor that computes the result of compression immediately
@@ -34,21 +33,21 @@ public abstract class ExecutorCompressor implements Compressor {
/**
* The executor that does the work.
*/
- @NonNull
+ @Nonnull
private final Executor mExecutor;
/**
* Compressor that delegates execution into the given executor.
* @param executor the executor that will do the compress
*/
- public ExecutorCompressor(@NonNull Executor executor) {
+ public ExecutorCompressor(@Nonnull Executor executor) {
mExecutor = executor;
}
- @NonNull
+ @Nonnull
@Override
public ListenableFuture<CompressionResult> compress(
- @NonNull final CloseableByteSource source) {
+ @Nonnull final CloseableByteSource source) {
final SettableFuture<CompressionResult> future = SettableFuture.create();
mExecutor.execute(() -> {
try {
@@ -67,7 +66,7 @@ public abstract class ExecutorCompressor implements Compressor {
* @return the result of compression
* @throws Exception failed to compress
*/
- @NonNull
- protected abstract CompressionResult immediateCompress(@NonNull CloseableByteSource source)
+ @Nonnull
+ protected abstract CompressionResult immediateCompress(@Nonnull CloseableByteSource source)
throws Exception;
}
diff --git a/src/main/java/com/android/apkzlib/zip/utils/ByteTracker.java b/src/main/java/com/android/apkzlib/zip/utils/ByteTracker.java
index 922d759..6bad5f7 100644
--- a/src/main/java/com/android/apkzlib/zip/utils/ByteTracker.java
+++ b/src/main/java/com/android/apkzlib/zip/utils/ByteTracker.java
@@ -16,13 +16,12 @@
package com.android.apkzlib.zip.utils;
-import com.android.annotations.NonNull;
import com.google.common.io.ByteSource;
import com.google.common.io.ByteStreams;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import javax.annotation.Nonnull;
public class ByteTracker {
@@ -42,7 +41,7 @@ public class ByteTracker {
* @return a byte source containing the cached data from the given stream
* @throws IOException failed to read the stream
*/
- public CloseableDelegateByteSource fromStream(@NonNull InputStream stream) throws IOException {
+ public CloseableDelegateByteSource fromStream(@Nonnull InputStream stream) throws IOException {
byte[] data = ByteStreams.toByteArray(stream);
updateUsage(data.length);
return new CloseableDelegateByteSource(ByteSource.wrap(data), data.length) {
@@ -60,7 +59,7 @@ public class ByteTracker {
* @return a byte source containing the cached data from the given stream
* @throws IOException failed to read the stream
*/
- public CloseableDelegateByteSource fromStream(@NonNull ByteArrayOutputStream stream) throws IOException {
+ public CloseableDelegateByteSource fromStream(@Nonnull ByteArrayOutputStream stream) throws IOException {
byte[] data = stream.toByteArray();
updateUsage(data.length);
return new CloseableDelegateByteSource(ByteSource.wrap(data), data.length) {
@@ -78,7 +77,7 @@ public class ByteTracker {
* @return the tracked byte source
* @throws IOException failed to read data from the byte source
*/
- public CloseableDelegateByteSource fromSource(@NonNull ByteSource source) throws IOException {
+ public CloseableDelegateByteSource fromSource(@Nonnull ByteSource source) throws IOException {
return fromStream(source.openStream());
}
diff --git a/src/main/java/com/android/apkzlib/zip/utils/CloseableDelegateByteSource.java b/src/main/java/com/android/apkzlib/zip/utils/CloseableDelegateByteSource.java
index 9e24936..83873a3 100644
--- a/src/main/java/com/android/apkzlib/zip/utils/CloseableDelegateByteSource.java
+++ b/src/main/java/com/android/apkzlib/zip/utils/CloseableDelegateByteSource.java
@@ -16,19 +16,18 @@
package com.android.apkzlib.zip.utils;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.io.ByteProcessor;
import com.google.common.io.ByteSink;
import com.google.common.io.ByteSource;
import com.google.common.io.CharSource;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Closeable byte source that delegates to another byte source.
@@ -54,7 +53,7 @@ public class CloseableDelegateByteSource extends CloseableByteSource {
* @param inner the inner byte source
* @param size the size of the source
*/
- public CloseableDelegateByteSource(@NonNull ByteSource inner, long size) {
+ public CloseableDelegateByteSource(@Nonnull ByteSource inner, long size) {
mInner = inner;
mSize = size;
}
@@ -65,7 +64,7 @@ public class CloseableDelegateByteSource extends CloseableByteSource {
*
* @return the inner byte source
*/
- @NonNull
+ @Nonnull
private synchronized ByteSource get() {
if (mInner == null) {
throw new ByteSourceDisposedException();
@@ -122,12 +121,12 @@ public class CloseableDelegateByteSource extends CloseableByteSource {
}
@Override
- public long copyTo(@NonNull OutputStream output) throws IOException {
+ public long copyTo(@Nonnull OutputStream output) throws IOException {
return get().copyTo(output);
}
@Override
- public long copyTo(@NonNull ByteSink sink) throws IOException {
+ public long copyTo(@Nonnull ByteSink sink) throws IOException {
return get().copyTo(sink);
}
@@ -137,7 +136,7 @@ public class CloseableDelegateByteSource extends CloseableByteSource {
}
@Override
- public <T> T read(@NonNull ByteProcessor<T> processor) throws IOException {
+ public <T> T read(@Nonnull ByteProcessor<T> processor) throws IOException {
return get().read(processor);
}
@@ -147,7 +146,7 @@ public class CloseableDelegateByteSource extends CloseableByteSource {
}
@Override
- public boolean contentEquals(@NonNull ByteSource other) throws IOException {
+ public boolean contentEquals(@Nonnull ByteSource other) throws IOException {
return get().contentEquals(other);
}
diff --git a/src/main/java/com/android/apkzlib/zip/utils/LittleEndianUtils.java b/src/main/java/com/android/apkzlib/zip/utils/LittleEndianUtils.java
index 42ddd3f..c0f3588 100644
--- a/src/main/java/com/android/apkzlib/zip/utils/LittleEndianUtils.java
+++ b/src/main/java/com/android/apkzlib/zip/utils/LittleEndianUtils.java
@@ -16,13 +16,12 @@
package com.android.apkzlib.zip.utils;
-import com.android.annotations.NonNull;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
-
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
+import javax.annotation.Nonnull;
/**
* Utilities to read and write 16 and 32 bit integers with support for little-endian
@@ -44,7 +43,7 @@ public class LittleEndianUtils {
* @return the 32-bit value
* @throws IOException failed to read the value
*/
- public static long readUnsigned4Le(@NonNull ByteBuffer bytes) throws IOException {
+ public static long readUnsigned4Le(@Nonnull ByteBuffer bytes) throws IOException {
Preconditions.checkNotNull(bytes, "bytes == null");
if (bytes.remaining() < 4) {
@@ -70,7 +69,7 @@ public class LittleEndianUtils {
* @return the 16-bit value
* @throws IOException failed to read the value
*/
- public static int readUnsigned2Le(@NonNull ByteBuffer bytes) throws IOException {
+ public static int readUnsigned2Le(@Nonnull ByteBuffer bytes) throws IOException {
Preconditions.checkNotNull(bytes, "bytes == null");
if (bytes.remaining() < 2) {
@@ -94,7 +93,7 @@ public class LittleEndianUtils {
* @param value the 32-bit value to convert
* @throws IOException failed to write the value data
*/
- public static void writeUnsigned4Le(@NonNull ByteBuffer output, long value)
+ public static void writeUnsigned4Le(@Nonnull ByteBuffer output, long value)
throws IOException {
Preconditions.checkNotNull(output, "output == null");
Preconditions.checkArgument(value >= 0, "value (%s) < 0", value);
@@ -114,7 +113,7 @@ public class LittleEndianUtils {
* @param value the 16-bit value to convert
* @throws IOException failed to write the value data
*/
- public static void writeUnsigned2Le(@NonNull ByteBuffer output, int value)
+ public static void writeUnsigned2Le(@Nonnull ByteBuffer output, int value)
throws IOException {
Preconditions.checkNotNull(output, "output == null");
Preconditions.checkArgument(value >= 0, "value (%s) < 0", value);
diff --git a/src/main/java/com/android/apkzlib/zip/utils/RandomAccessFileUtils.java b/src/main/java/com/android/apkzlib/zip/utils/RandomAccessFileUtils.java
index 051f5df..73166fd 100644
--- a/src/main/java/com/android/apkzlib/zip/utils/RandomAccessFileUtils.java
+++ b/src/main/java/com/android/apkzlib/zip/utils/RandomAccessFileUtils.java
@@ -16,10 +16,9 @@
package com.android.apkzlib.zip.utils;
-import com.android.annotations.NonNull;
-
import java.io.IOException;
import java.io.RandomAccessFile;
+import javax.annotation.Nonnull;
/**
* Utility class with utility methods for random access files.
@@ -39,7 +38,7 @@ public class RandomAccessFileUtils {
* @param data the array that will receive the data
* @throws IOException
*/
- public static void fullyRead(@NonNull RandomAccessFile raf, @NonNull byte[] data)
+ public static void fullyRead(@Nonnull RandomAccessFile raf, @Nonnull byte[] data)
throws IOException {
int r;
int p = 0;
diff --git a/src/test/java/com/android/apkzlib/sign/SignatureTestUtils.java b/src/test/java/com/android/apkzlib/sign/SignatureTestUtils.java
index 71610ef..fb1d322 100644
--- a/src/test/java/com/android/apkzlib/sign/SignatureTestUtils.java
+++ b/src/test/java/com/android/apkzlib/sign/SignatureTestUtils.java
@@ -19,7 +19,6 @@ package com.android.apkzlib.sign;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-import com.android.annotations.NonNull;
import com.android.apkzlib.utils.ApkZLibPair;
import java.math.BigInteger;
import java.security.KeyPair;
@@ -30,6 +29,7 @@ import java.security.cert.X509Certificate;
import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Date;
+import javax.annotation.Nonnull;
import javax.security.auth.x500.X500Principal;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
@@ -54,7 +54,7 @@ public class SignatureTestUtils {
* @return the pair with the private key and certificate
* @throws Exception failed to generate the signature data
*/
- @NonNull
+ @Nonnull
public static ApkZLibPair<PrivateKey, X509Certificate> generateSignaturePre18()
throws Exception {
return generateSignature("RSA", "SHA1withRSA");
@@ -66,7 +66,7 @@ public class SignatureTestUtils {
* @return the pair with the private key and certificate
* @throws Exception failed to generate the signature data
*/
- @NonNull
+ @Nonnull
public static ApkZLibPair<PrivateKey, X509Certificate> generateSignaturePos18()
throws Exception {
return generateSignature("EC", "SHA256withECDSA");
@@ -80,10 +80,10 @@ public class SignatureTestUtils {
* @return the pair with the private key and certificate
* @throws Exception failed to generate the signature data
*/
- @NonNull
+ @Nonnull
public static ApkZLibPair<PrivateKey, X509Certificate> generateSignature(
- @NonNull String sign,
- @NonNull String full)
+ @Nonnull String sign,
+ @Nonnull String full)
throws Exception {
// http://stackoverflow.com/questions/28538785/
// easy-way-to-generate-a-self-signed-certificate-for-java-security-keystore-using
diff --git a/src/test/java/com/android/apkzlib/utils/ApkZFileTestUtils.java b/src/test/java/com/android/apkzlib/utils/ApkZFileTestUtils.java
index 380bb51..916ef46 100644
--- a/src/test/java/com/android/apkzlib/utils/ApkZFileTestUtils.java
+++ b/src/test/java/com/android/apkzlib/utils/ApkZFileTestUtils.java
@@ -18,7 +18,6 @@ package com.android.apkzlib.utils;
import static org.junit.Assert.assertTrue;
-import com.android.annotations.NonNull;
import com.android.testutils.TestResources;
import com.google.common.base.Preconditions;
import com.google.common.io.ByteSource;
@@ -27,6 +26,7 @@ import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
+import javax.annotation.Nonnull;
/**
* Utility functions for tests.
@@ -42,8 +42,8 @@ public final class ApkZFileTestUtils {
* @return the bytes read
* @throws Exception failed to read the file
*/
- @NonNull
- public static byte[] readSegment(@NonNull File file, long start, int length) throws Exception {
+ @Nonnull
+ public static byte[] readSegment(@Nonnull File file, long start, int length) throws Exception {
Preconditions.checkArgument(start >= 0, "start < 0");
Preconditions.checkArgument(length >= 0, "length < 0");
@@ -72,8 +72,8 @@ public final class ApkZFileTestUtils {
* @param path the path
* @return the test resource
*/
- @NonNull
- public static File getResource(@NonNull String path) {
+ @Nonnull
+ public static File getResource(@Nonnull String path) {
File resource = TestResources.getFile(ApkZFileTestUtils.class, path);
assertTrue(resource.exists());
return resource;
@@ -85,8 +85,8 @@ public final class ApkZFileTestUtils {
* @param path the path
* @return the test resource
*/
- @NonNull
- public static ByteSource getResourceBytes(@NonNull String path) {
+ @Nonnull
+ public static ByteSource getResourceBytes(@Nonnull String path) {
return Resources.asByteSource(Resources.getResource(ApkZFileTestUtils.class, path));
}
diff --git a/src/test/java/com/android/apkzlib/zip/ZFileNotificationTest.java b/src/test/java/com/android/apkzlib/zip/ZFileNotificationTest.java
index 8d01f0d..84be460 100644
--- a/src/test/java/com/android/apkzlib/zip/ZFileNotificationTest.java
+++ b/src/test/java/com/android/apkzlib/zip/ZFileNotificationTest.java
@@ -21,21 +21,19 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.android.apkzlib.utils.ApkZLibPair;
import com.android.apkzlib.utils.IOExceptionRunnable;
import com.google.common.collect.Lists;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.mockito.Mockito;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.mockito.Mockito;
public class ZFileNotificationTest {
private static class KeepListener extends ZFileExtension {
@@ -77,7 +75,7 @@ public class ZFileNotificationTest {
@Nullable
@Override
- public IOExceptionRunnable added(@NonNull StoredEntry entry,
+ public IOExceptionRunnable added(@Nonnull StoredEntry entry,
@Nullable StoredEntry replaced) {
added.add(new ApkZLibPair<>(entry, replaced));
return returnRunnable;
@@ -85,7 +83,7 @@ public class ZFileNotificationTest {
@Nullable
@Override
- public IOExceptionRunnable removed(@NonNull StoredEntry entry) {
+ public IOExceptionRunnable removed(@Nonnull StoredEntry entry) {
removed.add(entry);
return returnRunnable;
}
diff --git a/src/test/java/com/android/apkzlib/zip/ZFileSortTest.java b/src/test/java/com/android/apkzlib/zip/ZFileSortTest.java
index 6ad7bd1..869f73a 100644
--- a/src/test/java/com/android/apkzlib/zip/ZFileSortTest.java
+++ b/src/test/java/com/android/apkzlib/zip/ZFileSortTest.java
@@ -21,9 +21,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import com.android.annotations.Nullable;
import java.io.ByteArrayInputStream;
import java.io.File;
+import javax.annotation.Nullable;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
diff --git a/src/test/java/com/android/apkzlib/zip/ZFileTest.java b/src/test/java/com/android/apkzlib/zip/ZFileTest.java
index 3619691..742b9bd 100644
--- a/src/test/java/com/android/apkzlib/zip/ZFileTest.java
+++ b/src/test/java/com/android/apkzlib/zip/ZFileTest.java
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.android.annotations.NonNull;
import com.android.apkzlib.zip.compress.DeflateExecutionCompressor;
import com.android.apkzlib.zip.utils.CloseableByteSource;
import com.android.apkzlib.zip.utils.RandomAccessFileUtils;
@@ -38,11 +37,6 @@ import com.google.common.hash.Hashing;
import com.google.common.io.ByteStreams;
import com.google.common.io.Closer;
import com.google.common.io.Files;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -59,6 +53,10 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
+import javax.annotation.Nonnull;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
public class ZFileTest {
@Rule
@@ -1027,9 +1025,9 @@ public class ZFileTest {
boolean[] done = new boolean[1];
options.setCompressor(new DeflateExecutionCompressor(executor, options.getTracker(),
Deflater.BEST_COMPRESSION) {
- @NonNull
+ @Nonnull
@Override
- protected CompressionResult immediateCompress(@NonNull CloseableByteSource source)
+ protected CompressionResult immediateCompress(@Nonnull CloseableByteSource source)
throws Exception {
Thread.sleep(500);
CompressionResult cr = super.immediateCompress(source);
diff --git a/src/test/java/com/android/apkzlib/zip/ZipTestUtils.java b/src/test/java/com/android/apkzlib/zip/ZipTestUtils.java
index 9c67cff..aaff18b 100644
--- a/src/test/java/com/android/apkzlib/zip/ZipTestUtils.java
+++ b/src/test/java/com/android/apkzlib/zip/ZipTestUtils.java
@@ -18,11 +18,11 @@ package com.android.apkzlib.zip;
import static org.junit.Assert.assertFalse;
-import com.android.annotations.NonNull;
import com.android.apkzlib.utils.ApkZFileTestUtils;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
+import javax.annotation.Nonnull;
import org.junit.rules.TemporaryFolder;
/**
@@ -37,8 +37,8 @@ class ZipTestUtils {
* @return the resource data
* @throws IOException I/O failed
*/
- @NonNull
- static byte[] rsrcBytes(@NonNull String rsrcName) throws IOException {
+ @Nonnull
+ static byte[] rsrcBytes(@Nonnull String rsrcName) throws IOException {
return ApkZFileTestUtils.getResourceBytes("/testData/packaging/" + rsrcName).read();
}
@@ -52,7 +52,7 @@ class ZipTestUtils {
* @return the file that was created with the resource
* @throws IOException failed to clone the resource
*/
- static File cloneRsrc(@NonNull String rsrcName, @NonNull TemporaryFolder folder)
+ static File cloneRsrc(@Nonnull String rsrcName, @Nonnull TemporaryFolder folder)
throws IOException {
String cloneName;
if (rsrcName.contains("/")) {
@@ -77,9 +77,9 @@ class ZipTestUtils {
* @throws IOException failed to clone the resource
*/
static File cloneRsrc(
- @NonNull String rsrcName,
- @NonNull TemporaryFolder folder,
- @NonNull String cloneName)
+ @Nonnull String rsrcName,
+ @Nonnull TemporaryFolder folder,
+ @Nonnull String cloneName)
throws IOException {
File result = new File(folder.getRoot(), cloneName);
assertFalse(result.exists());
diff --git a/src/test/java/com/android/apkzlib/zip/ZipToolsTest.java b/src/test/java/com/android/apkzlib/zip/ZipToolsTest.java
index b9dbc8d..e45f117 100644
--- a/src/test/java/com/android/apkzlib/zip/ZipToolsTest.java
+++ b/src/test/java/com/android/apkzlib/zip/ZipToolsTest.java
@@ -22,8 +22,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -38,6 +36,8 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
@@ -67,7 +67,7 @@ public class ZipToolsTest {
public String mName;
@Rule
- @NonNull
+ @Nonnull
public TemporaryFolder mTemporaryFolder = new TemporaryFolder();
@Parameterized.Parameters(name = "{4} {index}")
@@ -104,7 +104,7 @@ public class ZipToolsTest {
return zfile;
}
- private static void assertFileInZip(@NonNull ZFile zfile, @NonNull String name) throws Exception {
+ private static void assertFileInZip(@Nonnull ZFile zfile, @Nonnull String name) throws Exception {
StoredEntry root = zfile.get(name);
assertNotNull(root);