Avoid resolving TypeDescriptions when validating advice methods
@@ -448,7 +448,7 @@ public class ElasticApmAgent {
}
for (MethodDescription.InDefinedShape exitAdvice : typeDescription.getDeclaredMethods().filter(isStatic().and(isAnnotatedWith(Advice.OnMethodExit.class)))) {
validateAdviceReturnAndParameterTypes(exitAdvice);
- if (exitAdvice.getReturnType().getTypeName().startsWith("co.elastic.apm")) {
+ if (exitAdvice.getReturnType().asRawType().getTypeName().startsWith("co.elastic.apm")) {
throw new IllegalStateException("Advice return type must be visible from the bootstrap class loader and must not be an agent type.");
}
for (AnnotationDescription exit : exitAdvice.getDeclaredAnnotations().filter(ElementMatchers.annotationType(Advice.OnMethodExit.class))) {
@@ -463,11 +463,11 @@ public class ElasticApmAgent {
}
private static void validateAdviceReturnAndParameterTypes(MethodDescription.InDefinedShape advice) {
- if (advice.getReturnType().getTypeName().startsWith("co.elastic.apm")) {
+ if (advice.getReturnType().asRawType().getTypeName().startsWith("co.elastic.apm")) {
throw new IllegalStateException("Advice return type must not be an agent type: " + advice.toGenericString());
}
for (ParameterDescription.InDefinedShape parameter : advice.getParameters()) {
- if (parameter.getType().getTypeName().startsWith("co.elastic.apm")) {
+ if (parameter.getType().asRawType().getTypeName().startsWith("co.elastic.apm")) {
throw new IllegalStateException("Advice parameters must not contain an agent type: " + advice.toGenericString());
}
}
