History log of /libcore/luni/src/main/java/java/nio/ByteBuffer.java
Revision Date Author Comments
882daa8bc4ea578e11e7ff986a1a036dd9f21027 21-Jul-2014 Mathieu Chartier <mathieuc@google.com> Make ByteBuffer.allocateDirect be 8 byte aligned.

Bug: 16449607

(cherry picked from commit fb6c80875a8a8d0a9628562f89c250b6a962e824)

Change-Id: Id8771d6e9624c36b963466f91d0d1cb6703266d2
fb6c80875a8a8d0a9628562f89c250b6a962e824 21-Jul-2014 Mathieu Chartier <mathieuc@google.com> Make ByteBuffer.allocateDirect be 8 byte aligned.

Bug: 16449607

Change-Id: I4a854d55f49fe709965c6b6a769fb58c356627dc
ec3a12ddb18aaf37575ceb00e158f2bda5796629 02-Jun-2014 Neil Fuller <nfuller@google.com> Fix BufferTest.testAccess

Commit b327df0b7d83f079856304830ff4da92b4a5ea1f fixed three
tests but broke BufferTest.testAccess. This fixes all of them.

This ordering of state / argument checks appears consistent
with the checks in DirectByteBuffer for other, similar methods
such as putShort:
1) this.isAccessible
2) this.isReadOnly
3) Argument validity checks

Change-Id: I4e93129ae0f3008ee4894f840d69ae71586b9f07
b327df0b7d83f079856304830ff4da92b4a5ea1f 21-May-2014 Neil Fuller <nfuller@google.com> Change exception priority for ByteBuffer.put(null)

Commit 7e02765b7ada4e85f941f0a6b0fc60a8a76301f3
made ByteBuffer.put(null) throw a NullPointerException
if the ByteBuffer was read only. Previously it would
throw a ReadOnlyBufferException. The priority
of exceptions is unclear, but this returns the behavior
to what it was before and fixes 3 CTS tests:

ReadOnlyWrappedByteBufferTest.testPutByteBuffer
ReadOnlyHeapByteBufferTest.testPutByteBuffer
ReadOnlyDirectByteBufferTest.testPutByteBuffer

Change-Id: I90dd4b6969a4f31a26651d7b35758f899cc020b4
923706a429d78650a2a5f05c169b59174be1ee53 09-May-2014 Lajos Molnar <lajos@google.com> DirectByteBuffer: add setAccessible()

Bug: 14297827
Change-Id: I726f16f9a15f894b99a93c84aca820f5c1b994e5
7e02765b7ada4e85f941f0a6b0fc60a8a76301f3 28-Apr-2014 Lajos Molnar <lajos@google.com> Better protection against accessing freed DirectByteBuffers

Expand preventing access of freed buffers, so duplicated ByteBuffers
also become inaccessible when the original buffer is freed.

Throw IllegalStateException in ByteBuffer.put(ByteBuffer) when either
source or destination buffer is inaccessible.

Bug: 11512044
Change-Id: Idd2f4ef1f3d66b4209441bf4014ccd4aad9d850b
77c1cbc9eb6fac1549b98c553ea2df2beee66422 10-Jan-2014 Calin Juravle <calin@google.com> Invalidate DirectByteBuffers when freed.

Calls to DirectByteBuffer#free() will invalidate the buffer:
- isValid() will return false;
- subsequent operations which touch the inner buffer will
throw IllegalStateException.

Note: NioUtils#freeDirectByteBuffer can also be used to
invalidate the buffer.

Bug: 11512044
Change-Id: I78e00dc12b0dbfbd1be6af28bef2413053fb15cb
2589e301d1fb85960045c9ef29682d7e73b1aee7 05-Nov-2013 Narayan Kamath <narayan@google.com> Make effectiveDirectAddress final.

Also add a unit test to make sure elementSizeShift
is set correctly.

Change-Id: Ia6c797001a768fa1c3136d475f2ac0e047b35fb0
ac96decfea84ebdccb308492acb01454c8823c2c 05-Nov-2013 Narayan Kamath <narayan@google.com> Don't force MemoryBlocks on classes that don't care.

Only MappedByteBuffer and DirectByteBuffer need to know
about this abstraction.

Change-Id: I293284c8b8a73ac01463337dc8a1e22d16cd378d
38f3983aed5a093c17d1f68c1517bbc72c2862ea 15-Oct-2013 Elliott Hughes <enh@google.com> Use @throws rather than the deprecated and unusual @exception.

Change-Id: I69d94fae14a6153ef227352e1e159697db8d618d
223ab34ad4890414b278a1e7893a99220c8f3203 27-Aug-2013 Elliott Hughes <enh@google.com> Fix ByteBuffer.duplicate documentation.

Bug: https://code.google.com/p/android/issues/detail?id=59403

(cherry picked from commit 1c298efc60083a2ce5bdbf3febb942f5ce4c621d)

Change-Id: Iff5df247768e87cc92cb7dcc390fe58dc738642f
1c298efc60083a2ce5bdbf3febb942f5ce4c621d 27-Aug-2013 Elliott Hughes <enh@google.com> Fix ByteBuffer.duplicate documentation.

Bug: https://code.google.com/p/android/issues/detail?id=59403
Change-Id: I5107cb8e5c486fcf1fa9080c5c248a63d8d50665
04b2ff92ae27b3acd82148d9252253573638ccc6 30-Jan-2012 Ian Rogers <irogers@google.com> Add missing @Override annotations

Change-Id: I4c5772c9549375beeb0e4f269bd61d623fca7e35
(cherry picked from commit 49992f5003aac55e1b1cf54769abc93630ccde93)
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
126ab1b546c71137a97cef68cc89267e7f7be634 28-Aug-2012 Elliott Hughes <enh@google.com> Improve nio IllegalArgumentException detail messages.

Bug: 7005326
Change-Id: Ibab8b776865dbed5da062cc683f834a79f068b32
0568a63ba1086a78ffb4cff68dd2eac4f9908e13 26-Apr-2011 Elliott Hughes <enh@google.com> Fix ByteBuffer.put(ByteBuffer).

To do this tastefully required some cunning in the native code. The new
ScopedBytesRO/ScopedBytesRW classes let us paper over the differences
between byte[] and DirectByteBuffer, which in turn lets us paper over the
differences between the various kinds of ByteBuffer.

I've also rewritten Posix.read/Posix.readDirectBuffer and
Posix.write/Posix.writeDirectBuffer to use the same idea. I haven't rewritten
readv and writev, but can do and probably should.

Bug: http://code.google.com/p/android/issues/detail?id=16184
Change-Id: Ia30d2f2fe1b1716a8f068187df2218b407a55aae
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
0e1b748ecabf720065a632f28330f5d4d037d5ae 10-Sep-2010 Elliott Hughes <enh@google.com> Consistent naming for get/put/wrap arguments.

Bug: 2935622
Change-Id: Icb39392f9106f9fe5ba70ccdcb6b059dbf5617bc
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
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
8510524dab13e0acc1babf22cbc55002fb122777 17-Aug-2010 Elliott Hughes <enh@google.com> Some nio tidying.

Remove indirection on OSMemory, and use public ByteOrder and MapMode types
throughout the implementation, rather than adding our own duplication. Also
remove some unnecessary Java methods that just forwarded to identical native
methods, and an unnecessary factory class for MappedByteBuffer instances.
Also get rid of ICommonDataTypes, most of which was unused cruft.

Change-Id: I3240b02bcc19941b1b1cbba351ae7f7c1cdfc5b4
ccbe3404e0691dab506d017550658e8e5974c83e 10-Jul-2010 Elliott Hughes <enh@google.com> Use 'dst' (or an even more appropriate name where possible) rather than 'dest'.

(The ArrayIndexOutOfBoundsException for System.arraycopy already talks
about 'dst' and 'dstPos'.)

Change-Id: Iba9415dd4a9ec3b457938ea4469b4a0024bab6e4
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
fd6bb3510c2f94d636f3572dcf5f7f4dcd1a2726 13-May-2010 Elliott Hughes <enh@google.com> Remove //$NON-NLS-\d$ cruft.

Mostly done by perl(1), with manual cleanup of the few misspelled instances.
This makes our trailing whitespace slightly worse, but I'll fix all that with
a follow-on change.

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

Change-Id: Ib4356b3cd57490df8ff246ea6a4bc1c269ba848b