Instead of relying on JDK API, implement an in-place version of reversion using a simple state machine.