diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d950e93ecf9..c39097bc503 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2004-11-17 Michael Koch + + * java/nio/DirectByteBufferImpl.java + (owner): Updated comment. + (allocate): New method. + 2004-11-17 Michael Koch * java/net/URL.java (URL): Handle case when argument is null. diff --git a/libjava/java/nio/DirectByteBufferImpl.java b/libjava/java/nio/DirectByteBufferImpl.java index aad5dca1e5d..89be156d432 100644 --- a/libjava/java/nio/DirectByteBufferImpl.java +++ b/libjava/java/nio/DirectByteBufferImpl.java @@ -52,7 +52,7 @@ final class DirectByteBufferImpl extends ByteBuffer } } - /** Used by MappedByteBufferImpl to prevent premature GC. */ + /** Used by MappedByteBufferImpl and when slicing to prevent premature GC. */ protected Object owner; RawData address; @@ -73,6 +73,14 @@ final class DirectByteBufferImpl extends ByteBuffer this.owner = owner; } + /** + * Allocates a new direct byte buffer. + */ + public static ByteBuffer allocate(int capacity) + { + return new DirectByteBufferImpl(allocateImpl(capacity), capacity); + } + private static native RawData allocateImpl (int capacity); private static native void freeImpl (RawData address);