We learned, that
- the redefineClass method of the java.lang.instrumentation API cannot be used. For this to work we would need the bytecode in order to apply our instrumentations to. The problem is that we do not know if some other transformation was done after our javaagent ran
- the retransformClasses method of the java.lang.instrumentation API seems to be a better match. This allows to apply all java.lang.instrument.Transformers again on the original bytecode. So we do not have to store the bytecode, the JVM has to do that for us. Our transformer has to provide the flag that retransformation is possible.
What about our asynchronous redefinition approach:
- redefinition has to be started on the agent and will result in the inspectIT transformer to be executed again.
- As far as I get it there is no guarantee that the order of transformers that are executed is constant.
- I think it is not possible thus to do the instrumentation asynchronously from the point of view of the agent. Rather the instrumentation process within the transformer has to be synchronous.