Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] problem with pointcut capturing the second ar gument of a constructor call

Hi Elizabeth,
You're partly correct; the pointcut should have been:


    pointcut emailConstruction(String[] to) :
        call(public werner.ais.battery.util.Email.new(..))
        && args(*, to,..);

With "to", instead of String[], in the args list (I originally posted a version that got changed around when I was trying out different things!); I'm following the example on page 191 of the _Eclipse AspejctJ_ book (by Colyer, Clemet, Harley, and Webster).  They list several wildcard patterns for binding the second parameter of an argument list:

args(*, arg2, *, *, *)
args(*, arg2, ..)
args(..,arg2,..)
args(..,arg2,*, *, *)

Where arg2, in my case, is "to".  The first and last ones won't work for me, because they specify a determinate number of parameters after arg2; I'm trying to write a pointcut which will capture 2 constructors-- one with 2 arguments after "to", and one with a variable number (varargs) parameter after "to".  For both, I know that "to" is the second parameter, but I don't know how many arguments will follow it, so the second option above seemed to be the best choice, but I cannot seem to get it to compile.  Even with changing "String[]" to "to" in the args list, it still give me the same compile error:  "Syntax error on token ";", Type expected after this token". 

I did also try the way you suggest:  "args(*, String[] to, ..)", but that gives me 2 errors:  the original error, and "Syntax error on token "to"; ")" expected", so I don't think that's the way to go.  (Thanks for the suggestions, though-- it did help me find a mistake!).

This is driving me nuts..If anyone has any suggestions, I'd really appreciate it!

Thanks,
Tim



On 10/4/07, Echlin Harmer, Elizabeth <echline@xxxxxxx> wrote:
Hi Tim
Is the problem that you have declared you are collecting context "emailConst(String[] to)" but you haven't bound it to any args?
i.e. should it be "&& args(*, String[] to, ..);"
Elizabeth
-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx]On Behalf Of Timothy Perrigo
Sent: October 4, 2007 1:39 PM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] problem with pointcut capturing the second argument of a constructor call

This really has me stumped...according to everything I've read, I think the pointcut below should accomplish what I need, but I cannot get it to compile (I'm getting the following compile error:  "Syntax error on token ";", Type expected after this token").

Here is the pointcut definition:

    pointcut emailConstruction(String[] to) :
        call(public werner.ais.battery.util.Email.new(..))
        && args(*, String[] ,..);

I'm trying to define a pointcut on a constructor call for the Email class, and I want to capture the second argument (which is a String array).  The error message is coming from the last line of the pointcut (the args(*, String[], ..) part).  I'm stumped...Does anyone know what I might be doing wrong?

Any suggestions would be very much appreciated!

Thanks,
Tim





CONFIDENTIAL AND PRIVILEGED INFORMATION NOTICE

This e-mail, and any attachments, may contain information that
is confidential, subject to copyright, or exempt from disclosure.
Any unauthorized review, disclosure, retransmission, 
dissemination or other use of or reliance on this information 
may be unlawful and is strictly prohibited.  

AVIS D'INFORMATION CONFIDENTIELLE ET PRIVILÉGIÉE

Le présent courriel, et toute pièce jointe, peut contenir de 
l'information qui est confidentielle, régie par les droits 
d'auteur, ou interdite de divulgation. Tout examen, 
divulgation, retransmission, diffusion ou autres utilisations 
non autorisées de l'information ou dépendance non autorisée 
envers celle-ci peut être illégale et est strictement interdite.

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top