[
http://jira.jboss.com/jira/browse/JBAOP-346?page=comments#action_12351150 ]
Kabir Khan commented on JBAOP-346:
----------------------------------
The problem seems to be in Instrumentor.convertReferences.
Basically, if there is a non-instrumented "Intermediate class", then the
sub-class does not get the field access woven. If we have an interceptor attached to
field(* A->field)
class A{
int field;
}
class B extends A{
int useField(){return field};
}
class C extends B{
int useField(){return field};
}
When weaving B, we register that it does not have field access set up. When converting
references for C, we have a reference to B only (not to A).
manager.convertReferences("B") returns false in this case. We need to check if B
is an actual super class, and if it is then we need to check the fields regardless
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: 2.0.0.alpha3, 1.5.4.GA
Attachments: testcase2.tar
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@44a4fe33[public static main ([Ljava/lang/String;)V] matches no
pointcuts
[debug] javassist.CtConstructor@19c247a0[public Main ()V] matches no pointcuts
[debug] javassist.CtConstructor@27431340[public D ()V] matches no pointcuts
[debug] javassist.CtConstructor@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@69cb6c6d[public toString ()Ljava/lang/String;] matches no
pointcuts
[debug] javassist.CtConstructor@26fd68b1[public C ()V] matches no pointcuts
[debug] javassist.CtConstructor@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@152c7568[public B ()V] matches no pointcuts
[debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(*
*->(a)testcase.MyFieldAnnotation)
[debug] testcase.A.myField:Ljava/lang/String; matches no pointcuts
[debug] javassist.CtConstructor@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@329f671b[public A ()V] matches no pointcuts
[debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(*
*->(a)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@64601bb1 to load aspect
testcase.MyFieldInterceptor
[trying to transform] testcase.MyFieldInterceptor
[debug] There are no caller pointcuts!
[debug] javassist.CtMethod@26562bc2[public getName ()Ljava/lang/String;] matches no
pointcuts
[debug] javassist.CtMethod@2ff3c113[public invoke
(Lorg/jboss/aop/joinpoint/Invocation;)Ljava/lang/Object;] matches no pointcuts
[debug] javassist.CtConstructor@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@69cb6c6d[public toString ()Ljava/lang/String;] matches no
pointcuts
[debug] javassist.CtConstructor@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@44a4fe33[public static main ([Ljava/lang/String;)V] matches no
pointcuts
[debug] javassist.CtConstructor@366025e7[public Main ()V] matches no pointcuts
[debug] javassist.CtConstructor@122e7820[public D ()V] matches no pointcuts
[debug] javassist.CtConstructor@121a9334[public C ()V] matches no pointcuts
[debug] javassist.CtConstructor@7b479feb[public B ()V] matches no pointcuts
[debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(*
*->(a)testcase.MyFieldAnnotation)
[debug] testcase.A.myField:Ljava/lang/String; matches no pointcuts
[debug] javassist.CtConstructor@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@69cb6c6d[public toString ()Ljava/lang/String;] matches no
pointcuts
[debug] javassist.CtConstructor@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@5a77a7f9[public B ()V] matches no pointcuts
[debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(*
*->(a)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@4cbfea1d[public A ()V] matches no pointcuts
[debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(*
*->(a)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@64601bb1 to load aspect
testcase.MyFieldInterceptor
[trying to transform] testcase.MyFieldInterceptor
[debug] There are no caller pointcuts!
[debug] javassist.CtMethod@26562bc2[public getName ()Ljava/lang/String;] matches no
pointcuts
[debug] javassist.CtMethod@2ff3c113[public invoke
(Lorg/jboss/aop/joinpoint/Invocation;)Ljava/lang/Object;] matches no pointcuts
[debug] javassist.CtConstructor@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@69cb6c6d[public toString ()Ljava/lang/String;] matches no
pointcuts
[debug] javassist.CtConstructor@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@44a4fe33[public static
main ([Ljava/lang/String;)V] matches no pointcuts [debug]
javassist.CtConstructor@19c247a0[public Main ()V] matches no pointcuts [debug]
javassist.CtConstructor@27431340[public D ()V] matches no pointcuts [debug]
javassist.CtConstructor@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@69cb6c6d[public toString
()Ljava/lang/String;] matches no pointcuts [debug] javassist.CtConstructor@26fd68b1[public
C ()V] matches no pointcuts [debug] javassist.CtConstructor@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@152c7568[public B
()V] matches no pointcuts [debug] testcase.A.myField:Ljava/lang/String; matches pointcut:
get(* *->(a)testcase.MyFieldAnnotation) [debug] testcase.A.myField:Ljava/lang/String;
matches no pointcuts [debug] javassist.CtConstructor@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@329f671b[public A ()V]
matches no pointcuts [debug] testcase.A.myField:Ljava/lang/String; matches pointcut: get(*
*->(a)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@64601bb1 to load aspect testcase.MyFieldInterceptor
[trying to transform] testcase.MyFieldInterceptor [debug] There are no caller pointcuts!
[debug] javassist.CtMethod@26562bc2[public getName ()Ljava/lang/String;] matches no
pointcuts [debug] javassist.CtMethod@2ff3c113[public invoke
(Lorg/jboss/aop/joinpoint/Invocation;)Ljava/lang/Object;] matches no pointcuts [debug]
javassist.CtConstructor@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@69cb6c6d[public toString
()Ljava/lang/String;] matches no pointcuts [debug] javassist.CtConstructor@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@44a4fe33[public static
main ([Ljava/lang/String;)V] matches no pointcuts [debug]
javassist.CtConstructor@366025e7[public Main ()V] matches no pointcuts [debug]
javassist.CtConstructor@122e7820[public D ()V] matches no pointcuts [debug]
javassist.CtConstructor@121a9334[public C ()V] matches no pointcuts [debug]
javassist.CtConstructor@7b479feb[public B ()V] matches no pointcuts [debug]
testcase.A.myField:Ljava/lang/String; matches pointcut: get(*
*->(a)testcase.MyFieldAnnotation) [debug] testcase.A.myField:Ljava/lang/String; matches
no pointcuts [debug] javassist.CtConstructor@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@69cb6c6d[public toString
()Ljava/lang/String;] matches no pointcuts [debug] javassist.CtConstructor@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@5a77a7f9[public B ()V] matches no pointcuts [debug]
testcase.A.myField:Ljava/lang/String; matches pointcut: get(*
*->(a)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@4cbfea1d[public A
()V] matches no pointcuts [debug] testcase.A.myField:Ljava/lang/String; matches pointcut:
get(* *->(a)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@64601bb1 to load aspect testcase.MyFieldInterceptor
[trying to transform] testcase.MyFieldInterceptor [debug] There are no caller pointcuts!
[debug] javassist.CtMethod@26562bc2[public getName ()Ljava/lang/String;] matches no
pointcuts [debug] javassist.CtMethod@2ff3c113[public invoke
(Lorg/jboss/aop/joinpoint/Invocation;)Ljava/lang/Object;] matches no pointcuts [debug]
javassist.CtConstructor@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@69cb6c6d[public toString
()Ljava/lang/String;] matches no pointcuts [debug] javassist.CtConstructor@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