#14
Mausschubser
Beiträge: 80
Registriert: 7. Dez 2007 13:54

sorry to bother again.

"Hint: By default only one instance of an aspect is instantiated per virtual machine. As covered in the lecture, you can change this with aspect associations (perthis, pertarget, percflow, percflowbelow, etc.), which are added to the signature of the aspect."

i already spent 5 hours on this one task and i seem to not get anywhere with it...

sproksch
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

Ok... ignore the hint for a second. What is your current problem with this task?

#14
Mausschubser
Beiträge: 80
Registriert: 7. Dez 2007 13:54

well... aspectJ is obviously new to me, so i'm trying to familiarize myself with all the options (syntax) aspectJ has to offer and which of those might be able to help me solve the task. the little information that can be found online seems not to be very helpful for me either. one of my many questions: how can i distinguish between method calls made from outside my package and those made within one of my function.run(int) methods... target and this seem to be always the same.

#14
Mausschubser
Beiträge: 80
Registriert: 7. Dez 2007 13:54

if startup_calculator contains nothing but

fibonacci.run(2);

the output is supposed to be solely

RuntimeDataCollector: a call to Fibonacci
RuntimeDataCollector: ... is recursive

correct?

in order to do that i need to be able to tell whether the method call was made from startup_calculator or from fibonacci itself... while the method call from startup_calculator doesn't get recognized at all since its outside the package, the execution shows fibonacci for this and target...

#14
Mausschubser
Beiträge: 80
Registriert: 7. Dez 2007 13:54

i just found this

thisJoinPoint.getSourceLocation()

maybe it will help.

i'm still open for hints and suggestions...

Mirlix_
Endlosschleifenbastler
Beiträge: 188
Registriert: 3. Mär 2006 14:57

I solved this problem with cflowbelow, an important information that I missed at the beginnging was that cflow and cflowbelow can be added to the aspect and to the advice cflow and cflowbelow both can take the pointcut as a parameter. With this it is possible to have an advice for a call from outside the class and an advice for calls from inside the class. Hope this helps.
"If you want more effective programmers, you will discover that they should not waste their time debugging, they should not introduce the bugs to start with." Edsger W. Dijkstra

sproksch
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

Try it with a different approach... When you are looking for good pointcuts, think about the execution in terms of a stack trace. Every control flow is just a list of called methods in this case.

In addition to this I'm not sure why you take the packages into account... possible subclasses of "Function" may be implemented in any package, so I think this does not help you at all. Instead of matching packages, you could try to reason about the control flow... is it possible to distinguish between an initial function call and subsequent ones?

#14
Mausschubser
Beiträge: 80
Registriert: 7. Dez 2007 13:54

Try it with a different approach... When you are looking for good pointcuts, think about the execution in terms of a stack trace. Every control flow is just a list of called methods in this case.
i am totally aware of that.
is it possible to distinguish between an initial function call and subsequent ones?
exactly one of my questions... i'm guessing yes, but the question is how...

sproksch
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

How does a stack trace of a nested call look like?

#14
Mausschubser
Beiträge: 80
Registriert: 7. Dez 2007 13:54

it maps the internal method calling sequences of the nested call?

sproksch
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

What do you mean with "maps the calling"?

Do you know any possibility from the lecture to create a pointcut that matches (or does not match) depending on the current control flow?

#14
Mausschubser
Beiträge: 80
Registriert: 7. Dez 2007 13:54

well... i'm guessing i need something like this:

Code: Alles auswählen

after(Shape shape) returning: shapeChange(shape)
&& !cflowbelow(shapeChange()) {
Display.update(shape);
}


sproksch
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

You are guessing right If you have understood the construct cflowbelow you should be able to define pointcuts for initial function calls and subsequent ones...

Senchy
Windoof-User
Beiträge: 37
Registriert: 6. Okt 2010 19:14