Attaching a patch that removes the bytes_ and offset_ fields from the Request class and replaces them with a java.nio.ByteBuffer field. The Request class and its subclasses were changed to use the new field. Apart from the mechanical changes (that is, replacing the direct byte array accesses with accesses via ByteBuffer), the patch changes the following:
1) Changed the meaning of the length parameter in the ensureLength() method. Previously, it represented the minimum total length of the byte buffer, whereas it now represents the minimum number of available bytes at the end of the buffer. (Actually, the existing comments in the method match the new behaviour, so it looks like that was how it was intended to work.) This seemed like a reasonable simplification now that ensureLength() needed to be rewritten in any case (because it needed to check and reallocate a ByteBuffer instead of a byte array) and also all calls needed to be changed (because almost all referred to the removed offset_ field).
2) As I updated various pieces of the code, I noticed that there was a lot of duplication. The places where I had seen a helper method that did the exact same thing, I changed the code to use the helper methods instead of just mechanically translating it.
3) Removed some helper methods in client.am.SignedBinary and client.am.FloatingPoint since we now use methods in java.nio.ByteBuffer that provide the same functionality.
The patch adds 199 lines and removes 414 lines, so it results in a net removal of 215 lines.
All the regression tests ran cleanly with the patch. I'm currently running some performance tests to see if these changes affect the performance negatively.