chaitanya.kothapalli (1) [Avatar] Offline
#1
Thx ramnivas for ur awesome book ..
I have a query on using declare warning and declare error pointcut .
For ex : i m planning to write a aspect which warns the user at compile time if any method in the code i am considering exceeds for eg 5 parameters .

1) Is it possible to write an aspect for the above which detects at compile time using declare warning or error ??
2) When using declare warning .. can we write code that does some conditional checks or execute some code in the pointcut itself to find issues which can be detected at compile time like in the above example i have mentioned .

Thx in advance...
ramnivas (171) [Avatar] Offline
#2
Re: are conditional checks or execute code possible in dec warning pointcut
I am glad you liked the book.

For the first query, use a statement such as:
declare error: execution(* *(*,*,*,*,*,*,..)) : "Methods with more than 5 arguments considered harmful!";

The second requirement cannot be satisfied with static crosscutting alone, since the check for arguments value needs to happen during runtime.

-Ramnivas