import java.nio.ByteBuffer; public class BugReproduce { public static void main(final String args[]) { final byte[] data = new byte[512 * 1024]; long start = System.nanoTime(); for (int i = 0; i < 10000; i++) { final ByteBuffer buffer = ByteBuffer.wrap(data); while (buffer.position() < buffer.limit()) { buffer.get(); } } long end = System.nanoTime(); System.out.println("Execution took: " + (end - start) + " nanoseconds"); start = System.nanoTime(); for (int i = 0; i < 10000; i++) { final ByteBuffer buffer = ByteBuffer.wrap(data); while (buffer.position() < buffer.limit()) { buffer.put((byte) 0); } } end = System.nanoTime(); System.out.println("Execution took: " + (end - start) + " nanoseconds"); } }