@@ -0,0 +1,11 @@ | |||
abstract aspect Base { | |||
public final pointcut foo() : execution(* *(..)); | |||
} | |||
aspect Sub extends Base { | |||
public pointcut foo() : execution(* *(..)) && args(String); | |||
} |
@@ -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) { |
@@ -77,6 +77,12 @@ | |||
<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"> |
@@ -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), |
@@ -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"; |
@@ -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 |