From 4751c150542ec282f6c6d58984974edec6c0a045 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Mon, 3 May 2010 15:27:11 -0700 Subject: [PATCH] Fixing bulk reads in ByteArray.MyInputStream This has never worked properly, but it didn't matter until recently because neither the JDK's nor early Dalvik's DataInputStream was exercising it. But in 2.0, Dalvik's DataInputStream prefers bulk reads, which exercises this code when run on-device. http://code.google.com/p/android/issues/detail?id=8115 The problem was that System.arraycopy call didn't include the start offset in the call. --- dx/src/com/android/dx/util/ByteArray.java | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/dx/src/com/android/dx/util/ByteArray.java b/dx/src/com/android/dx/util/ByteArray.java index 6bd6e5f10..79fa1956e 100644 --- a/dx/src/com/android/dx/util/ByteArray.java +++ b/dx/src/com/android/dx/util/ByteArray.java @@ -321,7 +321,7 @@ public final class ByteArray { length = maxLength; } - System.arraycopy(bytes, cursor, arr, offset, length); + System.arraycopy(bytes, cursor + start, arr, offset, length); cursor += length; return length; } @@ -341,15 +341,6 @@ public final class ByteArray { public boolean markSupported() { return true; } - - /** - * Gets the current cursor. - * - * @return {@code 0..size();} the cursor - */ - public int getCursor() { - return cursor; - } } /** @@ -366,14 +357,5 @@ public final class ByteArray { this.wrapped = wrapped; } - - /** - * Gets the current cursor. - * - * @return {@code 0..size();} the cursor - */ - public int getCursor() { - return wrapped.getCursor(); - } } } -- 2.11.0