Hi guys,
I'm development an application using Hot Deplyment strategy, but I found some problems. When I try intercept a method that retuns some value the application performs normal, but when I try intercept a method that returns void occurs an exception.
protected final void mockMethod(String className, String method, Object obj) throws Exception {
Class c = sysClassLoader.loadClass(className);
String expr = "execution(* " + c.getName() + "->" + method + "(..))";
// checks method integrity
int methodCount = c.getMethods().length;
boolean found = false;
for(int i=0; i < methodCount; i++) {
Method m = c.getMethods();
if (m.getName().equals(method)) {
found = true;
if (!Modifier.isPublic(m.getModifiers()) && !Modifier.isStatic(m.getModifiers())) {
return;
}
if (m.getReturnType().getName().equals("void")) {
expr = "execution(public void " + c.getName() + "->" + method + "(..))";
}
}
}
...
}
As you can see above, I create at runtime the pointcut expression. When method returns void, so I tried to use expression starts with 'call' don't occurs error and 'invoke' method of the interceptor don't fired, but when expression starts with 'execution' occurs NullPointer Exception error.