Skip to content

Commit 69d8fb8

Browse files
committed
add a wrapper
1 parent 072e898 commit 69d8fb8

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

apm-sniffer/bytebuddy-patch/src/main/java/net/bytebuddy/agent/builder/SWDescriptionStrategy.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,10 @@ public Generic getSuperClass() {
332332
if (delegateSuperClass == null) {
333333
return null;
334334
}
335-
this.superClass = new SWTypeDescriptionWrapper(delegateSuperClass.asErasure(), this.nameTrait, delegateSuperClass.getClass().getClassLoader(), delegateSuperClass.getClass().getName()).asGenericType();
335+
this.superClass = new ForLoadedSuperClassWrapper(
336+
this.delegate.getClass(),
337+
new SWTypeDescriptionWrapper(delegateSuperClass.asErasure(), this.nameTrait, delegateSuperClass.getClass().getClassLoader(), delegateSuperClass.getClass().getName())
338+
);
336339
}
337340
return this.superClass;
338341
}
@@ -363,6 +366,30 @@ public int getModifiers() {
363366
}
364367
}
365368

369+
static class ForLoadedSuperClassWrapper extends TypeDescription.Generic.LazyProjection.ForLoadedSuperClass {
370+
private final TypeDescription delegation;
371+
372+
/**
373+
* Creates a new lazy projection of a type's super class.
374+
*
375+
* @param type The type of which the super class is represented.
376+
*/
377+
protected ForLoadedSuperClassWrapper(Class<?> type, TypeDescription delegation) {
378+
super(type);
379+
this.delegation = delegation;
380+
}
381+
382+
@Override
383+
protected TypeDescription.Generic resolve() {
384+
return this.delegation.asGenericType();
385+
}
386+
387+
@Override
388+
public TypeDescription asErasure() {
389+
return this.delegation;
390+
}
391+
}
392+
366393
static class TypeCache {
367394
private String typeName;
368395
private Set<Integer> methodCodes;

0 commit comments

Comments
 (0)