RFR 8191416: (bf) DirectByteBuffer extends MappedByteBuffer, confuses instanceof tests

Alan Bateman Alan.Bateman at oracle.com
Tue Feb 6 16:41:23 UTC 2018

On 06/02/2018 01:17, Brian Burkhalter wrote:
> https://bugs.openjdk.java.net/browse/JDK-8191416
> http://cr.openjdk.java.net/~bpb/8191416/webrev.00/
> As suggested in the issue description, change force(), load(), and isLoaded() to be no-ops when there is no backing file instead of throwing UnsupportedOperationException.
It's an undocumented implementation detail that a direct buffer is a 
MappedByteBuffer. This dates back to the original implementation, is 
complicated to change, and maybe we should put the effort re-visiting 
it.  I read this patch as a short term mitigation for those that test if 
a buffer is a MappedByteBuffer so they can call force. I guess it's okay 
although I do wonder if this mitigation should be limited to force and 
don't touch loaded/isLoaded.

Minor comment is that the other methods uses "mapping" in the name so 
maybe hasFileMapping might be better.


More information about the nio-dev mailing list