Java rewrite engine

Creating a pull request to track the merge into master, but I don't intend to actually have anyone review it.