java rewrite