From 01055e854df883746321b955bd5b9b41a840feda Mon Sep 17 00:00:00 2001 From: acolyer Date: Wed, 7 Jan 2004 15:21:26 +0000 Subject: [PATCH] fix for pr 48522, not warning on (un)softened exception --- .../compiler/problem/AjProblemReporter.java | 8 ++++++++ tests/ajcTests.xml | 13 +++++++++++++ tests/bugs/SofteningTooMuch.java | 15 +++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/bugs/SofteningTooMuch.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java index dd708a1b7..49b726db2 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java @@ -32,6 +32,7 @@ import org.eclipse.jdt.internal.compiler.ast.AstNode; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; +import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; @@ -71,6 +72,13 @@ public class AjProblemReporter extends ProblemReporter { for (Iterator i = world.getWorld().getDeclareSoft().iterator(); i.hasNext(); ) { DeclareSoft d = (DeclareSoft)i.next(); + // We need the exceptionType to match the type in the declare soft statement + // This means it must either be the same type or a subtype + ResolvedTypeX throwException = world.fromEclipse((ReferenceBinding)exceptionType); + FuzzyBoolean isExceptionTypeOrSubtype = + d.getException().matchesInstanceof(throwException); + if (!isExceptionTypeOrSubtype.alwaysTrue() ) continue; + if (callSite != null) { FuzzyBoolean match = d.getPointcut().match(callSite); if (match.alwaysTrue()) { diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 3f9841dc7..3b834af69 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -6821,5 +6821,18 @@ + + + + + + + + + + + diff --git a/tests/bugs/SofteningTooMuch.java b/tests/bugs/SofteningTooMuch.java new file mode 100644 index 000000000..164adb24c --- /dev/null +++ b/tests/bugs/SofteningTooMuch.java @@ -0,0 +1,15 @@ + +// pr 48522 + +public class SofteningTooMuch { + public static void main(String args[]) { + throw new Exception("should be a compiler error here"); + } +} + +class FooException extends Exception {} + +aspect ExcPolicy { + declare soft: FooException: execution(* SofteningTooMuch.*(..)); +} + -- 2.39.5