Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » changing method instance variables.
changing method instance variables. [message #588884] Mon, 20 June 2005 02:33
Oz Kologlu is currently offline Oz KologluFriend
Messages: 5
Registered: July 2009
Junior Member
Hi all,

I would like to change the instance variable of 'b' at the point indicated
'HERE' to be "new b string" _after_ returning.

If you are in Sydney CBD (in AU) a couple of free beers supplied for a
solution!

Thanks,
Oz

public class A {
String getString(B b) {
System.out.println( b.getString() ); // outputs "b string"
String s = C.getSomething( b ); // HERE: this is where i'd like
to change instance b after returning
....
System.out.println( b.getString() ); // should output "new b string"
return s;
}

// Main method
public static void main( String[] args ) {
A a = new A():
B b = new B("b string"));
System.out.println( a.getString( b )); //outputs "b string and c
string"
}

}

public class B {
String string;
public B( String string ) { this.string = string; }
public String getString() { return this.string; }
}

public class C {
public static String getSomething( B b ) { return b.getString() + " and
c string"; }
}

The aound(?) advice needs to do something like:

String around(B b) : execution ( * C.getSomething( B ) ) && target( b ){
String s = proceed( b );
if ( s.equals( "b string and c string" )) {
b = new B("new b string"); //this does not work since it only chages
the local reference
}
return s;
}
Previous Topic:AJDT development build for Eclipse 3.1RC2
Next Topic:changing method instance variables.
Goto Forum:
  


Current Time: Fri Apr 26 20:08:10 GMT 2024

Powered by FUDForum. Page generated in 0.02495 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top