Japanese stocks record their ninth weekly gain in a row