0

Trying to understand the difference between these 2 approaches

MethodSignature signature = (MethodSignature) joinPoint.getSignature();  
Abc abc = methodSignature.getMethod().getAnnotation(Abc.class);

vs

MethodSignature signature = (MethodSignature) joinPoint.getSignature();  
String methodName = signature.getMethod().getName();  
Class<?>[] parameterTypes = signature.getMethod().getParameterTypes();  
Abc abc = joinPoint.getTarget().getClass().getMethod(methodName,   parameterTypes).getAnnotation(Abc.class);

when would result of these approaches be different

Andy Turner
  • 137,514
  • 11
  • 162
  • 243
Vimal
  • 1
  • 1
  • Why do you think they might be different? What happened when you tried them both? Where do these two approaches come from? – Andy Turner Dec 07 '16 at 11:19
  • The obvious thing here is that the second approach gives you access to the method name itself and the types of the method parameters, but unless you actually need those for this specific annotation processing the approach seems too excessive compared to the first one. – Ceiling Gecko Dec 07 '16 at 11:24
  • @AndyTurner I did not find any difference. Someone suggested the second one is the better way based on http://stackoverflow.com/questions/6604428/get-annotated-parameters-inside-a-pointcut. Wanted to check if there would be any difference ever? – Vimal Dec 07 '16 at 18:18

0 Answers0