[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-dev] NPE with @args
|
- From: "Andy Clement" <andrew.clement@xxxxxxxxx>
- Date: Sun, 7 Dec 2008 11:33:11 -0800
- Delivered-to: aspectj-dev@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=3/2OYk6BUc+vmxSJVFgDguNsnfevmoZxYwzAttslr0Y=; b=w7VugoVlLF0W3GMlSlkiD3f2zqxVIZal5XPXYh4U1NujerwOe5mdjh2jxWERfrh1xI +KC5lRVAiT+AP6fWBH0ubPBimBwEvBMwEawf7Mv4iPKC1h3xxzobupcr0wEaKO6mHMwx YMfhD7NvJli4to/hivu/yGWfsXU/CE2R+laXU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=oIWLJyY4UkKt6to9imUfW3KWUSjL9e9sRTo90DBmgfdJEmrRHF7AZB0CuiBNIbUE7C 3Si6xKy9TGGqMA5yqGpy4Sj44ln243iUqFMmLjnhLmmF0v8GmCIpgS1n93gKHW8E8SsJ anT6l8+S/6F/8pvGozOeJRrTMQJ2ymlSZtVZ4=
Right.... last spam from me on this.... I've looked at the bug report
and can see a failure when the program is in a package.
However, I should have said in the first place that you cannot do
parameter annotation matching with @args(), that is for matching an
annotation on the type of the parameter.
@Foo
class MyAnnotatedType {}
public void m(MyAnnotatedType mat) {}
execution(* *.m(..)) && @args(Foo) // will match m
The only way to match parameter annotations is to use the syntax I
showed earlier:
public void m(MyAnnotatedType mat) {}
public void m2(@Foo String s) {}
execution(* *.m*(@Foo (*))) // will only match m2
For more information, see the 1.6.0 readme:
http://www.eclipse.org/aspectj/doc/released/README-160.html
Andy.
2008/12/7 Andy Clement <andrew.clement@xxxxxxxxx>:
> Actually... are you sure you are weaving just the place you want to?
> Your pointcut is likely to pick out all constructors then add a
> dynamic test for the annotation, if you do it using @args(). Do
> either the AJDT gutter annotations or -showWeaveInfo messages show
> more than you would expect to see?
>
> If you do raise a but, please include a full failing test program if
> you can - thanks!
>
> Andy.
>
> 2008/12/7 Andy Clement <andrew.clement@xxxxxxxxx>:
>> Hi Oliver,
>>
>> As Eric says, raise a bug for that. Although wouldn't you be better
>> off with static matching of that annotation?
>>
>> execution(*.new(@NotNull (*)))
>>
>> cheers,
>> Andy.
>>
>> 2008/12/7 Oliver Böhm <boehm@xxxxxxxxxx>:
>>> Hello,
>>>
>>> I defined a @NotNull annotation to protect in the first step constructors
>>> like this:
>>>
>>> public NotNullTest(@NotNull String s) {
>>> ...
>>> }
>>>
>>> I defined the following pointcut and (empty) advice:
>>>
>>> pointcut ctorWithNotNullArg() :
>>> execution(*..*.new(*)) && @args(NotNull);
>>>
>>> before() : ctorWithNotNullArg() {
>>> // empty
>>> }
>>>
>>> When I call the NotNullTest constructor with a null string I get a
>>> NullPointerException pointing direct to the first line of the constructor:
>>>
>>> java.lang.NullPointerException
>>> at patterntesting.check.runtime.NotNullTest.<init>(NotNullTest.java:48)
>>> at
>>> patterntesting.check.runtime.NotNullTest.testCtorNotNullArg(NotNullTest.java:76)
>>> ...
>>>
>>> I don't understand why I got a NPE here. When I use "args(String)" instead
>>> of "@args(NotNull)" it works normal. Is this behaviour a known bug or did I
>>> something wrong?
>>>
>>> regards
>>> Oliver
>>> --
>>> Oliver Böhm
>>> http://www.javatux.de
>>> _______________________________________________
>>> aspectj-dev mailing list
>>> aspectj-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>>>
>>
>