diff options
author | Michael Koch <konqueror@gmx.de> | 2004-11-24 10:44:18 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2004-11-24 10:44:18 +0000 |
commit | 11dde1bb18eaf7a6981bc5e7e46cc7d945d55182 (patch) | |
tree | 9b7c7a17527d4c0271c30763af092c759f04c29c /libjava/java/nio/DirectByteBufferImpl.java | |
parent | 911461693337552b76b5994d9d875e1b78e64b28 (diff) | |
download | gcc-11dde1bb18eaf7a6981bc5e7e46cc7d945d55182.zip gcc-11dde1bb18eaf7a6981bc5e7e46cc7d945d55182.tar.gz gcc-11dde1bb18eaf7a6981bc5e7e46cc7d945d55182.tar.bz2 |
NIOServerSocket.java: Added email to @author tag.
2004-11-24 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/NIOServerSocket.java: Added email to @author tag.
* java/nio/DirectByteBufferImpl.java:
Moved native methods to java.nio.VMDirectByteBuffer class.
* java/nio/MappedByteBufferImpl.java:
Use native methods from java.nio.VMDirectByteBuffer class.
* java/nio/VMDirectByteBuffer.java: New file,
* java/nio/natDirectByteBufferImpl.cc:
Moved all methods into java.nio.VMDirectByteBuffer class.
* java/nio/channels/spi/AbstractSelectableChannel.java
(register): Only re-use valid keys.
* Makefile.am: Added java/nio/VMDirectByteBuffer.java.
* Makefile.in: Regenerated.
From-SVN: r91146
Diffstat (limited to 'libjava/java/nio/DirectByteBufferImpl.java')
-rw-r--r-- | libjava/java/nio/DirectByteBufferImpl.java | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/libjava/java/nio/DirectByteBufferImpl.java b/libjava/java/nio/DirectByteBufferImpl.java index 6e4fa81..a92515d 100644 --- a/libjava/java/nio/DirectByteBufferImpl.java +++ b/libjava/java/nio/DirectByteBufferImpl.java @@ -38,20 +38,10 @@ exception statement from your version. */ package java.nio; -import gnu.classpath.Configuration; import gnu.gcj.RawData; final class DirectByteBufferImpl extends ByteBuffer { - static - { - // load the shared library needed for native methods. - if (Configuration.INIT_LOAD_LIBRARY) - { - System.loadLibrary ("javanio"); - } - } - /** Used by MappedByteBufferImpl and when slicing to prevent premature GC. */ protected Object owner; @@ -78,26 +68,21 @@ final class DirectByteBufferImpl extends ByteBuffer */ public static ByteBuffer allocate(int capacity) { - return new DirectByteBufferImpl(allocateImpl(capacity), capacity); + return new DirectByteBufferImpl(VMDirectByteBuffer.allocate(capacity), + capacity); } - private static native RawData allocateImpl (int capacity); - private static native void freeImpl (RawData address); - protected void finalize() throws Throwable { - freeImpl (address); + VMDirectByteBuffer.free(address); } - static native byte getImpl (RawData address, int index); - static native void putImpl (RawData address, int index, byte value); - public byte get() { checkForUnderflow(); int pos = position(); - byte result = getImpl (address, pos); + byte result = VMDirectByteBuffer.get(address, pos); position(pos + 1); return result; } @@ -106,19 +91,16 @@ final class DirectByteBufferImpl extends ByteBuffer { checkIndex(index); - return getImpl (address, index); + return VMDirectByteBuffer.get(address, index); } - static native void getImpl (RawData address, int index, - byte[] dst, int offset, int length); - public ByteBuffer get(byte[] dst, int offset, int length) { checkArraySize(dst.length, offset, length); checkForUnderflow(length); int index = position(); - getImpl(address, index, dst, offset, length); + VMDirectByteBuffer.get(address, index, dst, offset, length); position(index+length); return this; @@ -130,7 +112,7 @@ final class DirectByteBufferImpl extends ByteBuffer checkForOverflow(); int pos = position(); - putImpl (address, pos, value); + VMDirectByteBuffer.put(address, pos, value); position(pos + 1); return this; } @@ -140,15 +122,13 @@ final class DirectByteBufferImpl extends ByteBuffer checkIfReadOnly(); checkIndex(index); - putImpl (address, index, value); + VMDirectByteBuffer.put(address, index, value); return this; } - static native void shiftDown(RawData address, int dst_offset, int src_offset, int count); - void shiftDown(int dst_offset, int src_offset, int count) { - shiftDown(address, dst_offset, src_offset, count); + VMDirectByteBuffer.shiftDown(address, dst_offset, src_offset, count); } public ByteBuffer compact() @@ -157,21 +137,19 @@ final class DirectByteBufferImpl extends ByteBuffer if (pos > 0) { int count = remaining(); - shiftDown(address, 0, pos, count); + VMDirectByteBuffer.shiftDown(address, 0, pos, count); position(count); limit(capacity()); } return this; } - public static native RawData adjustAddress(RawData address, int offset); - public ByteBuffer slice() { int rem = remaining(); - return new DirectByteBufferImpl (owner, - adjustAddress(address, position()), - rem, rem, 0, isReadOnly ()); + return new DirectByteBufferImpl + (owner, VMDirectByteBuffer.adjustAddress(address, position()), + rem, rem, 0, isReadOnly()); } private ByteBuffer duplicate(boolean readOnly) |