]> source.dussan.org Git - aspectj.git/commitdiff
handle matching with this/target/args(InaccessibleTypeToOthers)
authorjhugunin <jhugunin>
Wed, 18 Dec 2002 06:17:28 +0000 (06:17 +0000)
committerjhugunin <jhugunin>
Wed, 18 Dec 2002 06:17:28 +0000 (06:17 +0000)
weaver/src/org/aspectj/weaver/CrosscuttingMembers.java
weaver/src/org/aspectj/weaver/patterns/ArgsPointcut.java
weaver/src/org/aspectj/weaver/patterns/ThisOrTargetPointcut.java
weaver/src/org/aspectj/weaver/patterns/TypePatternList.java

index 24c21cc6aa231f900f788a1180da028b4cc4d39a..ab60e689796009cbeaa9ef774443b1b6d92d89e2 100644 (file)
@@ -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() );
index 986d15eee647b1624882f54126b2ac459c0e96a3..a954713507d38b14e1ad761da97fee5ea4292d82 100644 (file)
@@ -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());               
index 1351ac07514b24356f1cc119e75cc26951fe481a..e59116e44fe5055521fb776c198eb1118d69bf5d 100644 (file)
@@ -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);
        }
 
 }
index c3a741578e46815362007c75245a548b43d4c9a5..3e4c0e25f580334805fc2d02b41fc649872509ed 100644 (file)
@@ -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;
        }