[jboss-user] [JBoss AOP] - What am I doing wrong???
manu4ever
do-not-reply at jboss.com
Fri Aug 25 13:13:42 EDT 2006
I have this bit of code:
public class Driver {
public static void main(String[] args) {
B b = new B(55);
System.out.println("spojo.field = " + b.getField());
System.out.println("spojo.super.field = " + b.getSuperField());
}
}
public class A {
@trace
int field;
public A(int i) {
field = i;
}
public int getField() {
return field;
}
}
public class B extends A {
int field;
public B(int i) {
super(i/2);
field = i;
}
public int getField() {
return field;
}
public int getSuperField() {
return super.getField();
}
}
The "TraceInterceptor" and jboss-aop.xml files come from one of the sample apps in jboss in directory docs/aspect-framework/examples/annotation.
When I compile and run this I get:
[java] <<< Trace : write field name: int A.field
[java] >>> Leaving Trace
[java] <<< Trace : write field name: int A.field
[java] >>> Leaving Trace
[java] <<< Trace : read field name: int A.field
[java] >>> Leaving Trace
[java] spojo.field = 55
[java] <<< Trace : read field name: int A.field
[java] >>> Leaving Trace
[java] spojo.super.field = 55
This is way wrong. The value of super.field is 27. The value being displayed seems to be the value of B.field rather than A.field. This feels like a static binding vs. dynamic binding problem inside jboss, but it could be that I'm just dumb and forgot to do something really simple.
Please advise!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967531#3967531
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967531
More information about the jboss-user
mailing list