The target is to insert codes to monitor the entry and exit of Java synchronized block.
i.e.
enteringSync();
synchronized(lockObj){
enteredSync();
...
leavingSync();
}
leftSync();
My original thought was to implement the enter/exit listener methods (which add subtrees around the Java synchronizd block), then to print out the resultant AST. Now I realized that antlr4 doesn't seem to support tree modification, what alternatives should I consider?