Unmapping MappedByteBuffer

Alan Bateman Alan.Bateman at oracle.com
Sat Nov 3 05:27:10 PDT 2012


On 03/11/2012 09:21, Mark Thornton wrote:
> :
>
> That wouldn't be compatible with existing use of MappedByteBuffer. 
> However you could perhaps apply that strategy to a new class (possibly 
> a subclass of MappedByteBuffer). You could do without the disown() 
> method --- legal usage would still be legal, only faulty use might get 
> an exception in a different place.
>
> Mark
>
That's right, plus slices, duplicates and views would need to be 
considered too. One prototype that we had a few years ago was to add a 
modifier to MapMode so that the map method could request an unmappable 
buffer. The resulting mapped byte buffer (and resulting 
slices/duplicates/views) were generated with code to coordinate with 
unmap. It didn't of course deal with the access from native code case 
because that doesn't go through the java API. Introducing a notion of 
locked or owned buffer could require updates to JNI for these cases.

-Alan



More information about the nio-dev mailing list