I’ve got a class that takes a ByteBuffer as a constructor argument. Is there a way to avoid making defensive copies in order to ensure that the buffer doesn’t get modified past that point?
ByteBuffer.isReadOnly() doesn’t guarantee that the original owner won’t modifying the buffer. To make matters worse, there doesn’t seem to be a way to subclass ByteBuffer. Any ideas?
This is the best I could do for now:
I’ve also filed a feature request with Oracle: https://bugs.java.com/bugdatabase/view_bug?bug_id=7130631