From 8c585e912ae4fd7b0b6f5a2e2ddabed6c70289cf Mon Sep 17 00:00:00 2001 From: Piotr Jastrzebski Date: Thu, 7 Aug 2014 12:42:26 +0100 Subject: Remove nameLength field from ZipEntry. It seems that this field is never used outside the internal constructor so it can be a local variable instead. Change-Id: I2aa26fb3fd13c571224a9aee14c7eea93e5c9591 --- luni/src/main/java/java/util/zip/ZipEntry.java | 7 ++----- luni/src/main/native/java_util_jar_StrictJarFile.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/luni/src/main/java/java/util/zip/ZipEntry.java b/luni/src/main/java/java/util/zip/ZipEntry.java index 217cc3c..d007b0f 100644 --- a/luni/src/main/java/java/util/zip/ZipEntry.java +++ b/luni/src/main/java/java/util/zip/ZipEntry.java @@ -52,7 +52,6 @@ public class ZipEntry implements ZipConstants, Cloneable { byte[] extra; - int nameLength = -1; long localHeaderRelOffset = -1; long dataOffset = -1; @@ -69,7 +68,7 @@ public class ZipEntry implements ZipConstants, Cloneable { ZipEntry(String name, String comment, long crc, long compressedSize, long size, int compressionMethod, int time, int modDate, byte[] extra, - int nameLength, long localHeaderRelOffset, long dataOffset) { + long localHeaderRelOffset, long dataOffset) { this.name = name; this.comment = comment; this.crc = crc; @@ -79,7 +78,6 @@ public class ZipEntry implements ZipConstants, Cloneable { this.time = time; this.modDate = modDate; this.extra = extra; - this.nameLength = nameLength; this.localHeaderRelOffset = localHeaderRelOffset; this.dataOffset = dataOffset; } @@ -340,7 +338,6 @@ public class ZipEntry implements ZipConstants, Cloneable { compressionMethod = ze.compressionMethod; modDate = ze.modDate; extra = ze.extra; - nameLength = ze.nameLength; localHeaderRelOffset = ze.localHeaderRelOffset; dataOffset = ze.dataOffset; } @@ -412,7 +409,7 @@ public class ZipEntry implements ZipConstants, Cloneable { compressedSize = ((long) it.readInt()) & 0xffffffffL; size = ((long) it.readInt()) & 0xffffffffL; - nameLength = it.readShort() & 0xffff; + int nameLength = it.readShort() & 0xffff; int extraLength = it.readShort() & 0xffff; int commentByteCount = it.readShort() & 0xffff; diff --git a/luni/src/main/native/java_util_jar_StrictJarFile.cpp b/luni/src/main/native/java_util_jar_StrictJarFile.cpp index 7611749..5a282e8 100644 --- a/luni/src/main/native/java_util_jar_StrictJarFile.cpp +++ b/luni/src/main/native/java_util_jar_StrictJarFile.cpp @@ -32,11 +32,10 @@ static void throwIoException(JNIEnv* env, const int32_t errorCode) { jniThrowException(env, "java/io/IOException", ErrorCodeString(errorCode)); } -static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, jstring entryName, - const uint16_t nameLength) { +static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, jstring entryName) { ScopedLocalRef zipEntryClass(env, env->FindClass("java/util/zip/ZipEntry")); const jmethodID zipEntryCtor = env->GetMethodID(zipEntryClass.get(), "", - "(Ljava/lang/String;Ljava/lang/String;JJJIII[BIJJ)V"); + "(Ljava/lang/String;Ljava/lang/String;JJJIII[BJJ)V"); return env->NewObject(zipEntryClass.get(), zipEntryCtor, @@ -49,7 +48,6 @@ static jobject newZipEntry(JNIEnv* env, const ZipEntry& entry, jstring entryName static_cast(0), // time static_cast(0), // modData NULL, // byte[] extra - static_cast(nameLength), static_cast(-1), // local header offset static_cast(entry.offset)); } @@ -135,7 +133,7 @@ static jobject StrictJarFile_nativeNextEntry(JNIEnv* env, jobject, jlong iterati entryNameCString[entryName.name_length] = '\0'; ScopedLocalRef entryNameString(env, env->NewStringUTF(entryNameCString.get())); - return newZipEntry(env, data, entryNameString.get(), entryName.name_length); + return newZipEntry(env, data, entryNameString.get()); } static jobject StrictJarFile_nativeFindEntry(JNIEnv* env, jobject, jlong nativeHandle, @@ -152,7 +150,7 @@ static jobject StrictJarFile_nativeFindEntry(JNIEnv* env, jobject, jlong nativeH return NULL; } - return newZipEntry(env, data, entryName, entryNameChars.size()); + return newZipEntry(env, data, entryName); } static void StrictJarFile_nativeClose(JNIEnv*, jobject, jlong nativeHandle) { -- cgit v1.1