Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Missing LocalVariableTable info for around advice ?

Hi!
When debugging java code woven with an "around" advice, it looks like the LocalVariableTable information gets lost during the weaving. E.g. considering the following code:

// Foo.java
public class Foo {
    private String myString = "A String";
    public static void main(String[] args) {
        new Foo().foo();
    }   
    private void foo() {
      String myLocal = myString;
      System.out.println(myLocal);   // breakpoint here
    }
}
// Test.aj
aspect Test {
  void around() : ( execution(* Foo.foo(..) ) ) {
      System.out.println("before");
      proceed();
      System.out.println("after");
  }
}

We compiled with ajc 1.2.1:
  ajc -g -preserveAllLocals -sourceroots . 

When running Foo in the Eclipse 3.1.0 debugger and setting a breakpoint at the "System.out.println(myLocal);" line, the debugger "Variables" window is empty. Also, disassembling with javap shows that the LocalVariableTable is empty in the generated foo_aroundBody1$advice :

  private static final void foo_aroundBody1$advice(Foo,Test,org.aspectj.runtime.internal.AroundClosure);
  Signature: (LFoo;LTest;Lorg/aspectj/runtime/internal/AroundClosure;)V
  Code:
   0:   getstatic       #34; //Field java/lang/System.out:Ljava/io/PrintStream;
   3:   ldc     #47; //String before
   5:   invokevirtual   #40; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
   8:   aload_2
   9:   astore_3
   10:  aload_0
   11:  invokestatic    #65; //Method foo_aroundBody0:(LFoo;)V
   14:  getstatic       #34; //Field java/lang/System.out:Ljava/io/PrintStream;
   17:  ldc     #55; //String after
   19:  invokevirtual   #40; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
   22:  return

  LineNumberTable: 
   line 103: 0
   line 104: 8
   line 105: 14
   line 106: 22
  LocalVariableTable: 
   Start  Length  Slot  Name   Signature
   0      23      0    this       LTest;
   0      23      1    ajc_aroundClosure       Lorg/aspectj/runtime/internal/AroundClosure;



I guess the answer is that the original class LocalVariableTable information is not copied over to the foo_aroundBody1$advice, and to do that would involves changes to the org.eclipse.jdt module. I would be happy to look into this if someone could guide me where to start.

- Per


Back to the top