The
application under test is Log4J.
The
constructor in question is:
protected Level(int level, String levelStr, int syslogEquivalent) {
super(level, levelStr, syslogEquivalent);
}
Super:
protected
Priority(int level, String levelStr, int syslogEquivalent) {/*just assignments
here…*/}
The stack
goes:
TestRanking.ajc$before$testrank_TestRanking$6$69466523(JoinPoint$StaticPart,
JoinPoint) line: 160
Level.<init>(int,
String, int) line: 104
Priority.<clinit>()
line: 45
LogManager.<clinit>()
line: 80
Logger.getRootLogger_aroundBody4(JoinPoint)
line: 136
Logger.getRootLogger_aroundBody5$advice(JoinPoint,
TestRanking, AroundClosure, JoinPoint$StaticPart) line: 183
Logger.getRootLogger()
line: 136
LoggingEventTest.getRootLogger_aroundBody0(LoggingEventTest,
JoinPoint) line: 53
LoggingEventTest.getRootLogger_aroundBody1$advice(LoggingEventTest,
JoinPoint, TestRanking, AroundClosure, JoinPoint) line: 108
LoggingEventTest.testSerializationSimple()
line: 53
…
There
seems to me there is some confusion in the stack:
public
void testSerializationSimple() throws Exception {
Logger root = Logger.getRootLogger();
// LoggingEventTest.testSerializationSimple() line: 53
à
public void testSerializationNDC() throws Exception {
Logger root = Logger.getRootLogger(); // LoggingEventTest.getRootLogger_aroundBody1$advice(LoggingEventTest,
JoinPoint, TestRanking, AroundClosure, JoinPoint) line: 108
I do have
some around() advices but I never reach them in the debugger before the
before() J
How can
it be that the stack flows from the execution of one method (line 53) directly
to the execution of a different method that was never called from the first
method (line 108)?
Hagai
-----Original
Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement
Sent: Thursday, March 18, 2010 10:20 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] null thisJoinPointStaticPart when advising
constructor execution
Can you
tell me what kind of constructors lead to that being null? A
simple (complete)
program that fails would be great. This program:
---
aspect
Test
{
public static void main(String []argv) {
new C();
}
pointcut methodUnderTestExecution1() :
(execution(*
*(..)) || execution(new(..))) && !within(Test);
before(): methodUnderTestExecution1() {
Object sig = thisJoinPointStaticPart.getSignature();
System.out.println(sig);
}
}
class C { }
---
works
fine and prints C().
cheers
Andy
On 18 March
2010 13:09, Hagai Cibulski <hagaic@xxxxxxxxx> wrote:
> Hi All!
>
> Could use some help here…
>
>
>
> I'm tracing methods execution stemming from JUnit tests
using AspectJ, using
> the following pointcut:
>
> pointcut
methodUnderTestExecution() :
>
>
execution(* *(..))
>
>
&& mutFilter();
>
>
>
> before(): methodUnderTestExecution() {
>
>
Signature sig = thisJoinPointStaticPart.getSignature();
>
>
…
>
> So far, that works fine!
>
>
>
> However, when trying to add constructor execution to the
pointcut, I get
> some unexpected behaviors:
>
>
>
> pointcut
methodUnderTestExecution1() :
>
>
(execution(* *(..)) || execution(new(..)))
>
>
&& mutFilter();
>
>
>
> before(): methodUnderTestExecution1() {
>
>
Signature sig = thisJoinPointStaticPart.getSignature();
>
>
// thisJoinPointStaticPart == null L
>
>
…
>
>
>
> For some constructors in the application under test the
advice causes
> NullPointerException because thisJoinPointStaticPart == null
>
>
>
> Anyone?
>
>
>
>
>
> Thanks,
>
> Hagai
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users
mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users