From 39bee886e3e96977fc8098d91f9e348dc0954efc Mon Sep 17 00:00:00 2001 From: JET Date: Thu, 20 Oct 2011 13:45:47 -0600 Subject: [PATCH 1/2] ByteBuffer and InputStream now better match the standard. --- classpath/java/io/InputStream.java | 2 +- classpath/java/nio/Buffer.java | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/classpath/java/io/InputStream.java b/classpath/java/io/InputStream.java index a225432044..8e74c2db8d 100644 --- a/classpath/java/io/InputStream.java +++ b/classpath/java/io/InputStream.java @@ -56,7 +56,7 @@ public abstract class InputStream { } public void reset() throws IOException { - // ignore + throw new IOException("mark/reset not supported"); } public boolean markSupported() { diff --git a/classpath/java/nio/Buffer.java b/classpath/java/nio/Buffer.java index 3de26da72f..c93c11f347 100644 --- a/classpath/java/nio/Buffer.java +++ b/classpath/java/nio/Buffer.java @@ -15,45 +15,50 @@ public abstract class Buffer { protected int position; protected int limit; - public int limit() { + public final int limit() { return limit; } - public int remaining() { + public final int remaining() { return limit-position; } - public int position() { + public final int position() { return position; } - public int capacity() { + public final int capacity() { return capacity; } - public Buffer limit(int newLimit) { + public final Buffer limit(int newLimit) { limit = newLimit; return this; } - public Buffer position(int newPosition) { + public final Buffer position(int newPosition) { position = newPosition; return this; } - public boolean hasRemaining() { + public final boolean hasRemaining() { return remaining() > 0; } - public Buffer clear() { + public final Buffer clear() { position = 0; limit = capacity; return this; } - public Buffer flip() { + public final Buffer flip() { limit = position; position = 0; return this; } + + public final Buffer rewind() { + position = 0; + return this; + } } From 3b1c769d2b6ba67fe47cdf583ed186944bb595a9 Mon Sep 17 00:00:00 2001 From: JET Date: Mon, 24 Oct 2011 09:01:17 -0600 Subject: [PATCH 2/2] Fixed RandomAccessFile to update position after reads. --- classpath/java/io/RandomAccessFile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classpath/java/io/RandomAccessFile.java b/classpath/java/io/RandomAccessFile.java index a2f40bce76..f5a3602bf1 100644 --- a/classpath/java/io/RandomAccessFile.java +++ b/classpath/java/io/RandomAccessFile.java @@ -56,6 +56,8 @@ public class RandomAccessFile { throw new ArrayIndexOutOfBoundsException(); copy(peer, position, buffer, offset, length); + + position += length; } private static native void copy(long peer, long position, byte[] buffer,