Merge change 6871 into donut

* changes:
  Use SetByteArrayRegion to minimize copy overhead and JNI calls.