From: aclement Date: Fri, 19 Mar 2004 09:28:14 +0000 (+0000) Subject: Fix for Bugzilla Bug 53012 X-Git-Tag: Root_ajdt_support~101 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0a017593dcbeab409c1634da87b3f500b848e903;p=aspectj.git Fix for Bugzilla Bug 53012 declare precedence on a class should be a compile-time error --- diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 33c0c645a..ce4620ece 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -7511,4 +7511,16 @@ + + + + + + + + + + diff --git a/tests/bugs/declarePrecedenceWithClasses/DeclarePrecedenceTestClass.java b/tests/bugs/declarePrecedenceWithClasses/DeclarePrecedenceTestClass.java new file mode 100644 index 000000000..98e2779d9 --- /dev/null +++ b/tests/bugs/declarePrecedenceWithClasses/DeclarePrecedenceTestClass.java @@ -0,0 +1,15 @@ +//Bug 53012 +// DP contains a declare precedence statement that mentions classes + +public class DeclarePrecedenceTestClass { + public static void main(String[] args) { + System.out.println("hello"); + } +} +aspect DP { + declare precedence: DeclarePrecedenceTestClass, DP; + + before() : staticinitialization(DeclarePrecedenceTestClass) { + System.out.println("ok"); + } +} diff --git a/tests/bugs/declarePrecedenceWithClasses/Priority.aj b/tests/bugs/declarePrecedenceWithClasses/Priority.aj new file mode 100644 index 000000000..fc44fbff0 --- /dev/null +++ b/tests/bugs/declarePrecedenceWithClasses/Priority.aj @@ -0,0 +1,11 @@ +// Bug 53012 +// Although the declare precedence mentions interfaces (and not aspects explicitly), it does +// mention with a '+' suffix - this should be allowed. + +public aspect Priority { + public interface Highest {} + public interface Lowest {} + declare precedence: Highest+, *, Lowest+; +} + +aspect Security implements Priority.Highest {} diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java b/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java index 4106abbc4..d7e190357 100644 --- a/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java +++ b/weaver/src/org/aspectj/weaver/patterns/DeclarePrecedence.java @@ -82,6 +82,14 @@ public class DeclarePrecedence extends Declare { } ResolvedTypeX exactType = pi.getExactType().resolve(scope.getWorld()); if (exactType == ResolvedTypeX.MISSING) continue; + + // Cannot do a dec prec specifying a non-aspect types unless suffixed with a '+' + if (!exactType.isAspect() && !pi.isIncludeSubtypes()) { + scope.getWorld().showMessage(IMessage.ERROR, + "Non-aspect types can only be specified in a declare precedence statement when subtypes are included. Non-aspect type is : "+exactType.getName(), + pi.getSourceLocation(),null); + } + for (int j=0; j < patterns.size(); j++) { if (j == i) continue; TypePattern pj = patterns.get(j);