--- /dev/null
+public class SampleTest {
+ public interface ByteReadingStrategy {
+ void readBytes(java.io.InputStream str);
+ }
+
+ public ByteReadingStrategy byteReadingStrategy;
+
+ private final ByteReadingStrategy offsetBuf = new ByteReadingStrategy() {
+ public void readBytes(java.io.InputStream str) {
+ str.read();
+ }
+ };
+
+ private class NamedByteReadingStrategy {
+ public void readBytes(java.io.InputStream str) {
+ str.read();
+ }
+ };
+
+ public void foo(){}
+}
+
+aspect Soften {
+ pointcut softenedTests() :
+ within(SampleTest+) && execution(* *(..)) && !execution(* *(..) throws Exception+);
+
+ declare soft: Exception+: softenedTests();
+}
--- /dev/null
+import java.sql.SQLException;
+
+public aspect Softener {
+
+ // expect this to soften the exception thrown
+ declare soft: Throwable : execution(* *.run());
+}
+
+class SoftenInner {
+ public static void main(String args[]) {
+ new SoftenInner().foo();
+ }
+
+ public void foo() {
+ new Runnable() {
+ public void run() {
+ throw new SQLException("test");
+ }
+ }.run();
+ }
+
+}
--- /dev/null
+import java.sql.SQLException;
+
+public aspect Softener2 {
+
+ // don't expect this to soften the exception thrown
+ declare soft: Throwable: execution(* SoftenInner.foo());
+
+}
+
+class SoftenInner {
+ public static void main(String args[]) {
+ new SoftenInner().foo();
+ }
+
+ public void foo() {
+ new Runnable() {
+ public void run() {
+ throw new SQLException("test");
+ }
+ }.run();
+ }
+
+}
runTest("ensure LineNumberTable correct with generics, for each and continue");
}
+ public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772() {
+ runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class");
+ }
+
+ public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772_2() {
+ runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class - 2");
+ }
+
+ public void testDeclareSoftAndInnerClasses_pr125981() {
+ runTest("declare soft and inner classes");
+ }
+
/////////////////////////////////////////
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class);
</ant>
</ajc-test>
+ <ajc-test dir="bugs153/pr151772" title="ensure declare soft doesn't allow undeclared exception in anonymous inner class">
+ <compile files="Softener.aj"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs153/pr151772" title="ensure declare soft doesn't allow undeclared exception in anonymous inner class - 2">
+ <compile files="Softener2.aj">
+ <message kind="error" line="18" text="Unhandled exception type SQLException"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs153/pr125981" title="declare soft and inner classes">
+ <compile files="SampleTest.java"/>
+ </ajc-test>
+
</suite>
\ No newline at end of file