Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] around advice for constructor call

Hi AspectJ Community Members,

I'm using AOP for unit testing purpose. (to replace external dependency).
In my app, I'm creating object of ClassA (which is present in external lib). I want to byepass constructor call of ClassA .  I tried "call" pointcut and around advice as below, but it is not working


pointcut callClassANew() : call(  ClassA.new());
void around() : callClassANew() {
System.out.println("[AspectJ]callClassANew "+thisJoinPoint);
}

Error :
[AppClassLoader@fabe9] error at LibMocks.aj:28::0 applying to join point that doesn't return void: constructor-call(void ClassA.<init>())
[AppClassLoader@fabe9] error at AppTest.java:160::0 applying to join point that doesn't return void: constructor-call(void ClassA.<init>())


Thank you in advance for the support

Regards
Sojan

Back to the top