X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=blobdiff_plain;f=src%2Fclasses%2Fjava%2Fnio%2FByteBuffer.java;h=fa99a65f68ed44c7e2bc9763ea370a71cac6cd17;hp=e0c99a79c5f8f91d74433227605c2c30ba13de91;hb=e734381a6e606354034111dc855be9a8e454ce71;hpb=0a84e8efb3a8509bbb8564ef9fe4abf2bdcb62b3 diff --git a/src/classes/java/nio/ByteBuffer.java b/src/classes/java/nio/ByteBuffer.java index e0c99a7..fa99a65 100644 --- a/src/classes/java/nio/ByteBuffer.java +++ b/src/classes/java/nio/ByteBuffer.java @@ -19,12 +19,13 @@ package java.nio; public class ByteBuffer extends Buffer { byte[] array; + int offset; public static ByteBuffer allocate(int i) { if (i < 0) { throw new IllegalArgumentException(); } - ByteBuffer newBuffer = new ByteBuffer(i); + ByteBuffer newBuffer = new ByteBuffer(-1, 0, i, i, new byte[i], 0); return newBuffer; } @@ -32,14 +33,18 @@ public class ByteBuffer extends Buffer { return allocate(capacity); } - protected ByteBuffer(int i) { - capacity = i; - this.clear(); - array = new byte[i]; + ByteBuffer(int mark, int pos, int lim, int cap, byte[] hb, int offset) { + super(mark, pos, lim, cap); + this.array = hb; + this.offset = offset; + } + + ByteBuffer(int mark, int pos, int lim, int cap) { + this(mark, pos, lim, cap, null, 0); } public ByteBuffer duplicate() { - ByteBuffer copy = new ByteBuffer(capacity); + ByteBuffer copy = new ByteBuffer(-1, 0, capacity, capacity, new byte[capacity], 0); copy.array = array; return copy; } @@ -50,7 +55,7 @@ public class ByteBuffer extends Buffer { public ByteBuffer slice() { int remaining = limit - position; - ByteBuffer copy = new ByteBuffer(remaining); + ByteBuffer copy = new ByteBuffer(-1, 0, remaining, remaining, new byte[remaining], 0); copy.array = array; return copy; } @@ -280,7 +285,7 @@ public class ByteBuffer extends Buffer { } public static ByteBuffer wrap(byte[] outMess) { - ByteBuffer byteBuffer = new ByteBuffer(outMess.length); + ByteBuffer byteBuffer = new ByteBuffer(-1, 0, outMess.length, outMess.length, new byte[outMess.length], 0); byteBuffer.clear(); System.arraycopy(outMess, 0 , byteBuffer.array, 0, outMess.length); return byteBuffer;