kylixs opened a new pull request, #659:
URL: https://github.com/apache/skywalking-java/pull/659
<!--
⚠️ Please make sure to read this template first, pull requests that
don't accord with this template
maybe closed without notice.
Texts surrounded by `<` and `>` are meant to be replaced by you, e.g.
<framework name>, <issue number>.
Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]`
-->
### Fix error in re-transforming the jedis classr:
https://github.com/apache/skywalking/issues/11651
- [x] Add a unit test to verify that the fix works.
- [x] Explain briefly why the bug exists and how to fix it.
### What happened
* Run app with Java Agent 9.1.0, watching `redis.clients.jedis.Jedis`
with`Arthas` reported:
```
java.lang.UnsupportedOperationException: class redefinition failed:
attempted to change the schema (add/remove fields)
```
* The JDK log (Xlog) display an error is: the redefined class redis.
Clients. Jedis. Jedis fields change the error
```
[40.198s][info][redefine,class,normalize] redefined class
redis.clients.jedis.Jedis fields change error: field Ljava/lang/reflect/Method;
cachedValue$$sw$v9vk4i1$rc1vrg3 changed to Ljava/lang/reflect/Method;
cachedValue$$sw$v9vk4i1$kq3fl10.
```
* Analyze with `javap -p` and compare the bytecode before and after
retransform, it is found that the field name of the proxy method changes.
* Found the number of declaration methods returned during retransform is
increased and not in the same order. The extra methods comes from the parent
class, and the methods are evaluated in a different order each time.
### How to fix it
* `SWDescriptionStrategy`: Return original methods in the same order,
removing generated methods for delegating superclass calls and others.
* `SWMethodGraphCompilerDelegate`: Sort methods of `MethodGraph` compute
from the parent classes.
- [ ] If this pull request closes/resolves/fixes an existing issue, replace
the issue number. Closes #<issue number>.
- [ ] Update the [`CHANGES`
log](https://github.com/apache/skywalking-java/blob/main/CHANGES.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]