Add the reference Java implementation