]> source.dussan.org Git - aspectj.git/commitdiff
tests and fix for pr100195, local var debug info not preserved when inlining around...
authoracolyer <acolyer>
Thu, 29 Sep 2005 11:30:49 +0000 (11:30 +0000)
committeracolyer <acolyer>
Thu, 29 Sep 2005 11:30:49 +0000 (11:30 +0000)
tests/bugs150/pr100195.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/bcel/ShadowRange.java

diff --git a/tests/bugs150/pr100195.aj b/tests/bugs150/pr100195.aj
new file mode 100644 (file)
index 0000000..816711e
--- /dev/null
@@ -0,0 +1,62 @@
+import org.aspectj.testing.Tester;
+
+public class pr100195 {
+    public static void main(String[] args) {
+        new Foo().foo();
+        AroundCasting.main(new String[0]);
+    }  
+}
+
+class Foo {
+       
+    static int x;
+       
+    private String myString = "A String";
+    public static void main(String[] args) {
+        new Foo().foo();
+        AroundCasting.main(new String[0]);
+    }
+    public void foo() {
+      String myLocal = myString;
+      x = 5;
+      System.out.println(myLocal);   // breakpoint here
+      bar(x);
+    }
+    
+    public void bar(int y) {}
+}
+// Test.aj
+aspect Test {
+  void around() : ( execution(* Foo.foo(..) ) ) {
+         int y = 4;
+      System.out.println("before");
+      proceed();
+      System.out.println("after");
+  }
+}
+
+class AroundCasting {
+    public static void main(String[] args) {
+       bar(x);
+        //Tester.checkEqual(x, 1003);
+    }
+    static int x;
+    
+    static void bar(int y) {}
+}
+
+
+aspect A {
+    static boolean test() { return true; }
+
+    int around(): if (test()) && get(int AroundCasting.x) {
+        return proceed() + 1000;
+    }
+
+    void around(): execution(void AroundCasting.main(String[])) {
+        Tester.event("enter main");
+        proceed();
+    }
+}
index 9e59e59b4ef232d0282cc1eb09d8ac3eb38d021e..8dcaa3d38c6be7675bdf21707817df6b8c59c317 100644 (file)
@@ -479,6 +479,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("array clone call join points in 1.4 vs 1.3");
   }
   
+  public void testDebugInfoForAroundAdvice() {
+         runTest("debug info in around advice inlining");
+  }
+  
   // helper methods.....
   
   public SyntheticRepository createRepos(File cpentry) {
index 230e9dd0059fb7114c63adec335ea9fe9197ae5d..0f277569ccf736a1750660fc68d7b393cf708587 100644 (file)
         </compile>   
      </ajc-test> 
      
+    <ajc-test dir="bugs150" pr="100195" title="debug info in around advice inlining">
+        <compile files="pr100195.aj">
+        </compile>
+        <run class="pr100195"/>
+    </ajc-test> 
     <!-- ============================================================================ -->
     <!-- ============================================================================ -->
     
index 4deb8560d266a691fcfc9e8346657c66e59fd6f6..b6381f9a71b346ecbfa8ed90d9227082d1d15369 100644 (file)
@@ -127,8 +127,20 @@ final class ShadowRange extends Range {
                 for (int j = sources.length - 1; j >= 0; j--) {
                     InstructionTargeter source = sources[j];
                     if (source instanceof LocalVariableTag) {
-                        // XXX destroying local variable info
-                        source.updateTarget(oldIh, null);
+                       Shadow.Kind kind = getKind();
+                       if (kind == Shadow.AdviceExecution ||
+                               kind == Shadow.ConstructorExecution ||
+                               kind == Shadow.MethodExecution ||
+                               kind == Shadow.PreInitialization ||
+                               kind == Shadow.Initialization ||
+                               kind == Shadow.StaticInitialization) {
+                               // if we're extracting a whole block we can do this...
+                               source.updateTarget(oldIh, freshIh);
+                       } else {
+                            // XXX destroying local variable info
+                               // but only for a call or get join point, so no big deal
+                               source.updateTarget(oldIh, null);
+                       }
                     } else if (source instanceof Range) {
                         // exceptions and shadows are just moved
                         ((Range)source).updateTarget(oldIh, freshIh, freshBody);