diff options
author | aclement <aclement> | 2005-01-11 11:22:15 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-01-11 11:22:15 +0000 |
commit | 603b063ecd2943e20f099712d9b754b19a380fee (patch) | |
tree | a3649ac5aa4e1a0ab475d5bee2a653785249f168 /tests | |
parent | 797b6a6afb75b14dc530bc0831566e110da3ae91 (diff) | |
download | aspectj-603b063ecd2943e20f099712d9b754b19a380fee.tar.gz aspectj-603b063ecd2943e20f099712d9b754b19a380fee.zip |
Fixes for 78021, 79554 - both to do with us breaking the exception table for a method on weaving *if* finally blocks are involved.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bugs150/PR78021.java | 45 | ||||
-rw-r--r-- | tests/bugs150/PR79554.java | 41 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/AllTests.java | 4 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java | 40 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java (renamed from tests/src/org/aspectj/systemtest/ajc150/AllTestsJava5_binaryWeaving.java) | 7 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/TestUtils.java | 2 |
6 files changed, 135 insertions, 4 deletions
diff --git a/tests/bugs150/PR78021.java b/tests/bugs150/PR78021.java new file mode 100644 index 000000000..66c86d339 --- /dev/null +++ b/tests/bugs150/PR78021.java @@ -0,0 +1,45 @@ +public class PR78021 { + + protected static Integer counter = new Integer(4); + + public static void main(String[] args) throws Exception { + try { + doSomething(); + System.err.println("TEST HAS PASSED"); + } catch (Exception e) { + System.err.println("TEST HAS FAILED: Exception thrown by doSomething: " +e.getMessage()); + throw e; + } + } + + public static void doSomething() { + int i = 0; + while (i++<1) { + counter=null; + try { + counter = new Integer(4); + // The inclusion of the next line changes the weaving ! If it is included the woven code is wrong and the exception escapes + if (counter == null) { break; } + commit(); + } catch (Throwable e) { + System.err.println("Caught exception " + e); + } finally { + System.err.println("In finally block"); + } + } + } + + protected static void commit() throws MyException { + System.err.println("Main.commit"); + } +} + +class MyException extends Exception { MyException(String s,String s2) { super(s); } } + +aspect SimpleExceptionThrowingAspect { + pointcut commitOperation() : call (* PR78021+.commit(..)); + + before() throws MyException : commitOperation() { + throw new MyException("Dummy My Exception", "55102"); + } +}
\ No newline at end of file diff --git a/tests/bugs150/PR79554.java b/tests/bugs150/PR79554.java new file mode 100644 index 000000000..5bab1d270 --- /dev/null +++ b/tests/bugs150/PR79554.java @@ -0,0 +1,41 @@ +/* + * Created on 22.10.2004 + */ + +/** + * @author Thomas Knauth + */ +public class PR79554 +{ + public static void main(String[] args) + { + try + { + if ( args.length < 0 ) + { + System.out.println("Usage!"); + return; + } + + throw new Exception(); + } + catch ( Throwable e ) + { + System.out.println( "exception caught!" ); + //e.printStackTrace(); + } + finally + { + System.out.println("finally block entered!"); + } + } +} + +aspect Aspect { + + pointcut main(): execution(void main(String[])); + + after(): main(){ + System.out.println("Aspect calling after main!"); + } +} diff --git a/tests/src/org/aspectj/systemtest/AllTests.java b/tests/src/org/aspectj/systemtest/AllTests.java index 961d99693..22d673892 100644 --- a/tests/src/org/aspectj/systemtest/AllTests.java +++ b/tests/src/org/aspectj/systemtest/AllTests.java @@ -13,7 +13,7 @@ import org.aspectj.systemtest.ajc10x.Ajc10xTests; import org.aspectj.systemtest.ajc11.Ajc11Tests; import org.aspectj.systemtest.ajc120.Ajc120Tests; import org.aspectj.systemtest.ajc121.Ajc121Tests; -import org.aspectj.systemtest.ajc150.AllTestsJava5_binaryWeaving; +import org.aspectj.systemtest.ajc150.AllTestsAspectJ150; import org.aspectj.systemtest.aspectpath.AspectPathTests; import org.aspectj.systemtest.base.BaseTests; import org.aspectj.systemtest.design.DesignTests; @@ -36,7 +36,7 @@ public class AllTests { public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.3"); //$JUnit-BEGIN$ - suite.addTest(AllTestsJava5_binaryWeaving.suite()); + suite.addTest(AllTestsAspectJ150.suite()); suite.addTest(Ajc121Tests.suite()); suite.addTest(Ajc120Tests.suite()); suite.addTest(Ajc11Tests.suite()); diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java new file mode 100644 index 000000000..e0b22155a --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.File; + +import org.aspectj.tools.ajc.CompilationResult; + + +/** + */ +public class Ajc150TestsNoHarness extends TestUtils { + + protected void setUp() throws Exception { + super.setUp(); + baseDir = new File("../tests/bugs150"); + } + + public void testIncorrectExceptionTableWhenBreakInMethod_pr78021() { + CompilationResult cR=ajc(baseDir,new String[]{"PR78021.java"}); + if (verbose) { System.err.println(cR); System.err.println(cR.getStandardError());} + RunResult rR = run("PR78021"); + if (verbose) {System.err.println(rR.getStdErr());} + } + + public void testIncorrectExceptionTableWhenReturnInMethod_pr79554() { + CompilationResult cR=ajc(baseDir,new String[]{"PR79554.java"}); + if (verbose) { System.err.println(cR); System.err.println(cR.getStandardError());} + RunResult rR = run("PR79554"); + if (verbose) {System.err.println(rR.getStdErr());} + } +}
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/AllTestsJava5_binaryWeaving.java b/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java index 353b5d07d..d138eb64b 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/AllTestsJava5_binaryWeaving.java +++ b/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java @@ -19,13 +19,16 @@ import junit.framework.TestSuite; * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ -public class AllTestsJava5_binaryWeaving { +public class AllTestsAspectJ150 { public static Test suite() { TestSuite suite = new TestSuite("Java5 - binary weaving"); //$JUnit-BEGIN$ suite.addTestSuite(MigrationTests.class); suite.addTest(Ajc150Tests.suite()); + suite.addTestSuite(Ajc150TestsNoHarness.class); + + // These are binary weaving tests suite.addTest(AccBridgeMethods.suite()); suite.addTestSuite(CovarianceTests.class); suite.addTestSuite(Enums.class); @@ -33,6 +36,8 @@ public class AllTestsJava5_binaryWeaving { suite.addTestSuite(AnnotationPointcutsTests.class); suite.addTestSuite(VarargsTests.class); suite.addTestSuite(AnnotationRuntimeTests.class); + + //$JUnit-END$ return suite; } diff --git a/tests/src/org/aspectj/systemtest/ajc150/TestUtils.java b/tests/src/org/aspectj/systemtest/ajc150/TestUtils.java index b62400c7c..dbaf6917d 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/TestUtils.java +++ b/tests/src/org/aspectj/systemtest/ajc150/TestUtils.java @@ -21,7 +21,7 @@ import org.aspectj.tools.ajc.AjcTestCase; import org.aspectj.tools.ajc.CompilationResult; public abstract class TestUtils extends AjcTestCase { - private static final boolean verbose = false; + protected static final boolean verbose = false; protected File baseDir; protected CompilationResult binaryWeave(String inpath,String insource,int expErrors,int expWarnings) { |