Win32Buffer extends Buffer { @Override public Buffer subBuffer(int index, int size) { if (index < 0) { throw new IllegalArgumentException("index must not be negative: " + index); } else if (size < 0) { throw new IllegalArgumentException("size must not be negative: " + size); } else if (index + size > getSize()) { throw new BufferOverflowException(); } Buffer result = subBuffer0(getAddress(), index, size); subBuffers.add(result); return result; } Win32Buffer(int size);  Win32Buffer(byte[] address, int size); @Override byte[] get(); @Override void put(byte[] src); @Override Buffer subBuffer(int index, int size);  }
@Test public final void subBuffer() { byte[] src = Hex.decode("12345678"); Buffer buffer = factory.createBuffer(src.length); buffer.put(src); Assert.assertArrayEquals(Hex.decode("3456"), buffer.subBuffer(1, 2).get()); }