diff options
author | acolyer <acolyer> | 2004-09-08 12:04:49 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-09-08 12:04:49 +0000 |
commit | eca1429e79b3dc55c1f93ffbadb3e50eb9808d9c (patch) | |
tree | d0618572a7c870e847b2d79c855c0a59420f7054 | |
parent | 8e4d8980e45ba054e7d8e3e5e7ac3aca940d0758 (diff) | |
download | aspectj-eca1429e79b3dc55c1f93ffbadb3e50eb9808d9c.tar.gz aspectj-eca1429e79b3dc55c1f93ffbadb3e50eb9808d9c.zip |
fix for Bugzilla Bug 72157
declare soft can cause programs with invalid exception behaviour to be generated
5 files changed, 53 insertions, 1 deletions
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 faa48170a..61270166d 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 @@ -33,6 +33,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.IProblemFactory; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; @@ -74,6 +75,12 @@ public class AjProblemReporter extends ProblemReporter { if (!factory.getWorld().getDeclareSoft().isEmpty()) { Shadow callSite = factory.makeShadow(location, referenceContext); Shadow enclosingExec = factory.makeShadow(referenceContext); + // PR 72157 - calls to super / this within a constructor are not part of the cons join point. + if ((callSite == null) && (enclosingExec.getKind() == Shadow.ConstructorExecution) + && (location instanceof ExplicitConstructorCall)) { + super.unhandledException(exceptionType, location); + return; + } // System.err.println("about to show error for unhandled exception: " + new String(exceptionType.sourceName()) + // " at " + location + " in " + referenceContext); diff --git a/tests/bugs/ConvertToUnchecked.java b/tests/bugs/ConvertToUnchecked.java index eb71e9f7b..966bc69d3 100644 --- a/tests/bugs/ConvertToUnchecked.java +++ b/tests/bugs/ConvertToUnchecked.java @@ -35,7 +35,7 @@ class PersistenceException extends RuntimeException class Root { - Root(String s) throws IOException { + Root(String s) /*throws IOException*/ { } } diff --git a/tests/bugs/PR72157.java b/tests/bugs/PR72157.java new file mode 100644 index 000000000..39120f5f4 --- /dev/null +++ b/tests/bugs/PR72157.java @@ -0,0 +1,35 @@ +public class PR72157 { + public PR72157() throws Exception { + throw new Exception(); + } + + public static void main(String[] args) { + new SCE2(); + } +} + +class SCE2 extends PR72157 { + public SCE2() { + super(); // CE L13? + } + +} + +class Foo { + + public Foo() throws Exception { + throw new Exception(); + } + +} + +class Goo { + public Goo() { + new Foo(); + } +} + +aspect SCEAspect { + declare soft: Exception: within(SCE2); + declare soft: Exception: within(Goo); +}
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java index be7192266..2ea8c3221 100644 --- a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java @@ -306,5 +306,8 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("around advice throws java.lang.VerifyError at runtime"); } + public void test057_decSoftWithSuper() { + runTest("declare soft can cause programs with invalid exception behaviour to be generated"); + } } diff --git a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml index ddb48afb5..ba4c2cfc8 100644 --- a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml @@ -449,3 +449,10 @@ <compile files="ArrayCloning.java"/> <run class="ArrayCloning"/> </ajc-test> + + <ajc-test dir="bugs" pr="72157" + title="declare soft can cause programs with invalid exception behaviour to be generated"> + <compile files="PR72157.java"> + <message kind="error" line="13" text="Unhandled"/> + </compile> + </ajc-test>
\ No newline at end of file |