JDK-8191416 : (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2017-11-16
  • Updated: 2018-03-28
  • Resolved: 2018-02-12
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 11
11 b01Fixed
Related Reports
Relates :  
Description
A long standing implementation detail is that direct ByteBuffers extend MappedByteBuffer. Now consider:

if (bb instance MappedByteBuffer) {
    ((MappedByteBuffer)bb).force();
} 

This throws UOE, as does isLoaded and the other methods defined by MappedByteBuffer.

A simple solution may be force/load/etc. to be no-ops when invoked without a backing file.