Pure-Java diff/patch implementation