[jboss-jira] [JBoss JIRA] Created: (JBAOP-346) FieldAccess for inherited field in subclass does not get replaced

Kabir Khan (JIRA) jira-events at jboss.com
Thu Jan 18 14:06:52 EST 2007


FieldAccess for inherited field in subclass does not get replaced
-----------------------------------------------------------------

                 Key: JBAOP-346
                 URL: http://jira.jboss.com/jira/browse/JBAOP-346
             Project: JBoss AOP
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions: 1.5.3.GA
            Reporter: Kabir Khan
         Assigned To: Kabir Khan
             Fix For: 1.5.4.GA, 2.0.0.alpha3


This is a reopening of JBAOP-339 since that was closed for 1.5.3.GA. From JBAOP-339:

dunks80 [18/Jan/07 01:08 PM]
release 1.5.3 fixed the issues previously reported in that field level access by classes not in the class hierarchy of the aspectized class will result in the interceptor running. However if the class is in the class hierarchy of the aspectized class and it accesses the inherited field the interceptor is not run. I'm including a second test case to demonstrate... quickly though here is the basic premise

-> = inherits from

Class heirarchy

D -> C -> B -> A

A declares annotated field...

package testcase;

public abstract class A
{
    /**
     * This field is annotated.
     * Any field access (get) should cause the interceptor to run
     */
    @MyFieldAnnotation
    protected String myField;
}


Main test case...

package testcase;

public class Main
{
    /**
     * @author gdunkle
     * @param args
     * TODO Implement auto-generated method stub
     */
    public static void main(String[] args)
    {
        C cInstance = new C();
        D dInstance = new D();
        // this doesn't work in 1.5.3 or 1.5.2
        System.out.println(cInstance.toString());
        // this works in 1.5.3
        System.out.println(cInstance.myField);
        // this won't work even if we uncomment the field in B
        // b/c it inherits from C and there is no duplicate field
        System.out.println(dInstance.toString());
        // this works in 1.5.3
        System.out.println(dInstance.myField);
    }
}

verbose output when run under 1.5.2

   [debug] Passed in instrumentor: null
[debug] Defaulting instrumentor to: org.jboss.aop.instrument.ClassicInstrumentor
[debug] jboss.aop.class.path: /home/gdunkle/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] Looking for aspects in: testcase.D
[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 19c247a0[public Main ()V] matches no pointcuts
[debug] javassist.CtConstructor at 27431340[public D ()V] matches no pointcuts
[debug] javassist.CtConstructor at 24a4e2e3[public C ()V] matches no pointcuts
[debug] was testcase.Main converted: false
[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 26fd68b1[public C ()V] matches no pointcuts
[debug] javassist.CtConstructor at 46e45076[public B ()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 152c7568[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 bc92535[public A ()V] matches no pointcuts
[debug] was testcase.B converted: true
[trying to transform] testcase.A
[debug] There are no caller pointcuts!
[debug] javassist.CtConstructor at 329f671b[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 14d6a05e[public MyFieldInterceptor ()V] matches no pointcuts
[debug] was testcase.MyFieldInterceptor converted: false
[trying to transform] testcase.D
[debug] There are no caller pointcuts!
[debug] javassist.CtMethod at 69cb6c6d[public toString ()Ljava/lang/String;] matches no pointcuts
[debug] javassist.CtConstructor at 36ff057f[public D ()V] matches no pointcuts
[debug] was testcase.D converted: false
null
null
null
null

verbose output when run under 1.5.3

[debug] Passed in instrumentor: null
[debug] Defaulting instrumentor to: org.jboss.aop.instrument.ClassicInstrumentor
[debug] jboss.aop.class.path: /home/gdunkle/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] Looking for aspects in: testcase.D
[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 122e7820[public D ()V] matches no pointcuts
[debug] javassist.CtConstructor at 121a9334[public C ()V] matches no pointcuts
[debug] javassist.CtConstructor at 7b479feb[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 2897a560[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 4139eeda[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 5a77a7f9[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 4cbfea1d[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 7b112783[public MyFieldInterceptor ()V] matches no pointcuts
[debug] was testcase.MyFieldInterceptor converted: false
[trying to transform] testcase.D
[debug] There are no caller pointcuts!
[debug] javassist.CtMethod at 69cb6c6d[public toString ()Ljava/lang/String;] matches no pointcuts
[debug] javassist.CtConstructor at 32b0bad7[public D ()V] matches no pointcuts
[debug] was testcase.D converted: false
null
testcase.MyFieldInterceptor ran!
Woo it worked
null
testcase.MyFieldInterceptor ran!
Woo it worked



field level access made by an object in the hierarchy should result in the interceptor being run.
[ Show » ]
dunks80 [18/Jan/07 01:08 PM] release 1.5.3 fixed the issues previously reported in that field level access by classes not in the class hierarchy of the aspectized class will result in the interceptor running. However if the class is in the class hierarchy of the aspectized class and it accesses the inherited field the interceptor is not run. I'm including a second test case to demonstrate... quickly though here is the basic premise -> = inherits from Class heirarchy D -> C -> B -> A A declares annotated field... package testcase; public abstract class A {     /**      * This field is annotated.      * Any field access (get) should cause the interceptor to run      */     @MyFieldAnnotation     protected String myField; } Main test case... package testcase; public class Main {     /**      * @author gdunkle      * @param args      * TODO Implement auto-generated method stub      */     public static void main(String[] args)     {         C cInstance = new C();         D dInstance = new D();         // this doesn't work in 1.5.3 or 1.5.2         System.out.println(cInstance.toString());         // this works in 1.5.3         System.out.println(cInstance.myField);         // this won't work even if we uncomment the field in B         // b/c it inherits from C and there is no duplicate field         System.out.println(dInstance.toString());         // this works in 1.5.3         System.out.println(dInstance.myField);     } } verbose output when run under 1.5.2    [debug] Passed in instrumentor: null [debug] Defaulting instrumentor to: org.jboss.aop.instrument.ClassicInstrumentor [debug] jboss.aop.class.path: /home/gdunkle/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] Looking for aspects in: testcase.D [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 19c247a0[public Main ()V] matches no pointcuts [debug] javassist.CtConstructor at 27431340[public D ()V] matches no pointcuts [debug] javassist.CtConstructor at 24a4e2e3[public C ()V] matches no pointcuts [debug] was testcase.Main converted: false [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 26fd68b1[public C ()V] matches no pointcuts [debug] javassist.CtConstructor at 46e45076[public B ()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 152c7568[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 bc92535[public A ()V] matches no pointcuts [debug] was testcase.B converted: true [trying to transform] testcase.A [debug] There are no caller pointcuts! [debug] javassist.CtConstructor at 329f671b[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 14d6a05e[public MyFieldInterceptor ()V] matches no pointcuts [debug] was testcase.MyFieldInterceptor converted: false [trying to transform] testcase.D [debug] There are no caller pointcuts! [debug] javassist.CtMethod at 69cb6c6d[public toString ()Ljava/lang/String;] matches no pointcuts [debug] javassist.CtConstructor at 36ff057f[public D ()V] matches no pointcuts [debug] was testcase.D converted: false null null null null verbose output when run under 1.5.3 [debug] Passed in instrumentor: null [debug] Defaulting instrumentor to: org.jboss.aop.instrument.ClassicInstrumentor [debug] jboss.aop.class.path: /home/gdunkle/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] Looking for aspects in: testcase.D [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 122e7820[public D ()V] matches no pointcuts [debug] javassist.CtConstructor at 121a9334[public C ()V] matches no pointcuts [debug] javassist.CtConstructor at 7b479feb[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 2897a560[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 4139eeda[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 5a77a7f9[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 4cbfea1d[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 7b112783[public MyFieldInterceptor ()V] matches no pointcuts [debug] was testcase.MyFieldInterceptor converted: false [trying to transform] testcase.D [debug] There are no caller pointcuts! [debug] javassist.CtMethod at 69cb6c6d[public toString ()Ljava/lang/String;] matches no pointcuts [debug] javassist.CtConstructor at 32b0bad7[public D ()V] matches no pointcuts [debug] was testcase.D converted: false null testcase.MyFieldInterceptor ran! Woo it worked null testcase.MyFieldInterceptor ran! Woo it worked field level access made by an object in the hierarchy should result in the interceptor being run.

[ Permlink | Delete | « Hide ]
dunks80 [18/Jan/07 01:09 PM]
test case to demonstrate problem with field level access from with class hierarchy not causing interceptor to run
[ Show » ]
dunks80 [18/Jan/07 01:09 PM] test case to demonstrate problem with field level access from with class hierarchy not causing interceptor to run



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the jboss-jira mailing list