Commit 2e6efcfa authored by Tobias Thierer's avatar Tobias Thierer
Browse files

Verify java.nio.ByteBuffer against OpenJDK8u121-b13, part 2.

Part 1 was commit 0d647121.

Changes in this CL:

- move check for (!isAccessible()) from put(ByteBuffer) back
  into the DirectByteBuffer subclass. It had previously been
  moved up into ByteBuffer.java by CL [1] which made a
  performance improvement in the rest of the method.

  This move is a pure refactoring without behavior change
  because DirectByteBuffer is the only subclass that overrides
  isAccessible(); it already contains similar checks in
  several places, so having this check there is more consistent.

  There are no ByteBuffer subclasses outside of the platform
  because ByteBuffer and its subclasses have package private
  constructors.

- revert addition of { } around if-blocks with a single
  statement. These had also been added by CL [1].

- add change marker for the performance improvement from CL [1].

- revert redundant addition of a check for (capacity < 0) in
  allocateDirect(int). The java.nio.Buffer superclass already
  throws IAE for cap < 0 (although with a different exception
  message) so we don't need to duplicate that check here.
  ByteBuffer.testAllocateDirect() verifies that this still
  throws IAE. This test method was only recently added in
  CL [2]. Previously, this was not covered by tests.

[1] libcore commit 27c702be
    at http://r.android.com/202536
[2] libcore commit fdfeacfa
    at http://r.android.com/672191

Left for a future CL:
 - {get,put}*Unchecked() methods
 - boolean isAccessible(), void setAccessible(boolean)

Test: CtsLibcoreTestCases
Bug: 35910877

Change-Id: I380b4cf1079d079c242c5353a079fe638d12e3ba
parent 2399174c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment