[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] capturing implicit toString() function calls
|
Ben,
>I have also tried
> String around() :
> withincode(StringBuffer StringBuffer.append(..))
&&
> call(String Integer.toString())
> {
> return "1";
> }
>In the aspect but this did not work.
Because join points "within" java.lang.StringBuffer are not exposed to the
weaver in your example.
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/
"Benjamin Mesing" <benjamin.mesing@xxxxxxxxxxxxxxx>@eclipse.org on
12/11/2004 07:19:46
Please respond to aspectj-users@xxxxxxxxxxx
Sent by: aspectj-users-admin@xxxxxxxxxxx
To: aspectj-users@xxxxxxxxxxx
cc:
Subject: Re: [aspectj-users] capturing implicit toString() function
calls
Hello,
> aspect TestAspect
> {
> before() : call (String HelloWorld.toString())
> || (call(void PrintStream.println(..)) && args(HelloWorld))
> || (call(StringBuffer StringBuffer.append(..)) &&
args(HelloWorld))
> {
> System.out.println("jpt hit");
> }
> }
Thanks, that did the trick!
The final version looks like this (based on my second example)
public aspect TestAspect
{
StringBuffer around(Integer i, StringBuffer sb) :
(call(StringBuffer StringBuffer.append(..)) && args(i))
&& target(sb) && (!within(TestAspect))
{
return sb.append(i + " became 1");
}
}
public class HelloWorld
{
public static void main(String[] args)
{
Integer i = new Integer(25);
System.out.println(""+i);
}
}
Where the output is as expected: "25 became 1".
I have also tried
String around() :
withincode(StringBuffer StringBuffer.append(..))
&&
call(String Integer.toString())
{
return "1";
}
In the aspect but this did not work.
Thanks all for your help. Your posts helped me a lot in understanding
what is going on.
Greetings Ben
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users