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 /weaver | |
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 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java | 35 | ||||
-rw-r--r-- | weaver/testdata/AfterFancyHelloWorld.txt | 18 | ||||
-rw-r--r-- | weaver/testdata/AfterHelloWorld.txt | 1 | ||||
-rw-r--r-- | weaver/testdata/AfterThrowingFancyHelloWorld.txt | 18 | ||||
-rw-r--r-- | weaver/testdata/AfterThrowingHelloWorld.txt | 1 | ||||
-rw-r--r-- | weaver/testdata/AfterThrowingParamFancyHelloWorld.txt | 18 |
6 files changed, 54 insertions, 37 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java index 9c002bd9c..88f397818 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.ListIterator; import java.util.Map; import java.util.Set; import java.util.Stack; @@ -972,7 +973,7 @@ public final class LazyMethodGen { } - /** This proedure should not currently be used. + /** This procedure should not currently be used. */ // public void killNops() { // InstructionHandle curr = body.getStart(); @@ -1007,10 +1008,19 @@ public final class LazyMethodGen { } } + // Update to all these comments, ASC 11-01-2005 + // The right thing to do may be to do more with priorities as + // we create new exception handlers, but that is a relatively + // complex task. In the meantime, just taking account of the + // priority here enables a couple of bugs to be fixed to do + // with using return or break in code that contains a finally + // block (pr78021,pr79554). + // exception ordering. // What we should be doing is dealing with priority inversions way earlier than we are // and counting on the tree structure. In which case, the below code is in fact right. + // XXX THIS COMMENT BELOW IS CURRENTLY WRONG. // An exception A preceeds an exception B in the exception table iff: @@ -1022,15 +1032,20 @@ public final class LazyMethodGen { // but I don't trust the only implementation, TreeSet, to do the right thing. /* private */ static void insertHandler(ExceptionRange fresh, LinkedList l) { -// for (ListIterator iter = l.listIterator(); iter.hasNext();) { -// ExceptionRange r = (ExceptionRange) iter.next(); -// if (fresh.getPriority() >= r.getPriority()) { -// iter.previous(); -// iter.add(fresh); -// return; -// } -// } - l.add(0, fresh); + // Old implementation, simply: l.add(0,fresh); + for (ListIterator iter = l.listIterator(); iter.hasNext();) { + ExceptionRange r = (ExceptionRange) iter.next(); + int freal = fresh.getRealStart().getPosition(); + int rreal = r.getRealStart().getPosition(); + if (fresh.getPriority() >= r.getPriority()) { + iter.previous(); + iter.add(fresh); + return; + } + } + + // we have reached the end + l.add(fresh); } diff --git a/weaver/testdata/AfterFancyHelloWorld.txt b/weaver/testdata/AfterFancyHelloWorld.txt index b693040af..04fe22f18 100644 --- a/weaver/testdata/AfterFancyHelloWorld.txt +++ b/weaver/testdata/AfterFancyHelloWorld.txt @@ -19,11 +19,11 @@ public abstract class FancyHelloWorld extends java.lang.Object: method-execution(void FancyHelloWorld.main(java.lang.String[])) | catch java.lang.Throwable -> E6 | | field-get(java.io.PrintStream java.lang.System.out) - | | | catch java.lang.Throwable -> E5 + | | | catch java.lang.Throwable -> E3 | | | | GETSTATIC java.lang.System.out Ljava/io/PrintStream; (line 9) - | | | catch java.lang.Throwable -> E5 + | | | catch java.lang.Throwable -> E3 | | | GOTO L0 - | | | E5: ASTORE 5 + | | | E3: ASTORE 5 | | | INVOKESTATIC Aspect.ajc_after_field_get ()V | | | ALOAD 5 | | | ATHROW @@ -32,8 +32,8 @@ public abstract class FancyHelloWorld extends java.lang.Object: | | | NOP | | field-get(java.io.PrintStream java.lang.System.out) | | ASTORE_1 - | | finally -> E4 - | | | catch java.lang.Exception -> E3 + | | finally -> E5 + | | | catch java.lang.Exception -> E4 | | | | ALOAD_1 // java.io.PrintStream out (line 11) | | | | LDC "bye" | | | | method-call(void java.io.PrintStream.println(java.lang.String)) @@ -50,8 +50,8 @@ public abstract class FancyHelloWorld extends java.lang.Object: | | | | | NOP | | | | method-call(void java.io.PrintStream.println(java.lang.String)) | | | | GOTO L3 - | | | catch java.lang.Exception -> E3 - | | | E3: ASTORE_2 (line 12) + | | | catch java.lang.Exception -> E4 + | | | E4: ASTORE_2 (line 12) | | | ALOAD_1 // java.io.PrintStream out (line 13) | | | ALOAD_2 // java.lang.Exception e | | | method-call(void java.io.PrintStream.println(java.lang.Object)) @@ -67,9 +67,9 @@ public abstract class FancyHelloWorld extends java.lang.Object: | | | | INVOKESTATIC Aspect.ajc_after_method_call ()V | | | | NOP | | | method-call(void java.io.PrintStream.println(java.lang.Object)) - | | finally -> E4 + | | finally -> E5 | | GOTO L3 - | | E4: ASTORE 4 (line 14) + | | E5: ASTORE 4 (line 14) | | JSR L4 | | ALOAD 4 | | ATHROW diff --git a/weaver/testdata/AfterHelloWorld.txt b/weaver/testdata/AfterHelloWorld.txt index 4c0e6db53..190674778 100644 --- a/weaver/testdata/AfterHelloWorld.txt +++ b/weaver/testdata/AfterHelloWorld.txt @@ -55,4 +55,5 @@ public class HelloWorld extends java.lang.Object: | RETURN method-execution(void HelloWorld.main(java.lang.String[])) end public static void main(String[]) + end public class HelloWorld diff --git a/weaver/testdata/AfterThrowingFancyHelloWorld.txt b/weaver/testdata/AfterThrowingFancyHelloWorld.txt index 3323beea6..572e86072 100644 --- a/weaver/testdata/AfterThrowingFancyHelloWorld.txt +++ b/weaver/testdata/AfterThrowingFancyHelloWorld.txt @@ -17,19 +17,19 @@ public abstract class FancyHelloWorld extends java.lang.Object: method-execution(void FancyHelloWorld.main(java.lang.String[])) | catch java.lang.Throwable -> E6 | | field-get(java.io.PrintStream java.lang.System.out) - | | | catch java.lang.Throwable -> E5 + | | | catch java.lang.Throwable -> E3 | | | | GETSTATIC java.lang.System.out Ljava/io/PrintStream; (line 9) - | | | catch java.lang.Throwable -> E5 + | | | catch java.lang.Throwable -> E3 | | | GOTO L0 - | | | E5: ASTORE 5 + | | | E3: ASTORE 5 | | | INVOKESTATIC Aspect.ajc_afterThrowing_field_get ()V | | | ALOAD 5 | | | ATHROW | | | L0: NOP | | field-get(java.io.PrintStream java.lang.System.out) | | ASTORE_1 - | | finally -> E4 - | | | catch java.lang.Exception -> E3 + | | finally -> E5 + | | | catch java.lang.Exception -> E4 | | | | ALOAD_1 // java.io.PrintStream out (line 11) | | | | LDC "bye" | | | | method-call(void java.io.PrintStream.println(java.lang.String)) @@ -44,8 +44,8 @@ public abstract class FancyHelloWorld extends java.lang.Object: | | | | | L1: NOP | | | | method-call(void java.io.PrintStream.println(java.lang.String)) | | | | GOTO L3 - | | | catch java.lang.Exception -> E3 - | | | E3: ASTORE_2 (line 12) + | | | catch java.lang.Exception -> E4 + | | | E4: ASTORE_2 (line 12) | | | ALOAD_1 // java.io.PrintStream out (line 13) | | | ALOAD_2 // java.lang.Exception e | | | method-call(void java.io.PrintStream.println(java.lang.Object)) @@ -59,9 +59,9 @@ public abstract class FancyHelloWorld extends java.lang.Object: | | | | ATHROW | | | | L2: NOP | | | method-call(void java.io.PrintStream.println(java.lang.Object)) - | | finally -> E4 + | | finally -> E5 | | GOTO L3 - | | E4: ASTORE 4 (line 14) + | | E5: ASTORE 4 (line 14) | | JSR L4 | | ALOAD 4 | | ATHROW diff --git a/weaver/testdata/AfterThrowingHelloWorld.txt b/weaver/testdata/AfterThrowingHelloWorld.txt index 6b307e761..822f1cd6c 100644 --- a/weaver/testdata/AfterThrowingHelloWorld.txt +++ b/weaver/testdata/AfterThrowingHelloWorld.txt @@ -47,4 +47,5 @@ public class HelloWorld extends java.lang.Object: | ATHROW method-execution(void HelloWorld.main(java.lang.String[])) end public static void main(String[]) + end public class HelloWorld diff --git a/weaver/testdata/AfterThrowingParamFancyHelloWorld.txt b/weaver/testdata/AfterThrowingParamFancyHelloWorld.txt index ecc17dcbd..08a2b89f4 100644 --- a/weaver/testdata/AfterThrowingParamFancyHelloWorld.txt +++ b/weaver/testdata/AfterThrowingParamFancyHelloWorld.txt @@ -10,11 +10,11 @@ public abstract class FancyHelloWorld extends java.lang.Object: public static void main(String[]): method-execution(void FancyHelloWorld.main(java.lang.String[])) | field-get(java.io.PrintStream java.lang.System.out) - | | catch java.lang.Throwable -> E2 + | | catch java.lang.Throwable -> E0 | | | GETSTATIC java.lang.System.out Ljava/io/PrintStream; (line 9) - | | catch java.lang.Throwable -> E2 + | | catch java.lang.Throwable -> E0 | | GOTO L0 - | | E2: ASTORE 5 + | | E0: ASTORE 5 | | ALOAD 5 | | INVOKESTATIC Aspect.ajc_afterThrowing_field_get (Ljava/lang/Throwable;)V | | ALOAD 5 @@ -22,20 +22,20 @@ public abstract class FancyHelloWorld extends java.lang.Object: | | L0: NOP | field-get(java.io.PrintStream java.lang.System.out) | ASTORE_1 - | finally -> E1 - | | catch java.lang.Exception -> E0 + | finally -> E2 + | | catch java.lang.Exception -> E1 | | | ALOAD_1 // java.io.PrintStream out (line 11) | | | LDC "bye" | | | INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/String;)V | | | GOTO L1 - | | catch java.lang.Exception -> E0 - | | E0: ASTORE_2 (line 12) + | | catch java.lang.Exception -> E1 + | | E1: ASTORE_2 (line 12) | | ALOAD_1 // java.io.PrintStream out (line 13) | | ALOAD_2 // java.lang.Exception e | | INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/Object;)V - | finally -> E1 + | finally -> E2 | GOTO L1 - | E1: ASTORE 4 (line 14) + | E2: ASTORE 4 (line 14) | JSR L2 | ALOAD 4 | ATHROW |