From 29457c3d6d0b4cd7cca1d2867e6bd80a56a24722 Mon Sep 17 00:00:00 2001 From: jhugunin Date: Mon, 4 Aug 2003 21:04:49 +0000 Subject: [PATCH] fixes for Bugzilla Bug 40858 super-qualified pointcut reference cause weaver stack trace and Bugzilla Bug 40814 no error when defining interface pointcuts --- .../compiler/ast/PointcutDeclaration.java | 22 +++++++++++++++--- tests/ajcTests.xml | 22 ++++++++++++++++++ tests/ajcTestsFailing.xml | 23 ++----------------- tests/bugs/AbstractPointcutCE.java | 16 +++++++++++++ tests/bugs/InterfacePointcutCE.java | 7 ------ tests/bugs/SuperPointcutCE.java | 4 ++-- .../weaver/patterns/ReferencePointcut.java | 2 ++ 7 files changed, 63 insertions(+), 33 deletions(-) create mode 100644 tests/bugs/AbstractPointcutCE.java delete mode 100644 tests/bugs/InterfacePointcutCE.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java index 9579cc87e..b987c418b 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java @@ -19,6 +19,8 @@ import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; import org.aspectj.ajdt.internal.core.builder.EclipseSourceContext; import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.ResolvedPointcutDefinition; +import org.aspectj.weaver.ResolvedTypeX; +import org.aspectj.weaver.TypeX; import org.aspectj.weaver.patterns.Pointcut; import org.eclipse.jdt.internal.compiler.ClassFile; import org.eclipse.jdt.internal.compiler.CompilationResult; @@ -72,8 +74,20 @@ public class PointcutDeclaration extends MethodDeclaration { this.declaredName = new String(selector); selector = CharOperation.concat(mangledPrefix, '$', selector, '$', Integer.toHexString(sourceStart).toCharArray()); - if (pointcutDesignator == null) return; //XXX - pointcutDesignator.postParse(typeDec, this); + + if (Modifier.isAbstract(this.declaredModifiers) && + !(typeDec instanceof AspectDeclaration)) + { + typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd, + "The abstract pointcut " + new String(declaredName) + + " can only be defined in an aspect"); + ignoreFurtherInvestigation = true; + return; + } + + if (pointcutDesignator != null) { + pointcutDesignator.postParse(typeDec, this); + } } public void resolveStatements() { @@ -86,7 +100,9 @@ public class PointcutDeclaration extends MethodDeclaration { if (Modifier.isAbstract(this.declaredModifiers)&& (pointcutDesignator != null)) { scope.problemReporter().signalError(sourceStart, sourceEnd, "abstract pointcut can't have body"); - } + ignoreFurtherInvestigation = true; + return; + } if (pointcutDesignator != null) { pointcutDesignator.finishResolveTypes(this, this.binding, arguments.length, diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 0058ddf2c..d6ae4b455 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -6477,5 +6477,27 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index 2ac4c8bbe..f1fd611a1 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -4,24 +4,6 @@ - - - - - - - - - - - - - @@ -36,7 +18,6 @@ - - - + + diff --git a/tests/bugs/AbstractPointcutCE.java b/tests/bugs/AbstractPointcutCE.java new file mode 100644 index 000000000..898a72b0a --- /dev/null +++ b/tests/bugs/AbstractPointcutCE.java @@ -0,0 +1,16 @@ + + +/** @testcase PR#40814 compile error expected for pointcuts in interfaces + * revised to check for error on abstract pointcuts in interfaces or classes + **/ +interface I { + abstract pointcut pc(); // CE +} + +abstract class C { + abstract pointcut pc(); // CE +} + +class Concrete { + abstract pointcut pc(); // CE +} diff --git a/tests/bugs/InterfacePointcutCE.java b/tests/bugs/InterfacePointcutCE.java deleted file mode 100644 index 49bcd33de..000000000 --- a/tests/bugs/InterfacePointcutCE.java +++ /dev/null @@ -1,7 +0,0 @@ - - -/** @testcase PR#40814 compile error expected for pointcuts in interfaces */ -interface I { - abstract pointcut pc(); // CE - pointcut publicCalls() : call(public * *(..)) || call(public new(..)); // CE -} \ No newline at end of file diff --git a/tests/bugs/SuperPointcutCE.java b/tests/bugs/SuperPointcutCE.java index 7231fb00e..be6111e16 100644 --- a/tests/bugs/SuperPointcutCE.java +++ b/tests/bugs/SuperPointcutCE.java @@ -1,6 +1,6 @@ -public class MissingTypeSigatureCE { +public class SuperPointcutCE { public static void main(String[] a) { new C().run(); } @@ -20,7 +20,7 @@ abstract aspect AA { /** @testcase PR#40858 weaver trace on mis-qualified pointcut reference */ aspect B extends AA { - pointcut pc() : super.pc() + pointcut pc() : super.pc() // CE super not allowed in 1.1 && !call(void println(..)); pointcut blah() : UnknownType.pc(); // CE diff --git a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java index 2d3291792..8c9d546f3 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java +++ b/weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java @@ -113,6 +113,8 @@ public class ReferencePointcut extends Pointcut { public void resolveBindings(IScope scope, Bindings bindings) { if (onTypeSymbolic != null) { onType = onTypeSymbolic.resolveExactType(scope, bindings); + // in this case we've already signalled an error + if (onType == ResolvedTypeX.MISSING) return; } ResolvedTypeX searchType; -- 2.39.5