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

Part 1 was commit 0d6471219bdd70d45b784a810e037e97011d6459.

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 27c702be4464b10bc99900769bc037fe4b0cfb7f
    at http://r.android.com/202536
[2] libcore commit fdfeacfac1c62197b784d58d89fcf5c6c29e0315
    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
2 files changed