use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project incubator-skywalking by apache.
the class MethodAnnotationMatch method isMatch.
@Override
public boolean isMatch(TypeDescription typeDescription) {
for (MethodDescription.InDefinedShape methodDescription : typeDescription.getDeclaredMethods()) {
List<String> annotationList = new ArrayList<String>(Arrays.asList(annotations));
AnnotationList declaredAnnotations = methodDescription.getDeclaredAnnotations();
for (AnnotationDescription annotation : declaredAnnotations) {
annotationList.remove(annotation.getAnnotationType().getActualName());
}
if (annotationList.isEmpty()) {
return true;
}
}
return false;
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class GenericSignatureResolutionTest method testGenericMethodWithoutGenericExceptionTypes.
@Test
public void testGenericMethodWithoutGenericExceptionTypes() throws Exception {
DynamicType.Unloaded<?> unloaded = new ByteBuddy().redefine(GenericMethod.class).method(named(BAR)).intercept(FixedValue.nullValue()).make();
Class<?> type = unloaded.load(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassLoadingStrategy.Default.WRAPPER).getLoaded();
MethodDescription createdMethod = new MethodDescription.ForLoadedMethod(type.getDeclaredMethod(BAR, Object.class));
MethodDescription originalMethod = new MethodDescription.ForLoadedMethod(GenericMethod.class.getDeclaredMethod(BAR, Object.class));
assertThat(createdMethod.getTypeVariables(), is(originalMethod.getTypeVariables()));
assertThat(createdMethod.getReturnType(), is(originalMethod.getReturnType()));
assertThat(createdMethod.getParameters().getOnly().getType(), is(originalMethod.getParameters().getOnly().getType()));
assertThat(createdMethod.getExceptionTypes().getOnly(), is(originalMethod.getExceptionTypes().getOnly()));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class GenericSignatureResolutionTest method testGenericMethod.
@Test
public void testGenericMethod() throws Exception {
DynamicType.Unloaded<?> unloaded = new ByteBuddy().redefine(GenericMethod.class).method(named(FOO)).intercept(FixedValue.nullValue()).make();
Class<?> type = unloaded.load(ClassLoadingStrategy.BOOTSTRAP_LOADER, ClassLoadingStrategy.Default.WRAPPER).getLoaded();
MethodDescription createdMethod = new MethodDescription.ForLoadedMethod(type.getDeclaredMethod(FOO, Exception.class));
MethodDescription originalMethod = new MethodDescription.ForLoadedMethod(GenericMethod.class.getDeclaredMethod(FOO, Exception.class));
assertThat(createdMethod.getTypeVariables(), is(originalMethod.getTypeVariables()));
assertThat(createdMethod.getReturnType(), is(originalMethod.getReturnType()));
assertThat(createdMethod.getParameters().getOnly().getType(), is(originalMethod.getParameters().getOnly().getType()));
assertThat(createdMethod.getExceptionTypes().getOnly(), is(originalMethod.getExceptionTypes().getOnly()));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class AbstractTypeDescriptionGenericTest method testMethodTypeVariableIsRetained.
@Test
public void testMethodTypeVariableIsRetained() throws Exception {
TypeDescription.Generic typeDescription = describeType(MemberVariable.class.getDeclaredField(FOO));
assertThat(typeDescription.getSort(), is(TypeDefinition.Sort.PARAMETERIZED));
assertThat(typeDescription.getTypeArguments().size(), is(2));
assertThat(typeDescription.getTypeArguments().get(0).getSort(), is(TypeDefinition.Sort.NON_GENERIC));
assertThat(typeDescription.getTypeArguments().get(0).asErasure().represents(Number.class), is(true));
assertThat(typeDescription.getTypeArguments().get(1).getSort(), is(TypeDefinition.Sort.NON_GENERIC));
assertThat(typeDescription.getTypeArguments().get(1).asErasure().represents(Integer.class), is(true));
MethodDescription methodDescription = typeDescription.getDeclaredMethods().filter(named(FOO)).getOnly();
assertThat(methodDescription.getReturnType().getSort(), is(TypeDefinition.Sort.VARIABLE));
assertThat(methodDescription.getReturnType().getSymbol(), is("S"));
assertThat(methodDescription.getReturnType().getTypeVariableSource(), is((TypeVariableSource) methodDescription.asDefined()));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.method.MethodDescription in project byte-buddy by raphw.
the class AbstractTypeDescriptionGenericTest method testMethodTypeVariableWithExtensionErasedBound.
@Test
public void testMethodTypeVariableWithExtensionErasedBound() throws Exception {
TypeDescription.Generic typeDescription = describeType(MemberVariable.class.getDeclaredField(BAR)).getSuperClass();
assertThat(typeDescription.getSort(), is(TypeDefinition.Sort.NON_GENERIC));
MethodDescription methodDescription = typeDescription.getDeclaredMethods().filter(named(QUX)).getOnly();
assertThat(methodDescription.getReturnType().getSort(), is(TypeDefinition.Sort.NON_GENERIC));
assertThat(methodDescription.getReturnType().asErasure(), is(TypeDescription.OBJECT));
}
Aggregations