]> source.dussan.org Git - aspectj.git/commitdiff
fixed ordering of inter-dependent cflow entries
authorjhugunin <jhugunin>
Wed, 1 Jan 2003 01:14:16 +0000 (01:14 +0000)
committerjhugunin <jhugunin>
Wed, 1 Jan 2003 01:14:16 +0000 (01:14 +0000)
fixed matching to privileged and inter-type field gets/sets which are method
calls in bytecode

weaver/src/org/aspectj/weaver/AjcMemberMaker.java
weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java
weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java
weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

index 2c9a899160cbc1055394c82d4c5d15e52ea241f0..f966a331a2bceb5eeab98ba810deb742f42862ec 100644 (file)
@@ -186,9 +186,9 @@ public class AjcMemberMaker {
        public static ResolvedMember privilegedAccessMethodForFieldGet(TypeX aspectType, Member field) {
                String sig;
                if (field.isStatic()) {
-                       sig = "()" + field.getSignature();
+                       sig = "()" + field.getReturnType().getSignature();
                } else {
-                       sig = "(" + field.getDeclaringType().getSignature() + ")" + field.getSignature();
+                       sig = "(" + field.getDeclaringType().getSignature() + ")" + field.getReturnType().getSignature();
                }
                
                return new ResolvedMember(Member.METHOD,
@@ -202,9 +202,9 @@ public class AjcMemberMaker {
        public static ResolvedMember privilegedAccessMethodForFieldSet(TypeX aspectType, Member field) {
                String sig;
                if (field.isStatic()) {
-                       sig = "(" + field.getSignature() + ")V";
+                       sig = "(" + field.getReturnType().getSignature() + ")V";
                } else {
-                       sig = "(" + field.getDeclaringType().getSignature() + field.getSignature() + ")V";
+                       sig = "(" + field.getDeclaringType().getSignature() + field.getReturnType().getSignature() + ")V";
                }
                
                return new ResolvedMember(Member.METHOD,
index fe21fec9d22b44ce8f6eccae01e7a81aa51c1044..394876696ba74090e74d80f275df41bd8e2efe08 100644 (file)
@@ -43,10 +43,16 @@ public class NewFieldTypeMunger extends ResolvedTypeMunger {
        
        public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedTypeX aspectType) {
                //??? might give a field where a method is expected     
+               ResolvedTypeX onType = aspectType.getWorld().resolve(getSignature().getDeclaringType());
+               
                ResolvedMember ret = AjcMemberMaker.interFieldGetDispatcher(getSignature(), aspectType);
                if (ResolvedTypeX.matches(ret, member)) return getSignature();
                ret = AjcMemberMaker.interFieldSetDispatcher(getSignature(), aspectType);
                if (ResolvedTypeX.matches(ret, member)) return getSignature();
+               ret = AjcMemberMaker.interFieldInterfaceGetter(getSignature(), onType, aspectType);
+               if (ResolvedTypeX.matches(ret, member)) return getSignature();
+               ret = AjcMemberMaker.interFieldInterfaceSetter(getSignature(), onType, aspectType);
+               if (ResolvedTypeX.matches(ret, member)) return getSignature();
                return super.getMatchingSyntheticMember(member, aspectType);
        }
 }
index c957a5656b3fef62d2add07bb2d5dcf70038c41f..7050612899ee7e619e2c9f4c5eef33cfc16484e7 100644 (file)
@@ -33,4 +33,19 @@ public class PrivilegedAccessMunger extends ResolvedTypeMunger {
                return getSignature();
        }
 
+       public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedTypeX aspectType) {
+               ResolvedMember ret;
+               if (getSignature().getKind() == Member.FIELD) {
+                       ret = AjcMemberMaker.privilegedAccessMethodForFieldGet(aspectType, getSignature());
+                       if (ResolvedTypeX.matches(ret, member)) return getSignature();
+                       ret = AjcMemberMaker.privilegedAccessMethodForFieldSet(aspectType, getSignature());
+                       if (ResolvedTypeX.matches(ret, member)) return getSignature();
+               } else {
+                       //System.err.println("sig: " + getSignature());
+                       ret = AjcMemberMaker.privilegedAccessMethodForMethod(aspectType, getSignature());
+                       if (ResolvedTypeX.matches(ret, member)) return getSignature();
+               }
+               return null;
+       }
+
 }
index 77842f3cd161f11ecde590ff666a352e651d6a82..8a58bcca310999b288a9bc6a767b776c106de32b 100644 (file)
@@ -288,8 +288,12 @@ public class BcelAdvice extends Advice {
                }
                
                if (kind.isCflow()) {
-                       if (this.innerCflowEntries.contains(o)) return -1;
-                       else if (o.innerCflowEntries.contains(this)) return +1;
+//                     System.err.println("sort: " + this + " innerCflowEntries " + innerCflowEntries);
+//                     System.err.println("      " + o + " innerCflowEntries " + o.innerCflowEntries);
+                       boolean isBelow = (kind == AdviceKind.CflowBelowEntry);
+
+                       if (this.innerCflowEntries.contains(o)) return isBelow ? +1 : -1;
+                       else if (o.innerCflowEntries.contains(this)) return isBelow ? -1 : +1;
                        else return 0;
                }
                
index 415098ba0fb7e090341d9384ed4241009974a805..2070da64b43aea41a8ab3c8694e8eb81cee78db8 100644 (file)
@@ -858,15 +858,29 @@ class BcelClassWeaver implements IClassWeaver {
                        Member method =
                                world.makeMethodSignature(clazz, invoke);
                        ResolvedMember declaredSig = method.resolve(world);
+                       //System.err.println(method + ", declaredSig: "  +declaredSig);
                        if (declaredSig == null) return;
-                       AjAttribute.EffectiveSignatureAttribute effectiveSig = declaredSig.getEffectiveSignature();
-                       if (effectiveSig == null) return;
-                       //System.err.println("call to inter-type member: " + effectiveSig);
-                       if (effectiveSig.isWeaveBody()) return;
                        
-                       match(BcelShadow.makeShadowForMethodCall(world, mg, ih, enclosingShadow,
+                       if (declaredSig.getKind() == Member.FIELD) {
+                               Shadow.Kind kind;
+                               if (method.getReturnType().equals(ResolvedTypeX.VOID)) {
+                                       kind = Shadow.FieldSet;
+                               } else {
+                                       kind = Shadow.FieldGet;
+                               }
+                               
+                               match(BcelShadow.makeShadowForMethodCall(world, mg, ih, enclosingShadow,
+                                               kind, declaredSig),
+                                       shadowAccumulator);
+                       } else {
+                               AjAttribute.EffectiveSignatureAttribute effectiveSig = declaredSig.getEffectiveSignature();
+                               if (effectiveSig == null) return;
+                               //System.err.println("call to inter-type member: " + effectiveSig);
+                               if (effectiveSig.isWeaveBody()) return;
+                               match(BcelShadow.makeShadowForMethodCall(world, mg, ih, enclosingShadow,
                                                effectiveSig.getShadowKind(), effectiveSig.getEffectiveSignature()),
                                        shadowAccumulator);
+                       }
                } else {
                        match(
                                BcelShadow.makeMethodCall(world, mg, ih, enclosingShadow),