From 958d39aa03982d22f5d5cfa7eec9d2788551d4c8 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 30 Oct 2007 14:55:00 -0600 Subject: [PATCH 1/8] Add debug information for ByteBuffer --- classpath/java/nio/ByteBuffer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classpath/java/nio/ByteBuffer.java b/classpath/java/nio/ByteBuffer.java index 38cd1993f6..9aed90f5b5 100644 --- a/classpath/java/nio/ByteBuffer.java +++ b/classpath/java/nio/ByteBuffer.java @@ -201,4 +201,8 @@ public class ByteBuffer { if (position < 0 || position+amount > limit) throw new IndexOutOfBoundsException(); } + + public String toString() { + return "(ByteBuffer with array: " + array + " arrayOffset: " + arrayOffset + " position: " + position + " remaining; " + remaining() + ")"; + } } From df79f410f1b93d05fadad9c62670a8f3cd733430 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 30 Oct 2007 15:08:49 -0600 Subject: [PATCH 2/8] Optimize bulk reads from ByteArrayInputStream --- classpath/java/io/ByteArrayInputStream.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/classpath/java/io/ByteArrayInputStream.java b/classpath/java/io/ByteArrayInputStream.java index ee053f4fe8..d3bbcc686e 100644 --- a/classpath/java/io/ByteArrayInputStream.java +++ b/classpath/java/io/ByteArrayInputStream.java @@ -19,6 +19,18 @@ public class ByteArrayInputStream extends InputStream { } } + public int read(byte[] buffer, int offset, int bufferLength) { + if (position < length) { + return -1; + } + if (length-position < bufferLength) { + bufferLength = length-position; + } + System.arraycopy(buffer, offset, array, position, bufferLength); + position += bufferLength; + return bufferLength; + } + public int available() { return length - position; } From 907ce57975eb76876702a371973903daca756720 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 30 Oct 2007 15:10:32 -0600 Subject: [PATCH 3/8] Order of arraycopy backwards --- classpath/java/io/ByteArrayInputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classpath/java/io/ByteArrayInputStream.java b/classpath/java/io/ByteArrayInputStream.java index d3bbcc686e..6566b12fb4 100644 --- a/classpath/java/io/ByteArrayInputStream.java +++ b/classpath/java/io/ByteArrayInputStream.java @@ -26,7 +26,7 @@ public class ByteArrayInputStream extends InputStream { if (length-position < bufferLength) { bufferLength = length-position; } - System.arraycopy(buffer, offset, array, position, bufferLength); + System.arraycopy(array, position, buffer, offset, bufferLength); position += bufferLength; return bufferLength; } From b85c643251a4e0db153a6054abd6fb5ee70b138d Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 30 Oct 2007 15:37:46 -0600 Subject: [PATCH 4/8] Minor optimization for ByteArrayInputStream --- classpath/java/io/ByteArrayInputStream.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classpath/java/io/ByteArrayInputStream.java b/classpath/java/io/ByteArrayInputStream.java index 6566b12fb4..828db99722 100644 --- a/classpath/java/io/ByteArrayInputStream.java +++ b/classpath/java/io/ByteArrayInputStream.java @@ -23,8 +23,9 @@ public class ByteArrayInputStream extends InputStream { if (position < length) { return -1; } - if (length-position < bufferLength) { - bufferLength = length-position; + int remaining = length-position; + if (remaining < bufferLength) { + bufferLength = remaining; } System.arraycopy(array, position, buffer, offset, bufferLength); position += bufferLength; From b3891debb26ef4a52b13b3b42c4db7425f887150 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 30 Oct 2007 16:22:53 -0600 Subject: [PATCH 5/8] Fixes build for Mac OS X. If the binary is stripped on Mac OS X, dlsym fails, so builtin native library calls do not work. The solution, in this case, is to not strip the binary. --- makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/makefile b/makefile index 8a400218da..36ffe6d5fc 100644 --- a/makefile +++ b/makefile @@ -326,7 +326,9 @@ ifeq ($(platform),windows) else $(cc) $(^) $(lflags) -o $(@) endif +ifneq ($(platform),darwin) @$(strip) --strip-all $(@) +endif @$(show-size) $(@) $(generator): $(generator-objects) From 1da69cf881e9abddddde894987dcd11d978d79d9 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 30 Oct 2007 16:23:51 -0600 Subject: [PATCH 6/8] Test tweak --- test/Misc.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Misc.java b/test/Misc.java index f44fc6a37a..c80bda86cf 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -1,3 +1,4 @@ + public class Misc { private static int alpha; private static int beta; From 57fe9ea4669ef86e07c200d67fe10af2abb7f738 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 30 Oct 2007 16:24:09 -0600 Subject: [PATCH 7/8] Test tweak --- test/Misc.java | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Misc.java b/test/Misc.java index c80bda86cf..f44fc6a37a 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -1,4 +1,3 @@ - public class Misc { private static int alpha; private static int beta; From 2fd2df53fd3d93582e9f2d6aeb63437df4a88a87 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 30 Oct 2007 16:52:24 -0600 Subject: [PATCH 8/8] Fixed thinko in ByteArrayInputStream --- classpath/java/io/ByteArrayInputStream.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classpath/java/io/ByteArrayInputStream.java b/classpath/java/io/ByteArrayInputStream.java index 828db99722..56be302f76 100644 --- a/classpath/java/io/ByteArrayInputStream.java +++ b/classpath/java/io/ByteArrayInputStream.java @@ -20,7 +20,7 @@ public class ByteArrayInputStream extends InputStream { } public int read(byte[] buffer, int offset, int bufferLength) { - if (position < length) { + if (position >= length) { return -1; } int remaining = length-position;