Monitor Transformer
A Transformer that rewrites synchronized
blocks produced by older versions of the Java compiler (1.3 and older) into a more modern format. This is required for compatibility with Fernflower, which does not understand the older format.
This transformer depends on JSRInlinerAdapter.
It makes three changes:
Inlines
MONITOREXIT
subroutines. JSRInlinerAdapter only replacesJSR
/RET
calls withGOTO
. Fernflower needs the actual body of the subroutine to be inlined.Extends exception handler ranges to cover the
MONITOREXIT
instruction.Replaces
ASTORE ALOAD MONITORENTER
sequences withDUP MONITORENTER
, which prevents Fernflower from emitting a redundant variable declaration.
There is one final difference that this transformer does not deal with: modern versions of the Java compiler add a second exception handler range to each synchronized block covering the MONITOREXIT
sequence, with the handler pointing to the same MONITOREXIT
sequence. Adding this isn't necessary for Fernflower compatibility.