Redefinition of classes
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.
- This method is only available since Java6, so Java5 applications cannot use this feature. (For java5 application, we thus have to disable redefinition)
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.No this is possible, but only if we instrument on the agent, that is do the instrumentation synchronously on the agent.
Open questions/problems
- What about bytecode modifications that were not done with a java.lang.instrumentation transformer? Are there any other options of doing this?