I've tried to address all the points that have been made. I haven't changed the way the sub-words are read and written because the code I'm seeing is fairly nearly optimal right now and anything more complex runs the risk of tripping inlining limits, thus pessimizing performance. We need a general solution which isn't optimized for special cases but is decent on average and often very good. I think it's close to the best compromise we're going to get.
I have changed the javadoc as requested and I have fixed the code in HeapByteBuffer so that it doesn't check the index twice for floating- point put() and get() operations. I have added a jtreg test for HeapByteBuffer which tests it pretty thoroughly. It also, as a consequence, tests the underlying Unsafe methods. I wasn't sure what a separate test for the Unsafe methods would achieve so I didn't write one. OK? http://cr.openjdk.java.net/~aph/unaligned.hotspot.6/ http://cr.openjdk.java.net/~aph/unaligned.jdk.6/ Andrew.