sermant-io / Sermant

A Cloud-Native Proxyless Service Mesh based on Java Bytecode Enhancement Technology
https://sermant.io/
Apache License 2.0
1.26k stars 170 forks source link

attempted duplicate class definition for name ,"BootstrapInstTemplate" #335

Closed whispin closed 2 years ago

whispin commented 2 years ago

question description: I tried to develop a plugin, but I found some problems when debugging, java.lang.LinkageError: loader (instance of sun/misc/Launcher$AppClassLoader): attempted duplicate class definition for name: "com.huawei.sermant.core.agent.template.BootstrapInstTemplate__246a5df2"

HapThorin commented 2 years ago

When you use old-style enhancement code, EnhanceDefinitions enhanced same Class should be aggregated into one Transformer. That means each enhanced method will be enhanced for once. I don't understand how BootStrapInstTemplate was created twice. Maybe you can provide more information to me, such as stacks, logs or enhanced classes and methods.

However, for the new-style enhancement code, when multiple PluginDescriptions enhance the same method of the class loaded by BootsSrapClassLoader, the problem described by you will indeed occur. I have written the relevant code fixes, and @xuezechao1 will submit them in a short time.

whispin commented 2 years ago

Thanks for your answer, I learned a lot from the sermant.