[jboss-jira] [JBoss JIRA] Reopened: (JBAOP-339) FieldAccess for inherited fields does not get replaced

dunks80 (JIRA) jira-events at jboss.com
Thu Jan 18 13:09:53 EST 2007


     [ http://jira.jboss.com/jira/browse/JBAOP-339?page=all ]

dunks80 reopened JBAOP-339:
---------------------------

             
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.

> FieldAccess for inherited fields does not get replaced
> ------------------------------------------------------
>
>                 Key: JBAOP-339
>                 URL: http://jira.jboss.com/jira/browse/JBAOP-339
>             Project: JBoss AOP
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 1.5.2.GA
>         Environment: JBoss 4.0.5.GA
> JBoss AOP 1.5.2.GA load time weaving
> Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-b105, mixed mode) 
>            Reporter: dunks80
>         Assigned To: Kabir Khan
>             Fix For: 1.5.3.GA
>
>         Attachments: testcase.tar, testcase2.tar
>
>
> I'm seeing the following unexpected behavior
> Code:
> public abstract class A
> {
>    @MyFieldAnnotation
>    protected Object myField;
> ...
> }
> public abstract class B<Z> extends A
> {
> ...
> }
> public class C extends B<Y>
> {
> ...
> }  
> @InterceptorDef(scope = Scope.PER_VM)
> @Bind(pointcut = "get(* *->@MyFieldAnnotation)")
> public class MyFieldInterceptor implements Interceptor
> {
> ...
> }
> 	
> When i try to call myField on an instance of C from within a method in C my interceptor is not run. However if I duplicate the annotated field in class B like this...
> Code:
> public abstract class A
> {
>    @MyFieldAnnotation
>    protected Object myField;
> ...
> }
> public abstract class B<Z> extends A
> {
>  @MyFieldAnnotation
>    protected Object myField;
> ...
> }
> 	
> ...then the interceptor works when calling myField from an instance of C. I'm guess that since B is generic some sort of erasure of the annotation is happening. As a work around in the meantime I've just duplicated the annotated field. I just wanted to know whether this issue was known to the developers (if not I'll post it to jira) and whether or not there was some way to get this working without the need to duplicate that field.
> Thanks

-- 
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