You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/09/28 03:04:08 UTC
[GitHub] [skywalking] luanwenfei-venus opened a new issue, #9700: [Bug]
luanwenfei-venus opened a new issue, #9700:
URL: https://github.com/apache/skywalking/issues/9700
### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues.
### Apache SkyWalking Component
Java Agent (apache/skywalking-java)
### What happened
I have found the reason for this problem. The problem described in #9698 will occur when the classes that skywalking is intended to enhance and they are used in agents added before skywalking.
The reason ad follow :
Skywalking uses byte-buddy, when it structures byte-buddy's AgentBuilder, it select 'SinglePass (Default)' as it's 'DiscoveryStrategy'.
```
/**
* A discovery strategy that considers all loaded types supplied by {@link Instrumentation#getAllLoadedClasses()}.
*/
enum SinglePass implements AgentBuilder.RedefinitionStrategy.DiscoveryStrategy {
/**
* The singleton instance.
*/
INSTANCE;
/**
* {@inheritDoc}
*/
public Iterable<Iterable<Class<?>>> resolve(Instrumentation instrumentation) {
return Collections.<Iterable<Class<?>>>singleton(Arrays.<Class<?>>asList(instrumentation.getAllLoadedClasses()));
}
}
```
DiscovertStrategy.SinglePass will discovery all loaded classes and then if skywaling need to enhance them in AgentBuilder.installOn, they will be retransformed.

In AgentBuilder.installOn process:
1. As first step in the picture, the classes that have been not loaded will be transform,.
2. As second step in the picture,the classes tha have been loaded will be discovered by 'DiscovertStrategy.SinglePass' and will be
retransformed.
We quoted the 'instrumentation. RetransformClasses()' restrictions:
> The retransformation must not add, remove or rename fields or methods, change the signatures of methods, **or change inheritance.**
It means that,when agent try to retransform classes, the above restrictions need to be observed.But i find that, when skywalking enhance a classes, it will change the class's inheritance.

If this class(can be system class) has been loaded by other agent before skywalking's premain,when skywalking enhance this class the Instrumentation.retransformClasses() will throw:
```
java.lang.UnsupportedOperationException: class redefinition failed: attempted to change superclass or interfaces
```
Because skywalking attemp to change a class's inheritace in retransform process.
### What you expected to happen
I hope it can help skywalking. And i expect skywalking-java can coexist with other agents.
### How to reproduce
Agent version:8.11.0
Plugin:apm-guava-eventbus-plugin
The command is like '-javaagent:xxxx-agent.jar -javaagent:skywalking-agent.jar'.
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
--
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: notifications-unsubscribe@skywalking.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] luanwenfei-venus closed issue #9700: [Bug] The reason for 'java.lang.UnsupportedOperationException: class redefinition failed: attempted to change superclass or interfaces'.
Posted by GitBox <gi...@apache.org>.
luanwenfei-venus closed issue #9700: [Bug] The reason for 'java.lang.UnsupportedOperationException: class redefinition failed: attempted to change superclass or interfaces'.
URL: https://github.com/apache/skywalking/issues/9700
--
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: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org