Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] NPE with @args

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
>>
>


Back to the top