]> source.dussan.org Git - aspectj.git/commitdiff
better type and visibility checking for pointcut references
authorjhugunin <jhugunin>
Thu, 19 Dec 2002 22:13:11 +0000 (22:13 +0000)
committerjhugunin <jhugunin>
Thu, 19 Dec 2002 22:13:11 +0000 (22:13 +0000)
weaver/src/org/aspectj/weaver/ResolvedMember.java
weaver/src/org/aspectj/weaver/ResolvedTypeX.java
weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java

index d7e40012206a245f5b42a2be9fd9179d6b059be7..f47f11279e12595cf64e829ec84b76625fc66a72 100644 (file)
@@ -161,5 +161,10 @@ public class ResolvedMember extends Member implements IHasPosition {
                return Modifier.isAbstract(modifiers);
        }
 
+       public boolean isVisible(ResolvedTypeX fromType) {
+               World world = fromType.getWorld();
+               return ResolvedTypeX.isVisible(getModifiers(), getDeclaringType().resolve(world),
+                                       fromType);
+       }
 }
    
index bcfd9e02b70ce712a97c00005258bfe0289b442d..c0de08a5b01bc399126a9e8061b59b099e9a3793 100644 (file)
@@ -885,7 +885,7 @@ public abstract class ResolvedTypeX extends TypeX {
                                        } else {
                                                if (this instanceof BcelObjectType) return false;  //XXX ignores separate comp
                                                getWorld().getMessageHandler().handleMessage(
-                                                       MessageUtil.error("inter-type declaration from " + munger.getAspectType() +
+                                                       MessageUtil.error("inter-type declaration from " + munger.getAspectType().getName() +
                                                                                        " conflicts with existing member: " + existingMember,
                                                                                        munger.getSourceLocation())
                                                );
@@ -957,11 +957,11 @@ public abstract class ResolvedTypeX extends TypeX {
                //System.err.println("conflict at " + m2.getSourceLocation());
                getWorld().getMessageHandler().handleMessage(MessageUtil.error(
                        "intertype declaration from "
-                               + m1.getAspectType().getClassName()
+                               + m1.getAspectType().getName()
                                + " conflicts with intertype declaration: "
                                + m2.getSignature()
                                + " from "
-                               + m2.getAspectType().getClassName(),
+                               + m2.getAspectType().getName(),
                        m2.getSourceLocation()));
        }
        
index d3b9d1badde8955550fd2b37fa9255d40500a196..52977f2b722f264d9ac4801ecd809d5a0388e884 100644 (file)
@@ -142,6 +142,12 @@ public class ReferencePointcut extends Pointcut {
                        return;
                }
                
+               // check visibility
+               if (!pointcutDef.isVisible(scope.getEnclosingType())) {
+                       scope.message(IMessage.ERROR, this, "pointcut declaration " + pointcutDef + " is not accessible");
+                       return;
+               }
+               
                if (Modifier.isAbstract(pointcutDef.getModifiers())) {
                        if (onType != null) {
                                scope.message(IMessage.ERROR, this, 
@@ -174,7 +180,9 @@ public class ReferencePointcut extends Pointcut {
                                                                "bad parameter to pointcut reference");
                                return;
                        }
-                       if (!p.matchesSubtypes(parameterTypes[i])) {
+                       if (!p.matchesSubtypes(parameterTypes[i]) && 
+                               !p.getExactType().equals(TypeX.OBJECT))
+                       {
                                scope.message(IMessage.ERROR, p, "incompatible type, expected " +
                                                parameterTypes[i].getName() + " found " + p);
                                return;
@@ -220,7 +228,6 @@ public class ReferencePointcut extends Pointcut {
                                );
                                return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
                        }
-                       //??? error if we don't find
                                        
                        //System.err.println("start: " + searchStart);
                        ResolvedTypeX[] parameterTypes = searchStart.getWorld().resolve(pointcutDec.getParameterTypes());
@@ -231,7 +238,9 @@ public class ReferencePointcut extends Pointcut {
                        for (int i=0,len=arguments.size(); i < len; i++) {
                                TypePattern p = arguments.get(i);
                                //we are allowed to bind to pointcuts which use subtypes as this is type safe
-                               if (!p.matchesSubtypes(parameterTypes[i])) {
+                               if (!p.matchesSubtypes(parameterTypes[i])  && 
+                                       !p.getExactType().equals(TypeX.OBJECT))
+                               {
                                        throw new BCException("illegal change to pointcut declaration: " + this);
                                }