-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use Instrumentation#retransformClasses to hotswap #566
base: master
Are you sure you want to change the base?
Conversation
I have very similar idea, btw, where is the |
The second problem I see is atomicity. Each redefinition batch should be isolated from the others. In your solution, two consecutive hotswap() calls, R1 and R2, could redefine the same class, R1.C and R2.C, and only the last change (R2.C) would be processed by the redefinition. This could lead to a linkage error in DCEVM. |
|
If it is truly necessary to address atomicity issues, the following solution can be considered:
|
May be there could a que of byte code be for each class in the weak map and the retransform method would pop bytecode from the que. |
However, in extreme cases, confusion may still occur. For example, if another Java agent modifies the bytecode of the same class, triggering a redefine or reTransform, it becomes impossible to distinguish where the Transformer's callback was triggered from. |
I think that using queue+pop is better than overriding and retaining unnecessary bytecode in the map. When autoHotswap=true is enabled, there could be numerous redefinitions. Minecraft developers have reported that they can fill 500MB to 1GB of code cache with redefined classes. |
Retaining the final byte[] is necessary. Otherwise, if other Java agents trigger a redefine/retransform, it will cause the hotswap to no longer be effective. One possible approach is to implement a disk-based cache, writing the byte[] to disk. |
Interesting. I'll take some time to look into this. In the meantime, could you share more about your use case? I'm really curious. |
We are currently facing an issue when using the hotswap agent: Users are unsure whether a modified class has been successfully hot-updated. Although there may be some log outputs, users still do not know if the changes have taken effect. We are considering allowing users to retrieve the runtime bytecode to determine if it has taken effect, for example, using: https://arthas.aliyun.com/en/doc/jad.html. Therefore, we strongly prefer to use |
If logging of redefinition is only reason for it then I recommend to use |
#564