Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumswrapping around fields
https://www.eclipse.org/forums/index.php/mv/msg/5121/15438/#msg_15438
I was experimenting with aspectJ - couldnt get it to run on Eclipse 2.1,
so got the older 2.0. I was trying this :
public class Person {
public int age;
public String name;
}
Here is a sample testcase which I started with, in order to "exercise" the
aspects :
public class VarAspectTest extends TestCase {
public VarAspectTest(String arg0) {
super(arg0);
}
public void testVarGet() {
System.out.println("Accessing Person.name..." + new Person().name);
System.out.println("Accessing Person.age..." + new Person().age);
}
}
The result seems weird- although I am able to get "HELLO" as the name, the
age shows up as 0 - i.e. the aspect on the int member wasn't triggered.
This too had the same results. I'm actually looking for a way to process all
string and int members. If I do this :
pointcut getVar(Object whatever): get(* Person.*) && target(whatever);
I am able to trap everything, but the primitive types give a class-cast
exception. So, another question is - is it possible to handle primitive
types in aspectJ ?
I am new to aspects, so I might probably be doing something wrong.
Thanks in advance for any suggestions.
Regards,
Somik]]>Somik Raha2003-01-23T03:02:12-00:00Re: wrapping around fields
https://www.eclipse.org/forums/index.php/mv/msg/5121/15472/#msg_15472
Originally posted by: somik.yahoo.com
Oh, looks like I got the wrong user group - sorry about that, will post in
the aspectj-user mailing list.
Regards,
Somik
"Somik Raha" <somik@industriallogic.com> wrote in message
news:b0nks6$c16$1@rogue.oti.com...
> Hi,
> I was experimenting with aspectJ - couldnt get it to run on Eclipse 2.1,
> so got the older 2.0. I was trying this :
>
> aspect A {
> pointcut getVar(Object whatever): get(* Person.name) &&
> target(whatever);
> pointcut getVarInt(int whatever): get(* Person.age) &&
target(whatever);
>
> int around(int whatever): getVarInt(whatever) {
> System.out.println("in around(int)");
> return -1;
> }
> Object around(Object whatever): getVar(whatever) {
> System.out.println("in around");
> return "HELLO";
> }
> }
>
> where the Person class is :
>
> public class Person {
> public int age;
> public String name;
> }
>
> Here is a sample testcase which I started with, in order to "exercise" the
> aspects :
>
> public class VarAspectTest extends TestCase {
> public VarAspectTest(String arg0) {
> super(arg0);
> }
> public void testVarGet() {
> System.out.println("Accessing Person.name..." + new
Person().name);
> System.out.println("Accessing Person.age..." + new Person().age);
> }
> }
>
> The result seems weird- although I am able to get "HELLO" as the name, the
> age shows up as 0 - i.e. the aspect on the int member wasn't triggered.
>
> Next, I tried :
>
> pointcut getVar(Object whatever): get(* Person.String) &&
> target(whatever);
> pointcut getVarInt(int whatever): get(* Person.int) &&
target(whatever);
>
> This too had the same results. I'm actually looking for a way to process
all
> string and int members. If I do this :
> pointcut getVar(Object whatever): get(* Person.*) && target(whatever);
>
> I am able to trap everything, but the primitive types give a class-cast
> exception. So, another question is - is it possible to handle primitive
> types in aspectJ ?
>
> I am new to aspects, so I might probably be doing something wrong.
> Thanks in advance for any suggestions.
>
> Regards,
> Somik
>
>]]>2003-01-23T06:18:27-00:00Re: wrapping around fields
https://www.eclipse.org/forums/index.php/mv/msg/5121/564130/#msg_564130
the aspectj-user mailing list.
Regards,
Somik
"Somik Raha" <somik@industriallogic.com> wrote in message
news:b0nks6$c16$1@rogue.oti.com...
> Hi,
> I was experimenting with aspectJ - couldnt get it to run on Eclipse 2.1,
> so got the older 2.0. I was trying this :
>
> aspect A {
> pointcut getVar(Object whatever): get(* Person.name) &&
> target(whatever);
> pointcut getVarInt(int whatever): get(* Person.age) &&
target(whatever);
>
> int around(int whatever): getVarInt(whatever) {
> System.out.println("in around(int)");
> return -1;
> }
> Object around(Object whatever): getVar(whatever) {
> System.out.println("in around");
> return "HELLO";
> }
> }
>
> where the Person class is :
>
> public class Person {
> public int age;
> public String name;
> }
>
> Here is a sample testcase which I started with, in order to "exercise" the
> aspects :
>
> public class VarAspectTest extends TestCase {
> public VarAspectTest(String arg0) {
> super(arg0);
> }
> public void testVarGet() {
> System.out.println("Accessing Person.name..." + new
Person().name);
> System.out.println("Accessing Person.age..." + new Person().age);
> }
> }
>
> The result seems weird- although I am able to get "HELLO" as the name, the
> age shows up as 0 - i.e. the aspect on the int member wasn't triggered.
>
> Next, I tried :
>
> pointcut getVar(Object whatever): get(* Person.String) &&
> target(whatever);
> pointcut getVarInt(int whatever): get(* Person.int) &&
target(whatever);
>
> This too had the same results. I'm actually looking for a way to process
all
> string and int members. If I do this :
> pointcut getVar(Object whatever): get(* Person.*) && target(whatever);
>
> I am able to trap everything, but the primitive types give a class-cast
> exception. So, another question is - is it possible to handle primitive
> types in aspectJ ?
>
> I am new to aspects, so I might probably be doing something wrong.
> Thanks in advance for any suggestions.
>
> Regards,
> Somik
>
>]]>Somik Raha2003-01-23T06:18:27-00:00