JDK-8150785 : (bf) Hoist slice and duplicate methods up to java.nio.Buffer
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-02-28
  • Updated: 2017-05-17
  • Resolved: 2016-05-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b120Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
At present, 'slice()' and 'duplicate()' are defined separately in all subtypes of java.nio.Buffer. Hoisting them up to the base class (at the same time overriding covariantly in each of the subtypes) would allow more code reuse when working with buffers.
Comments
During the analysis there hasn't been found any reasons why `asReadOnlyBuffer()` cannot be hoisted as well. The reason why it was decided to not include it in the scope of this issue is that no use cases has been found to support this hoisting yet.
12-05-2016

I'm excluding 'compact' and 'asReadOnly' for now. Because of YAGNI. Currently (in the WebSocket implementation) I need only 'slice' and 'duplicate'. And speaking of 'compact'. It seems to be an odd one out as its use case is very heavily tied to byte buffers and channels.
04-05-2016