diff options
author | jhugunin <jhugunin> | 2003-01-01 01:14:16 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-01-01 01:14:16 +0000 |
commit | 6ca8bded754a82f24db9e7f7c362425fcb7e7acf (patch) | |
tree | c6725801482bd6c65e1fa3c2a43a25240f3ebc1a /weaver | |
parent | ad1978de1e654c0e500aeb4abf23cff0c64d15d3 (diff) | |
download | aspectj-6ca8bded754a82f24db9e7f7c362425fcb7e7acf.tar.gz aspectj-6ca8bded754a82f24db9e7f7c362425fcb7e7acf.zip |
fixed ordering of inter-dependent cflow entries
fixed matching to privileged and inter-type field gets/sets which are method
calls in bytecode
Diffstat (limited to 'weaver')
5 files changed, 50 insertions, 11 deletions
diff --git a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java index 2c9a89916..f966a331a 100644 --- a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java +++ b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java @@ -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, diff --git a/weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java b/weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java index fe21fec9d..394876696 100644 --- a/weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/NewFieldTypeMunger.java @@ -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); } } diff --git a/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java b/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java index c957a5656..705061289 100644 --- a/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java +++ b/weaver/src/org/aspectj/weaver/PrivilegedAccessMunger.java @@ -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; + } + } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java index 77842f3cd..8a58bcca3 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java @@ -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; } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 415098ba0..2070da64b 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -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), |