I have an annotated class (ConnectorServiceInterceptor) containing some AspectJ around advices.
e.g.:
@Around("execution(void Service.removeConnector(long))")
public void removeConnector(ProceedingJoinPoint pjp) throws Throwable {
// do stuff
}
I have a Spring configured bean exposing some methods which are configured in Terracotta to be distributed. This works ;)
Executing the method on application 1 also executes the method on application 2.
The problem is that when starting my application, I get the following exception:
Code:
com.tc.aspectwerkz.exception.DefinitionException: Could not register parameter named args from register 2 for removeConnector_aroundBody3$advice.(LDefaultConnectorService;JLorg/aspectj/lang/JoinPoint;LConnectorServiceInterceptor;Lorg/aspectj/lang/ProceedingJoinPoint;)V
at com.tc.aspectwerkz.reflect.impl.asm.AsmMethodInfo.pushParameterNameFromRegister(AsmMethodInfo.java:246)
at com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfo$MethodParameterNamesCodeAdapter.visitLocalVariable(AsmClassInfo.java:971)
at com.tc.asm.ClassReader.accept(ClassReader.java:1121)
at com.tc.asm.ClassReader.accept(ClassReader.java:300)
at com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfo.<init>(AsmClassInfo.java:184)
at com.tc.aspectwerkz.reflect.impl.asm.AsmClassInfo.getClassInfo(AsmClassInfo.java:301)
...
When I launch the application without Terracotta I don't receive any exceptions.
I haven't seen that before, but it sure looks more like a bug than a feature :-)
Is it possible to get the bytecode for the class containing that weaved in aspect? I'm not super familiar with how aspectJ weaving works. I'd be looking for the bytes to whatever class the method "removeConnector_aroundBody3$advice" is introduced into.
Alternatively, if you package up a little bit of a complete example that fails with terracotta, it would help us debug it.
Thank you for your prompt reply. I was afraid not being able to reproduce this problem with an easy sample, but I managed ;)
Attached file throws the exception mentioned in my first post in the console. It is working though so I'm not quite sure what is going on.
I don't have a answer yet, but I do have the code running and producing the same exception locally (which is at least half of the battle). Many thanks for creating the test case!!
Little closer -- looks like this has something do with Terracotta's instrumentation around array access. Commenting out array operations in the removeConnetor advice avoids the exception
Code:
@Around("execution(void test.ConnectorService.removeConnector(long))")
public void removeConnector(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("i Remove");
// Object[] args = pjp.getArgs();
// long id = (Long) args[0];
pjp.proceed(pjp.getArgs());
// System.out.println(id);
}
Still digging on the underlying issue. Just keeping everyone posted
I spoke too soon...commenting out the array operations in that advice has the side effect of eliminating all local variables (the real source of the issue). More details to come
It seems that the AspectJ compiler is failing to update the local variable information correctly. We will be reporting the problem to the AJ developers shortly.
Although it is ugly and annoying to see that exception being printed, it should not be causing any issues to your application or the function of Terracotta.