skywalking-java icon indicating copy to clipboard operation
skywalking-java copied to clipboard

fix:fix when enchance higher classes to hashmap cause NoClassDefFoun…

Open leihuazhe opened this issue 2 years ago • 4 comments

…dError

  • [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.
  • [ ] Update the CHANGES log.

leihuazhe avatar Aug 09 '22 12:08 leihuazhe

I change the skywalking-java-agent package for my personal using (I want a small agent, don't need many fuanctions of skywaling. ). But, when I launch the agent, here is the phenomenon: wecom-temp-826069dacbd3a3d8ba1c34b5602ba5ad

The MethodInvocationContext is before MethodInterceptResult, so when load the MethodInvocationContext , will cause java.lang.NoClassDefFoundError.

Although the order of high loader classes is not out of order in the skywalking project. But I think we should ensure the load sequence should order by the define in the class.

leihuazhe avatar Aug 09 '22 12:08 leihuazhe

image

the MethodInvocationContext is the subclass of MethodInterceptResult. if classloader load the MethodInvocationContext first, it couldn't find the MethodInterceptResult .so exception below:

java.lang. IllegalStateException Create breakpoint: java.lang.NoClassDefFoundError: com/maple/shine/apm/agent/core/plugin/interceptor/enhance/MethodInterceptResult

this is my customized class.

leihuazhe avatar Aug 09 '22 12:08 leihuazhe

I am not sure this is the case. The class files could be cross-reference. Such as A is using B, and B is using A.

If Byte-buddy is asking for a sorted class map, it should be clear on the method's comment, which I can't find it. Have you checked with byte-buddy author about your case? Because you are using our codebases for private purposes, I can't confirm your change, unless the bytebuddy side could confirm the sequence matters.

wu-sheng avatar Aug 09 '22 13:08 wu-sheng

resonable,I will check the bytebuddy's api, take some expriment.

leihuazhe avatar Aug 09 '22 13:08 leihuazhe

The bytebuddy author's replay:
If there is a dependency, you need to inject the classes in the required order.

https://github.com/raphw/byte-buddy/issues/1299

leihuazhe avatar Aug 16 '22 02:08 leihuazhe

Thanks for the update. You should update changes.md about this fix.

wu-sheng avatar Aug 16 '22 04:08 wu-sheng

finished

leihuazhe avatar Aug 16 '22 05:08 leihuazhe