Implement bwa_java_mem function