[jboss-user] [JBoss AOP] - Re: Inteception on field inherited through generic superclas

dunks80 do-not-reply at jboss.com
Thu Jan 18 08:52:26 EST 2007


Kabir,
        I just downloaded AOP 1.5.3 and I'm still seeing the same behavior on my test case...here is the verbose output when running the testcase


  | [debug] Passed in instrumentor: null
  | [debug] Defaulting instrumentor to: org.jboss.aop.instrument.ClassicInstrumentor
  | [debug] jboss.aop.class.path: /workspace/aop-problem/src/java
  | [debug] Looking for aspects in: testcase.ZImpl
  | [debug] Looking for aspects in: testcase.B
  | [debug] Looking for aspects in: testcase.MyFieldAnnotation
  | [debug] Looking for aspects in: testcase.A
  | [debug] Looking for aspects in: testcase.Main
  | [debug] Looking for aspects in: testcase.MyFieldInterceptor
  | [debug] Found @InterceptorDef in: testcase.MyFieldInterceptor
  | [debug] Looking for aspects in: testcase.C
  | [debug] Looking for aspects in: testcase.Z
  | [debug] jboss.aop.search.classpath: 'null' true
  | [debug] jboss.aop.path: null
  | [trying to transform] testcase.Main
  | [debug] There are no caller pointcuts!
  | [debug] javassist.CtMethod at 44a4fe33[public static main ([Ljava/lang/String;)V] matches no pointcuts
  | [debug] javassist.CtConstructor at 366025e7[public Main ()V] matches no pointcuts
  | [debug] javassist.CtConstructor at 28d08633[public C ()V] matches no pointcuts
  | [debug] javassist.CtConstructor at 6037fb1e[public B ()V] matches no pointcuts
  | [debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(* *->@testcase.MyFieldAnnotation)
  | [debug] testcase.A.myField:Ljava/lang/String; matches no pointcuts
  | [debug] javassist.CtConstructor at 6686fe26[public A ()V] matches no pointcuts
  | [debug] was testcase.Main converted: true
  | [trying to transform] testcase.C
  | [debug] There are no caller pointcuts!
  | [debug] javassist.CtMethod at 69cb6c6d[public toString ()Ljava/lang/String;] matches no pointcuts
  | [debug] javassist.CtConstructor at 41fc2fb[public C ()V] matches no pointcuts
  | [debug] was testcase.C converted: false
  | [trying to transform] testcase.B
  | [debug] There are no caller pointcuts!
  | [debug] javassist.CtConstructor at 42704baa[public B ()V] matches no pointcuts
  | [debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(* *->@testcase.MyFieldAnnotation)
  | [debug] testcase.A.myField:Ljava/lang/String; matches no pointcuts
  | [debug] was testcase.B converted: true
  | [trying to transform] testcase.A
  | [debug] There are no caller pointcuts!
  | [debug] javassist.CtConstructor at 65b4fad5[public A ()V] matches no pointcuts
  | [debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(* *->@testcase.MyFieldAnnotation)
  | [debug] testcase.A.myField:Ljava/lang/String; matches no pointcuts
  | [debug] was testcase.A converted: true
  | iterate binding testcase.MyFieldInterceptor
  | field matched binding testcase.MyFieldInterceptor
  | [debug] added advisor: testcase.A from binding: testcase.MyFieldInterceptor
  | Using context classloader sun.misc.Launcher$AppClassLoader at 64601bb1 to load aspect testcase.MyFieldInterceptor
  | [trying to transform] testcase.MyFieldInterceptor
  | [debug] There are no caller pointcuts!
  | [debug] javassist.CtMethod at 26562bc2[public getName ()Ljava/lang/String;] matches no pointcuts
  | [debug] javassist.CtMethod at 2ff3c113[public invoke (Lorg/jboss/aop/joinpoint/Invocation;)Ljava/lang/Object;] matches no pointcuts
  | [debug] javassist.CtConstructor at 2c76e369[public MyFieldInterceptor ()V] matches no pointcuts
  | [debug] was testcase.MyFieldInterceptor converted: false
  | null
  | 

were you able to get the test case i sent you to run correctly (with the duplicated myField inherited variable in class B commented out)? 

Upon further investigation it seems that the interceptor is invoked on the inherited field as long as the field is not called from within the subclass itself...what I mean is that in subclass C I have a toString method that returns the inherited A.myField value....

 

  | public class C extends B<ZImpl>
  | {
  |     public String toString()
  |     {
  |         return myField;
  |     }
  | }
  | 

If the inherited field is not duplicated in class B and I call  C.toString the interceptor is not run on the inherited A.myField...however...if within the main class i directly call C.myField like this..


  | 
  | public class Main
  | {
  |     /**
  |      * @author gdunkle
  |      * @param args
  |      * TODO Implement auto-generated method stub
  |      */
  |     public static void main(String[] args)
  |     {
  |         C cInstance=new C();
  |         System.out.println(cInstance.toString());
  |         System.out.println(cInstance.myField);
  |     }
  | }
  | 

the interceptor is run. I just reran the test case with the  1.5.2 release and the second print line in Main did not invoke the interceptor so it looks like that part of the issue was indeed solved by 1.5.3. 

So I guess my new issue is that the interceptors are not being called on fields inherited through the superclass from inside the subclass itself. Should this be expected behavior? Could you please comment?

Thanks

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4003309#4003309

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4003309



More information about the jboss-user mailing list