英文:
Change parent of the class using instrumentation
问题
I have a class called Client, it is extending Connection class, I want to make a class called KConnection which extends Connection class, and I want that the parent of the Client should not be Connection but it should be KConnection using bytebuddy agent in the premain using AgentBuilder(). something like this
new AgentBuilder.Default()
.type(ElementMatchers.named("Client"))
.transform(new AgentBuilder.Transformer() {
@Override
public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader) {
return builder.superclass(KConnection.class);
}
})
.installOn(inst);
Can anyone guide me over here..?
英文:
I have a class called Client, it is extending Connection class, I want to make a class called KConnection which extends Connection class, and I want that the parent of the Client should not be Connection but it should be KConnection using bytebuddy agent in the premain using AgentBuilder(). something like this
new AgentBuilder.Default()
.type(ElementMatchers.named("Client"))
.transform(new AgentBuilder.Transformer() {
@Override
public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader) {
return builder.superclass(KConnection.class);
}
})
.installOn(inst);
Can anyone guide me over here..?
答案1
得分: -1
我已经在Byte Buddy的GitHub问题页面上提出了问题,并且问题已经解决。附上参考链接。
https://github.com/raphw/byte-buddy/issues/1403
英文:
I have reached out to the byte-buddy git hub issues and it was solved. Attaching reference .
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论