History log of /libcore/luni/src/main/java/java/nio/Buffer.java
Revision Date Author Comments
0121106d9dc1ba713b53822886355e4d9339e852 28-Feb-2013 Joel Dice <joel.dice@gmail.com> Use longs instead of ints to store pointers in NIO buffers.

This allows the code to be used on 64-bit VMs.

Change-Id: I4d01bfcd0ffea528c6179687771d047fdcb4d18a
fe5da19e0e366286cd4d95f7628fe9442b9062c8 27-Mar-2013 Elliott Hughes <enh@google.com> Simplify the nio Buffer implementations, and fix MappedByteBuffer.

* Fix the reported bug caused by delegation in the MappedByteBuffer
implementation.

* Collapse the three classes (ReadOnly*, ReadWrite*, and *) used
to implement most buffer types into one class each.

* Rename HeapByteBuffer to ByteArrayBuffer to match its companions.

* Remove BaseByteBuffer.

* Give the classes used to implement asXBuffer sane names (their
existing names were backwards).

Bug: https://code.google.com/p/android/issues/detail?id=53637
Change-Id: I2a7ff4f1d502564389615384324afadabccb04f9
3b5eb93b0dc1d1a0109451cca56a618635485a67 27-Mar-2013 Elliott Hughes <enh@google.com> Improve java.nio.Buffer.toString.

Bug: https://code.google.com/p/android/issues/detail?id=53637
Change-Id: I823662b39cb48b5f4456f4c58269324dfcdc2fd1
126ab1b546c71137a97cef68cc89267e7f7be634 28-Aug-2012 Elliott Hughes <enh@google.com> Improve nio IllegalArgumentException detail messages.

Bug: 7005326
Change-Id: Ibab8b776865dbed5da062cc683f834a79f068b32
e3b6fa2bf357f2712ab2ee9e8487f157595ea0c7 10-Jun-2011 Elliott Hughes <enh@google.com> Expose pread and pwrite.

And fix FileChannel to use them.

Bug: 4183719
Bug: 3107501
Change-Id: I51114a16522b93bf959b5953bec658e6889054c6
a28bc96d63595a77fa918da8ccdda50e9eaae95e 21-May-2011 Elliott Hughes <enh@google.com> Fix read/write bugs in DatagramChannel and SocketChannel.

Also improve some exception detail messages for ease of debugging.

These bugs were found by external/apache-harmony tests.

Change-Id: I37a58c1d1f1c2150eb9171967f47ef9644e8ae15
a1603838fe9e865575c87982e32c6343740e464c 11-Dec-2010 Elliott Hughes <enh@google.com> Lots more bounds-checking/exception-throwing consistency.

Overflow-safe checks all round, plus better detail messages. This isn't
quite everything, but it's a large chunk of the work. Most notably, this
is all of io and nio.

There are numerous changes of exception priority here, and the harmony
tests noticed a subset of them in the nio code. I've modified our checked-out
copy of the tests to accept any of the throwable exceptions.

Change-Id: Id185f1228fb9a1d5fc9494e78375b5623fb0fe14
43a9f774d075e0e441d8b996e3f6c81ea483ec89 19-Oct-2010 Elliott Hughes <enh@google.com> BufferIterator support for byte[].

Bug: 3032515
Change-Id: I040a92c3ce241aa97719ff94e3cc31c62473bf46
8fbc397fc09158bee0bc0cb231c609c4c6e9fc15 18-Sep-2010 Elliott Hughes <enh@google.com> Optimize non-direct (heap) buffer bulk put.

I've also factored out the bounds checking, even though the JIT can't yet
inline it back. I'm unwilling to duplicate all that code again.

This patch also fixes bugs in the previous checkin relating to offsets
and positions. In real life (and, seemingly, in all our tests) these tend
to be 0, making it rare that anyone trips over these bugs. (The first nio
change I made was fixing just such a bug.) I've improved the test I added
last time so that it covers more of these cases.

Here are the "after" performance figures for heap buffer bulk copies:

CharBuffer_getCharArray 5797
CharBuffer_putCharArray 5818
DoubleBuffer_getDoubleArray 13053
DoubleBuffer_putDoubleArray 13026
FloatBuffer_getFloatArray 8216
FloatBuffer_putFloatArray 8283
IntBuffer_getIntArray 8253
IntBuffer_putIntArray 8371
LongBuffer_getLongArray 13053
LongBuffer_putLongArray 13020
ShortBuffer_getShortArray 5796
ShortBuffer_putShortArray 5864

This compares well with with direct buffer performance (just gets shown here):

CharBuffer_getCharArray 4412
DoubleBuffer_getDoubleArray 11594
FloatBuffer_getFloatArray 6787
IntBuffer_getIntArray 6791
LongBuffer_getLongArray 11672
ShortBuffer_getShortArray 4430

Bug: 2985452
Change-Id: I37307f9b304c87a87af5313790444dcdf6174ff1
6944bea4a129dc2d4be687c72f2a9f228ec532bc 17-Sep-2010 Elliott Hughes <enh@google.com> Make nio heap (non-direct) buffer bulk get orders of magnitude faster.

Bug: 2985452
Change-Id: I8bd210d1a623e434121f30eca6e2555e1aea11cd
0c53cf8b2c46deb41e91db50ddc17d598cc64a10 09-Sep-2010 Elliott Hughes <enh@google.com> Speed up MappedByteBuffer.

Make it possible to override limit(int) and position(int) internally, so I can
avoid updating MappedByteBufferAdapter's wrapped ByteBuffer's limit and
position on every get or put. I still need to do extra work with position if
you use the get/put overloads that don't take an index, but even that becomes
cheaper. The indexed overloads benefit the most, though. Before:

benchmark before after (both us)

ByteBuffer_getByte 830 757
ByteBuffer_getChar 940 875

ByteBuffer_getByte_indexed 800 509
ByteBuffer_getChar_indexed 936 643

Also factor out duplicated toString implementations.

Bug: 2935622
Change-Id: I4cfe206fde638bddb5a7b4a62223e2588f44b8ac
934767b07d94041390785d8fe66c86b2379730bc 09-Sep-2010 Elliott Hughes <enh@google.com> Fix build (non-final _elementSizeShift).

Bug: 2935622
Change-Id: I5ff543b11e055a25676444d7ba9f0bb939544816
0440837fd0013373ba3476283151299e7be9e5a3 08-Sep-2010 Elliott Hughes <enh@google.com> Move the MemoryBlock up into java.nio.Buffer.

This lets me kill getBaseAddress and the (bogus) DirectBuffer interface.

Bug: 2935622
Change-Id: I51c758e7687a6cfa4a3a64ef089fb600b847b70f
0f335c4ed1a0cb419c8ce82183fabb241d5dd032 07-Sep-2010 Elliott Hughes <enh@google.com> Kill getEffectiveAddress.

Set the corresponding field in the constructors.

Requires a dalvikvm change: https://android-git.corp.google.com/g/64866

Bug: 2935622
Change-Id: I26663bfcdb80db75672be71395b861c1a79c24fc
29dbfe19b113a13b712be2bc762ef1c81cd06c47 03-Sep-2010 Elliott Hughes <enh@google.com> Use finalizers to free direct buffers.

Also switch to a cheaper scheme for avoiding double-frees (which could only
happen if library code is broken; at the moment the only caller is the
iovec-style stuff). This halves the cost of direct buffer access, at the
unimportant cost of not throwing an exception if we try to access a buffer
we freed while we still had a reference to it.

Also use named constants for the sizes of primitive types.

Also kill BufferFactory.

Bug: 2935622
Change-Id: I6021ce7531f49d8cff7635d6d2cc54851bacaf69
162a12c1442641a95fe95859fa4e561b22db049f 25-May-2010 Elliott Hughes <enh@google.com> Remove @hide from Java 6 API.

I've left the two new spi packages @hidden, because I think we shouldn't
support them without convincing demand from developers (and I don't
believe there could be such a thing --- they just don't make sense, and
if we add anything, it should be the ability to provide extra ICU data).

Also fix a handful of javadoc syntax errors in Arrays.java and TreeMap.java.

Bug: 2497395
Change-Id: I4176b72daff0face4ed6c7ee1d1f4267d52006b4
f33eae7e84eb6d3b0f4e86b59605bb3de73009f3 13-May-2010 Elliott Hughes <enh@google.com> Remove all trailing whitespace from the dalvik team-maintained parts of libcore.

Gentlemen, you may now set your editors to "strip trailing whitespace"...

Change-Id: I85b2f6c80e5fbef1af6cab11789790b078c11b1b
3ff29eb11a241d58c54ecc84230bb0672f4aa148 23-Apr-2010 Peter Hallam <peterhal@google.com> More merging of nio into luni

Change-Id: Ib4356b3cd57490df8ff246ea6a4bc1c269ba848b