Well, Sojan, if you don't know where to get the object from how should I? ;-) I suggest you derive your ClassA by something like ClassAMock and inject it, i.e. use an instance of it as a return value. Mock testing is state of the art and you can easily return a subclass instance if the return value is ClassA. Providing a mock should be the whole purpose of your setup, I suppose.
Pretty simple, isn't it? :-) Alexander Kriegisch Am 04.06.2013 um 13:41 schrieb Sojan Mathew <sojanmat...@gmail.com>: > Hi Alexander, > Thank you for the reply. > Basically what I need is, bypass constructor call. In around advice, from > where I can get object to be returned? (I'm NOT calling proceed inside > around, to bypass constructor body execution) > > How can bypass constructor body execution? > Regards > Sojan > > > > On Tue, Jun 4, 2013 at 3:19 PM, Alexander Kriegisch > <alexan...@kriegisch.name> wrote: >> The error message says it: You are intercepting a call which does not return >> void (but ClassA). Consequently, your around advice should also return >> ClassA. >> >> Alexander Kriegisch >> >> Am 04.06.2013 um 11:33 schrieb Sojan Mathew <sojanmat...@gmail.com>: >> >>> 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 >>> _______________________________________________ >>> aspectj-users mailing list >>> aspectj-users@eclipse.org >>> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> >> _______________________________________________ >> aspectj-users mailing list >> aspectj-users@eclipse.org >> https://dev.eclipse.org/mailman/listinfo/aspectj-users > > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users