ex09 task 3b
ex09 task 3b
sorry to bother again.
can i please get more information about the second hint in the task and about how it is supposed to help me.
"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...
can i please get more information about the second hint in the task and about how it is supposed to help me.
"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...
Re: ex09 task 3b
Ok... ignore the hint for a second. What is your current problem with this task?
Re: ex09 task 3b
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.
Re: ex09 task 3b
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...
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...
Re: ex09 task 3b
i just found this
thisJoinPoint.getSourceLocation()
maybe it will help.
i'm still open for hints and suggestions...
thisJoinPoint.getSourceLocation()
maybe it will help.
i'm still open for hints and suggestions...
Re: ex09 task 3b
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
Re: ex09 task 3b
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?
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?
Re: ex09 task 3b
i am totally aware of that.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.
exactly one of my questions... i'm guessing yes, but the question is how...is it possible to distinguish between an initial function call and subsequent ones?
Re: ex09 task 3b
How does a stack trace of a nested call look like?
Re: ex09 task 3b
it maps the internal method calling sequences of the nested call?
Re: ex09 task 3b
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?
Do you know any possibility from the lecture to create a pointcut that matches (or does not match) depending on the current control flow?
Re: ex09 task 3b
well... i'm guessing i need something like this:
Code: Alles auswählen
after(Shape shape) returning: shapeChange(shape)
&& !cflowbelow(shapeChange()) {
Display.update(shape);
}
Re: ex09 task 3b
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...

Re: ex09 task 3b
was ist necessary for the task to use this language-feature of aspectj or does it only have to work?
Our solution is more like a "hack" around this, using different pointcuts which differ by within() where the call was executed.
The output is like the expected one in the exercise but the solution might not be as clean as if we used cflowbelow
Our solution is more like a "hack" around this, using different pointcuts which differ by within() where the call was executed.
The output is like the expected one in the exercise but the solution might not be as clean as if we used cflowbelow

Re: ex09 task 3b
To be honest, I have not used "within" before, so I think I have to look at your solution to say if your solution is ok.