aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java59
-rw-r--r--org.eclipse.jdt.core/jdtcore-for-aspectj-src.zipbin3868181 -> 3868198 bytes
-rw-r--r--org.eclipse.jdt.core/jdtcore-for-aspectj.jarbin7145491 -> 7145501 bytes
-rw-r--r--tests/bugs171/pr387444/Code.java12
-rw-r--r--tests/bugs171/pr387444/Code2.java33
-rw-r--r--tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests_need17jre.java43
-rw-r--r--tests/src/org/aspectj/systemtest/ajc171/ajc171.xml19
8 files changed, 158 insertions, 10 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 f43281317..2808b3436 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
@@ -100,8 +100,9 @@ public class AjProblemReporter extends ProblemReporter {
// System.err.println("about to show error for unhandled exception: " + new String(exceptionType.sourceName()) +
// " at " + location + " in " + referenceContext);
- for (Iterator i = factory.getWorld().getDeclareSoft().iterator(); i.hasNext();) {
- DeclareSoft d = (DeclareSoft) i.next();
+ for (DeclareSoft d: factory.getWorld().getDeclareSoft()) {
+// for (Iterator<DeclareSoft> i = factory.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
ResolvedType throwException = factory.fromEclipse((ReferenceBinding) exceptionType);
@@ -139,6 +140,60 @@ public class AjProblemReporter extends ProblemReporter {
super.unhandledException(exceptionType, location);
}
+
+ public void unhandledExceptionFromAutoClose(TypeBinding exceptionType, ASTNode location) {
+ 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);
+
+ for (DeclareSoft d: factory.getWorld().getDeclareSoft()) {
+// for (Iterator<DeclareSoft> i = factory.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
+ ResolvedType throwException = factory.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()) {
+ // System.err.println("matched callSite: " + callSite + " with " + d);
+ return;
+ } else if (!match.alwaysFalse()) {
+ // !!! need this check to happen much sooner
+ // throw new RuntimeException("unimplemented, shouldn't have fuzzy match here");
+ }
+ }
+ if (enclosingExec != null) {
+ FuzzyBoolean match = d.getPointcut().match(enclosingExec);
+ if (match.alwaysTrue()) {
+ // System.err.println("matched enclosingExec: " + enclosingExec + " with " + d);
+ return;
+ } else if (!match.alwaysFalse()) {
+ // !!! need this check to happen much sooner
+ // throw new RuntimeException("unimplemented, shouldn't have fuzzy match here");
+ }
+ }
+ }
+ }
+
+ // ??? is this always correct
+ if (location instanceof Proceed) {
+ return;
+ }
+
+ super.unhandledExceptionFromAutoClose(exceptionType, location);
+ }
private boolean isPointcutDeclaration(MethodBinding binding) {
return CharOperation.prefixEquals(PointcutDeclaration.mangledPrefix, binding.selector);
diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip
index 619a7f989..3f0b8c062 100644
--- a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip
+++ b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip
Binary files differ
diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar
index 82b35f6d9..675d5a2d4 100644
--- a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar
+++ b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar
Binary files differ
diff --git a/tests/bugs171/pr387444/Code.java b/tests/bugs171/pr387444/Code.java
new file mode 100644
index 000000000..4407908f6
--- /dev/null
+++ b/tests/bugs171/pr387444/Code.java
@@ -0,0 +1,12 @@
+import java.io.*;
+
+public class Code {
+ public void m() { // throws IOException {
+ try (FileReader reader = new FileReader("test.txt")) {
+ System.out.println("");
+ }
+ }
+}
+aspect X {
+ declare soft: IOException: within(*);
+}
diff --git a/tests/bugs171/pr387444/Code2.java b/tests/bugs171/pr387444/Code2.java
new file mode 100644
index 000000000..6bc83d392
--- /dev/null
+++ b/tests/bugs171/pr387444/Code2.java
@@ -0,0 +1,33 @@
+import java.io.*;
+import org.aspectj.lang.*;
+
+public class Code2 {
+ public static void main(String[]argv) {
+ try {
+ new Code2().m();
+ } catch (SoftException se) {
+ System.out.println(se.getWrappedThrowable().getMessage());
+ }
+ }
+
+ public void m() {
+ try (MyReader reader = new MyReader()) {
+ System.out.println("");
+ }
+ }
+}
+aspect X {
+ declare soft: MyException: within(Code2);
+}
+
+class MyReader implements AutoCloseable {
+ public void close() throws MyException {
+ throw new MyException("foo");
+ }
+}
+
+class MyException extends Exception {
+ public MyException(String s) {
+ super(s);
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java b/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java
index 39f2884fd..95d459a5d 100644
--- a/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java
@@ -20,7 +20,7 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
* @author Andy Clement
*/
public class Ajc171Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
-
+
public void testUnresolvableEnum_pr387568() {
runTest("unresolvable enum");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests_need17jre.java b/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests_need17jre.java
new file mode 100644
index 000000000..d6faaa516
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests_need17jre.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc171;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc171Tests_need17jre extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ public void testSoft17_pr387444() {
+ runTest("soft 17");
+ }
+
+ public void testSoft17_pr387444_2() {
+ runTest("soft 17 2");
+ }
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc171Tests_need17jre.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return new File("../tests/src/org/aspectj/systemtest/ajc171/ajc171.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml b/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml
index 7f6a372d8..4f09f7c84 100644
--- a/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml
+++ b/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml
@@ -2,16 +2,21 @@
<suite>
- <ajc-test dir="bugs171/pr387568" title="unresolvable enum">
- <compile files="Color.java Code.java" options="-1.5"/>
- <!--
- <run class="de.scrum_master.galileo.filter.JsoupFilter">
+ <ajc-test dir="bugs171/pr387444" title="soft 17">
+ <compile files="Code.java" options="-1.7"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs171/pr387444" title="soft 17 2">
+ <compile files="Code2.java" options="-1.7"/>
+ <run class="Code2">
<stdout>
- <line text="JsoupFilter.getLogMessage()"/>
- <line text="run()"/>
+ <line text="foo"/>
</stdout>
</run>
- -->
+ </ajc-test>
+
+ <ajc-test dir="bugs171/pr387568" title="unresolvable enum">
+ <compile files="Color.java Code.java" options="-1.5"/>
</ajc-test>
<ajc-test dir="bugs171/pr386049" title="itd abstract">