[Chaoblade]jvm-sandbox UnsupportedOperationException错误

本文探讨了在使用jvm-sandbox的agentchaosblade-jvm-exec时,遇到的AOP切点失效问题,原因在于与使用ByteBuddy进行字节码增强的其他agent冲突。文章引用了Arthas和SkyWalking的issue,解释了ByteBuddy多次增强同一类导致的JVM验证失败。解决方案可能涉及缓存策略或调整agent加载顺序以避免重复增强。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jvm-sandbox UnsupportedOperationException

在使用基于 jvm-sandbox 的agent chaosblade-jvm-exec 的attach java进程的时候,发现某些 AOP 切点无法被正常切到,错误如下

java.lang.unsupportedoperationexception: class redefinition failed: attempted to change superclass or interfaces 

image-20210819192342482

经过排查是跟公司内部的其他 java agent 有冲突导致的,另外一个 agent 使用 ByteBuddy 进行字节码增强的。

经过中间件同学的排查和相关资料的搜索,发现在 Arthas 和 skywalking agent之间也存在类似的问题。

相关issue如下

  • https://github.com/alibaba/arthas/issues/1502
  • https://github.com/alibaba/arthas/issues/1141
  • https://github.com/apache/skywalking/blob/master/docs/en/FAQ/Compatible-with-other-javaagent-bytecode-processing.md

从最后一个链接能看到pr作者的原因描述。

The SkyWalking agent uses ByteBuddy to transform classes when the Java application starts. ByteBuddy generates auxiliary classes with different random names every time.

When another Java agent retransforms the same class, it triggers the SkyWalking agent to enhance the class again. Since the bytecode has been regenerated by ByteBuddy, the fields and imported class names have been modified, and the JVM verifications on class bytecode have failed, the retransform classes would therefore be unsuccessful.

ByteBuddy 对同一个class进行多次 enhance,但是每次生成的辅助类又不一样,加了一个缓存,这样就避免多次 增强。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值