diff options
author | jhugunin <jhugunin> | 2002-12-18 06:17:28 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2002-12-18 06:17:28 +0000 |
commit | 0d1be0aeaabe27f76f3ce3b923e198dedef28a43 (patch) | |
tree | acc82229c16cc4388f3f5f7b4ce29e863d83bc50 /weaver | |
parent | fdda168314476e94315ee2b844c2ff55ea944ddc (diff) | |
download | aspectj-0d1be0aeaabe27f76f3ce3b923e198dedef28a43.tar.gz aspectj-0d1be0aeaabe27f76f3ce3b923e198dedef28a43.zip |
handle matching with this/target/args(InaccessibleTypeToOthers)
Diffstat (limited to 'weaver')
4 files changed, 34 insertions, 20 deletions
diff --git a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java index 24c21cc6a..ab60e6897 100644 --- a/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java +++ b/weaver/src/org/aspectj/weaver/CrosscuttingMembers.java @@ -96,9 +96,7 @@ public class CrosscuttingMembers { declareDominates.add(declare); } else if (declare instanceof DeclareParents) { DeclareParents dp = (DeclareParents)declare; - for (Iterator i = dp.getParents().collectAccessTypeMungers(world).iterator(); i.hasNext(); ) { - addTypeMunger(world.concreteTypeMunger((PrivilegedAccessMunger)i.next(), inAspect)); - } + exposeTypes(dp.getParents().getExactTypes()); declareParents.add(dp); } else if (declare instanceof DeclareSoft) { DeclareSoft d = (DeclareSoft)declare; @@ -111,6 +109,21 @@ public class CrosscuttingMembers { } } + public void exposeTypes(Collection typesToExpose) { + for (Iterator i = typesToExpose.iterator(); i.hasNext(); ) { + exposeType((TypeX)i.next()); + } + } + + public void exposeType(TypeX typeToExpose) { + if (typeToExpose == ResolvedTypeX.MISSING) return; + + ResolvedMember member = new ResolvedMember( + Member.STATIC_INITIALIZATION, typeToExpose, 0, ResolvedTypeX.VOID, "", TypeX.NONE); + addTypeMunger(world.concreteTypeMunger( + new PrivilegedAccessMunger(member), inAspect)); + } + public void addPrivilegedAccesses(Collection accessedMembers) { for (Iterator i = accessedMembers.iterator(); i.hasNext(); ) { addPrivilegedAccess( (ResolvedMember)i.next() ); diff --git a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java index 986d15eee..a95471350 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java @@ -34,13 +34,8 @@ public class ArgsPointcut extends NameBindingPointcut { } public FuzzyBoolean match(Shadow shadow) { - int n = shadow.getArgCount(); - TypeX[] argTypes = new TypeX[n]; - for (int i=0; i < n; i++) { - argTypes[i] = shadow.getArgType(i); - } FuzzyBoolean ret = - arguments.matches(shadow.getIWorld().resolve(argTypes), TypePattern.DYNAMIC); + arguments.matches(shadow.getIWorld().resolve(shadow.getArgTypes()), TypePattern.DYNAMIC); return ret; } @@ -81,15 +76,18 @@ public class ArgsPointcut extends NameBindingPointcut { public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) { - return new ArgsPointcut(arguments.resolveReferences(bindings)); + TypePatternList args = arguments.resolveReferences(bindings); + if (inAspect.crosscuttingMembers != null) { + inAspect.crosscuttingMembers.exposeTypes(args.getExactTypes()); + } + return new ArgsPointcut(args); } private Test findResidueNoEllipsis(Shadow shadow, ExposedState state, TypePattern[] patterns) { int len = shadow.getArgCount(); //System.err.println("boudn to : " + len + ", " + patterns.length); if (patterns.length != len) { - throw new RuntimeException("this should never happen"); - //return Literal.FALSE; //??? this should never happen + return Literal.FALSE; } Test ret = Literal.TRUE; @@ -110,6 +108,9 @@ public class ArgsPointcut extends NameBindingPointcut { } public Test findResidue(Shadow shadow, ExposedState state) { + if (arguments.matches(shadow.getIWorld().resolve(shadow.getArgTypes()), TypePattern.DYNAMIC).alwaysFalse()) { + return Literal.FALSE; + } int ellipsisCount = arguments.ellipsisCount; if (ellipsisCount == 0) { return findResidueNoEllipsis(shadow, state, arguments.getTypePatterns()); diff --git a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java index 1351ac075..e59116e44 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java @@ -103,7 +103,12 @@ public class ThisOrTargetPointcut extends NameBindingPointcut { } public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) { - return new ThisOrTargetPointcut(isThis, type.remapAdviceFormals(bindings)); + TypePattern newType = type.remapAdviceFormals(bindings); + if (inAspect.crosscuttingMembers != null) { + inAspect.crosscuttingMembers.exposeType(newType.getExactType()); + } + + return new ThisOrTargetPointcut(isThis, newType); } } diff --git a/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java b/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java index c3a741578..3e4c0e25f 100644 --- a/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java +++ b/weaver/src/org/aspectj/weaver/patterns/TypePatternList.java @@ -232,16 +232,11 @@ public class TypePatternList extends PatternNode { return typePatterns; } - public Collection collectAccessTypeMungers(World world) { + public Collection getExactTypes() { ArrayList ret = new ArrayList(); for (int i=0; i<typePatterns.length; i++) { TypeX t = typePatterns[i].getExactType(); - ResolvedTypeX rt = t.resolve(world); - if (!Modifier.isPublic(rt.getModifiers())) { - ret.add(new PrivilegedAccessMunger(new ResolvedMember( - Member.STATIC_INITIALIZATION, rt, 0, ResolvedTypeX.VOID, "", TypeX.NONE - ))); - } + if (t != ResolvedTypeX.MISSING) ret.add(t); } return ret; } |