Add "FrameTrackingAdapter" for incremental stackmap frame updates
With the latest Java versions correct stackmap frames become more and more
important. Re-calculating frames is an expensive task and comes with the pain
to figure out type hierarchies ("getCommonSuperClass()").
For most instrumentation tasks it is possible to incremetally update frames.
For this you need to know the current frame types, to insert additional frames
as needed by your instrumentation code. For the JaCoCo project I developed a
"FrameTracker":
https://github.com/jacoco/jacoco/blob/master/org.jacoco.core/src/org/jacoco/core/internal/instr/FrameTracker.java
It is a MethodVisitor that keeps track of the current types of the local
variables and the operand stack. This class can be used to instrument class
files with stackmap frame information without re-calculating the overall type
information. If the additional code requires an additional frame due to the
control structure it adds this frame can be inserted with a call to insertFrame().
As it seems to be a generic and useful piece of code it might make sense to
provide such functionality directly within ASM. I adjusted the code and its
tests for ASM:
https://github.com/marchof/asm/commit/bffcf692983c9dda2a4e38afcaab8da0fe4e28c2