]> source.dussan.org Git - aspectj.git/commitdiff
fix for pr86057, overriding of final pointcut
authoracolyer <acolyer>
Fri, 19 Aug 2005 16:51:30 +0000 (16:51 +0000)
committeracolyer <acolyer>
Fri, 19 Aug 2005 16:51:30 +0000 (16:51 +0000)
tests/bugs150/pr86057.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/ResolvedType.java
weaver/src/org/aspectj/weaver/WeaverMessages.java
weaver/src/org/aspectj/weaver/weaver-messages.properties

diff --git a/tests/bugs150/pr86057.aj b/tests/bugs150/pr86057.aj
new file mode 100644 (file)
index 0000000..30861a2
--- /dev/null
@@ -0,0 +1,11 @@
+abstract aspect Base {
+       
+       public final pointcut foo() : execution(* *(..));
+       
+}
+
+aspect Sub extends Base {
+       
+       public pointcut foo() : execution(* *(..)) && args(String);
+       
+}
\ No newline at end of file
index 21321349797ce65fbba993951c473e4696860279..f4ed350fa9072fcc713ad201802f795cd9f369f8 100644 (file)
@@ -238,6 +238,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("void field type in pointcut expression");
   }
   
+  public void testPointcutOverriding() {
+         runTest("overriding final pointcut from super-aspect");
+  }
+  
   // helper methods.....
   
   public SyntheticRepository createRepos(File cpentry) {
index a8a2967c62258791b18690bfed718a5a5b9160b5..da8d9e661d81765313d0264995b3a48ae226b784 100644 (file)
             <message line="3" kind="error" text="fields cannot have a void type"/>
         </compile>
     </ajc-test>
+
+    <ajc-test dir="bugs150" pr="86057" title="overriding final pointcut from super-aspect">
+        <compile files="pr86057.aj">
+            <message line="9" kind="error" text="can't override final pointcut Base.foo()"/>
+        </compile>
+    </ajc-test>
                                 
    <ajc-test dir="bugs150" pr="78707" title="before returning advice not allowed!">
         <compile files="pr78707.aj">
index 8e359fcdc9a4d0fb785e7401055c4bceef9d0fd9..1d4b401884cb19f3568ea8438be7a9a02bf2e597 100644 (file)
@@ -1233,9 +1233,18 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
        
        /**
         * @return true if the override is legal
+        * note: calling showMessage with two locations issues TWO messages, not ONE message
+        * with an additional source location.
         */
        public boolean checkLegalOverride(ResolvedMember parent, ResolvedMember child) {
                //System.err.println("check: " + child.getDeclaringType() + " overrides " + parent.getDeclaringType());
+               if (Modifier.isFinal(parent.getModifiers())) {
+                       world.showMessage(Message.ERROR,
+                                       WeaverMessages.format(WeaverMessages.CANT_OVERRIDE_FINAL_MEMBER,parent),
+                                       child.getSourceLocation(),null);
+                       return false;
+               }
+               
                if (!parent.getReturnType().equals(child.getReturnType())) {
                        world.showMessage(IMessage.ERROR,
                                        WeaverMessages.format(WeaverMessages.ITD_RETURN_TYPE_MISMATCH,parent,child),
index 0665e294030aa280673159a267b1b70743f4ed91..4bee39a7d5869ac1959aaf4456ce0ac84dd70897 100644 (file)
@@ -55,6 +55,7 @@ public class WeaverMessages {
        public static final String ITD_MEMBER_CONFLICT = "itdMemberConflict";
        public static final String ITD_NON_EXPOSED_IMPLEMENTOR = "itdNonExposedImplementor";
        public static final String ITD_ABSTRACT_MUST_BE_PUBLIC_ON_INTERFACE = "itdAbstractMustBePublicOnInterface";
+       public static final String CANT_OVERRIDE_FINAL_MEMBER = "cantOverrideFinalMember";
        
        public static final String NON_VOID_RETURN = "nonVoidReturn";
        public static final String INCOMPATIBLE_RETURN_TYPE="incompatibleReturnType";
index e1c2cad5516ecd6ee87c44761f9712fb3998f0fd..af95e1e38db67cc3dfd4d0d9166f778e91948931 100644 (file)
@@ -47,6 +47,7 @@ itdConsOnAspect=can''t declare constructor on an aspect
 returnTypeMismatch=can''t override {0} with {1} return types don''t match
 paramTypeMismatch=can''t override {0} with {1} parameter types don''t match
 visibilityReduction=can''t override {0} with {1} visibility is reduced
+cantOverrideFinalMember=can''t override final {0}
 doesntThrow=overriden method doesn't throw {0}
 overriddenStatic={0} cannot override {1}; overridden method is static
 overridingStatic={0} cannot override {1}; overriding method is static