Fix child/parent class enhancement issue during retransform#756
Fix child/parent class enhancement issue during retransform#756lujiajing1126 wants to merge 9 commits intomainfrom
Conversation
There was a problem hiding this comment.
license-eye has totally checked 5486 files.
| Valid | Invalid | Ignored | Fixed |
|---|---|---|---|
| 5240 | 2 | 244 | 0 |
Click to see the invalid file list
- apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ChildBar.java
- apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ParentBar.java
...er/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ChildBar.java
Show resolved
Hide resolved
...r/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ParentBar.java
Show resolved
Hide resolved
...sniffer/bytebuddy-patch/src/main/java/net/bytebuddy/agent/builder/SWDescriptionStrategy.java
Outdated
Show resolved
Hide resolved
| private final TypeDescription.Generic superGeneric; | ||
|
|
||
| protected ForLoadedSuperClassWrapper(TypeDescription delegation, TypeDescription.Generic superGeneric) { | ||
| super(null); // HACK: a trick here since type is not used anywhere in the wrapper |
There was a problem hiding this comment.
Has the wrapper overrided all methods of ForLoadedSuperClass? I want to guarantee that the null would not be used unexpectedly.
If yes, could you add a UT to check that? This could prevent upgrade issue if byte-buddy core adds a method in the future.
|
An alternative solution: To avoid missing methods in subclass, use builder = builder.defineField(
CONTEXT_ATTR_NAME, Object.class, ACC_PRIVATE | ACC_VOLATILE)
.implement(EnhancedInstance.class)
// .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME))
.defineMethod("getSkyWalkingDynamicField", Object.class, Visibility.PUBLIC)
.intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME))
.defineMethod("setSkyWalkingDynamicField", void.class, Visibility.PUBLIC).withParameters(Object.class)
.intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)); |
|
This seems easier and not hacking? @lujiajing1126 Could you take a look at this proposal? |
Great. It looks more straight-forward. @tjuwangning pls raise a new PR |
Here is the new PR: #757 |
|
Closed in favor of #757 |
Fix retransform bug if parent class has also been enhanced
Add a unit test to verify that the fix works.
Explain briefly why the bug exists and how to fix it.
If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.
Update the
CHANGESlog.This PR adds a unit test to reproduce a retransform issue:
When a child class extends a parent class and the both classes need to be enhanced by SkyWalking Agent, retransform will fail since
getter/setterare not generated in the child class.