Hi,
My bad !
i use the javac Ant task to compile the TestingClass ( to avoid CTW weaving) , which "debug" parameter is Off by default, turning it to On, all runs as expected, and thethisJoinPoint.getStaticPart().getSourceLocation().getLine() returns the correct line number
Sorry for the noise
Compiling with iajc for weaving at Compile Time, certainly uses javac with debug set to On, am i right?

Le 28/12/2012 10:24, Pasturel a écrit :
Hi,
I am not an expert of javap analysis.
I try to join the whole trace.

I think you are right. decompiling the TestingClass with JD-GUI, doesn't show any line number.

has i made something wrong, at compilation time ?

extract of javap -verbose TestingClass :

public class jlp.aspectj.test.TestingClass extends java.lang.Object implements java.lang.Runnable
  minor version: 0
  major version: 49
  Constant pool:
const #1 = Field #40.#69; // jlp/aspectj/test/TestingClass.name:Ljava/lang/String;
const #2 = Method    #44.#70;    // java/lang/Object."<init>":()V
const #3 = String    #71;    //
const #4 = Field    #40.#72;    // jlp/aspectj/test/TestingClass.running:Z
const #5 = int    1000000;
const #6 = Field    #40.#73;    // jlp/aspectj/test/TestingClass.limit:I
const #7 = class    #74;    //  java/lang/Thread
const #8 = Method #7.#75; // java/lang/Thread."<init>":(Ljava/lang/Runnable;)V const #9 = Field #40.#76; // jlp/aspectj/test/TestingClass.thread:Ljava/lang/Thread;
const #10 = String    #77;    //  no_name
const #11 = Method #40.#78; // jlp/aspectj/test/TestingClass."<init>":(Ljava/lang/String;)V const #12 = Field #79.#80; // java/lang/System.out:Ljava/io/PrintStream;
const #13 = class    #81;    //  java/lang/StringBuilder
const #14 = Method    #13.#70;    // java/lang/StringBuilder."<init>":()V
const #15 = Method #13.#82; // java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
const #16 = String    #83;    //  .myShortMethod : I will sleep for 100 ms
const #17 = Method #13.#84; // java/lang/StringBuilder.toString:()Ljava/lang/String; const #18 = Method #85.#86; // java/io/PrintStream.println:(Ljava/lang/String;)V
const #19 = long    100l;
const #21 = Method    #7.#87;    //  java/lang/Thread.sleep:(J)V
const #22 = class    #88;    //  java/lang/InterruptedException
const #23 = Method #22.#89; // java/lang/InterruptedException.printStackTrace:()V
const #24 = String    #90;    //  .myLongMethod : I will sleep for 1s
const #25 = long    1000l;
const #27 = class    #91;    //  java/util/HashMap
const #28 = Method    #27.#70;    // java/util/HashMap."<init>":()V
const #29 = String    #92;    //  .myStressingMethod :  limit=
const #30 = Method #13.#93; // java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
const #31 = class    #94;    //  java/lang/Integer
const #32 = Method    #31.#95;    // java/lang/Integer."<init>":(I)V
const #33 = Method #31.#84; // java/lang/Integer.toString:()Ljava/lang/String; const #34 = Method #27.#96; // java/util/HashMap.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
const #35 = Method    #27.#97;    // java/util/HashMap.clear:()V
const #36 = Method #40.#98; // jlp/aspectj/test/TestingClass.myShortMethod:()V const #37 = Method #40.#99; // jlp/aspectj/test/TestingClass.myStressingMethod:(I)V const #38 = Method #40.#100; // jlp/aspectj/test/TestingClass.myLongMethod:()V const #39 = Method #31.#101; // java/lang/Integer.parseInt:(Ljava/lang/String;)I
const #40 = class    #102;    //  jlp/aspectj/test/TestingClass
const #41 = String    #103;    //  thread_
const #42 = Method #40.#104; // jlp/aspectj/test/TestingClass."<init>":(Ljava/lang/String;I)V
const #43 = Method    #7.#105;    //  java/lang/Thread.start:()V
const #44 = class    #106;    //  java/lang/Object
const #45 = class    #107;    //  java/lang/Runnable
const #46 = Asciz    name;
const #47 = Asciz    Ljava/lang/String;;
const #48 = Asciz    running;
const #49 = Asciz    Z;
const #50 = Asciz    limit;
const #51 = Asciz    I;
const #52 = Asciz    thread;
const #53 = Asciz    Ljava/lang/Thread;;
const #54 = Asciz    getName;
const #55 = Asciz    ()Ljava/lang/String;;
const #56 = Asciz    Code;
const #57 = Asciz    setName;
const #58 = Asciz    (Ljava/lang/String;)V;
const #59 = Asciz    <init>;
const #60 = Asciz    (Ljava/lang/String;I)V;
const #61 = Asciz    ()V;
const #62 = Asciz    myShortMethod;
const #63 = Asciz    myLongMethod;
const #64 = Asciz    myStressingMethod;
const #65 = Asciz    (I)V;
const #66 = Asciz    run;
const #67 = Asciz    main;
const #68 = Asciz    ([Ljava/lang/String;)V;
const #69 = NameAndType    #46:#47;//  name:Ljava/lang/String;
const #70 = NameAndType    #59:#61;//  "<init>":()V
const #71 = Asciz    ;
const #72 = NameAndType    #48:#49;//  running:Z
const #73 = NameAndType    #50:#51;//  limit:I
const #74 = Asciz    java/lang/Thread;
const #75 = NameAndType    #59:#108;// "<init>":(Ljava/lang/Runnable;)V
const #76 = NameAndType    #52:#53;//  thread:Ljava/lang/Thread;
const #77 = Asciz    no_name;
const #78 = NameAndType    #59:#58;// "<init>":(Ljava/lang/String;)V
const #79 = class    #109;    //  java/lang/System
const #80 = NameAndType    #110:#111;// out:Ljava/io/PrintStream;
const #81 = Asciz    java/lang/StringBuilder;
const #82 = NameAndType #112:#113;// append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
const #83 = Asciz    .myShortMethod : I will sleep for 100 ms;
const #84 = NameAndType    #114:#55;// toString:()Ljava/lang/String;
const #85 = class    #115;    //  java/io/PrintStream
const #86 = NameAndType    #116:#58;// println:(Ljava/lang/String;)V
const #87 = NameAndType    #117:#118;//  sleep:(J)V
const #88 = Asciz    java/lang/InterruptedException;
const #89 = NameAndType    #119:#61;//  printStackTrace:()V
const #90 = Asciz    .myLongMethod : I will sleep for 1s;
const #91 = Asciz    java/util/HashMap;
const #92 = Asciz    .myStressingMethod :  limit=;
const #93 = NameAndType #112:#120;// append:(I)Ljava/lang/StringBuilder;
const #94 = Asciz    java/lang/Integer;
const #95 = NameAndType    #59:#65;//  "<init>":(I)V
const #96 = NameAndType #121:#122;// put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
const #97 = NameAndType    #123:#61;//  clear:()V
const #98 = NameAndType    #62:#61;//  myShortMethod:()V
const #99 = NameAndType    #64:#65;//  myStressingMethod:(I)V
const #100 = NameAndType    #63:#61;//  myLongMethod:()V
const #101 = NameAndType    #124:#125;// parseInt:(Ljava/lang/String;)I
const #102 = Asciz    jlp/aspectj/test/TestingClass;
const #103 = Asciz    thread_;
const #104 = NameAndType    #59:#60;// "<init>":(Ljava/lang/String;I)V
const #105 = NameAndType    #126:#61;//  start:()V
const #106 = Asciz    java/lang/Object;
const #107 = Asciz    java/lang/Runnable;
const #108 = Asciz    (Ljava/lang/Runnable;)V;
const #109 = Asciz    java/lang/System;
const #110 = Asciz    out;
const #111 = Asciz    Ljava/io/PrintStream;;
const #112 = Asciz    append;
const #113 = Asciz (Ljava/lang/String;)Ljava/lang/StringBuilder;;
const #114 = Asciz    toString;
const #115 = Asciz    java/io/PrintStream;
const #116 = Asciz    println;
const #117 = Asciz    sleep;
const #118 = Asciz    (J)V;
const #119 = Asciz    printStackTrace;
const #120 = Asciz    (I)Ljava/lang/StringBuilder;;
const #121 = Asciz    put;
const #122 = Asciz (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;;
const #123 = Asciz    clear;
const #124 = Asciz    parseInt;
const #125 = Asciz    (Ljava/lang/String;)I;
const #126 = Asciz    start;


Le 28/12/2012 02:54, Andy Clement a écrit :
Hi,

Can you confirm if the code you are load time weaving into has line number table entries? Use javap with -verbose to see them if they are there, look for one attached to each method. If they are missing that explains it, if they are not missing it seems like a bug.

cheers,
Andy


On 24 December 2012 07:37, Pasturel <[email protected] <mailto:[email protected]>> wrote:

    Le 24/12/2012 16:04, Pasturel a écrit :
    Le 24/12/2012 12:25, Pasturel a écrit :
    Hi,
    withAspectJ Compiler 1.7.1 (DEVELOPMENT - Built: Wednesday Oct
    24, 2012 at 18:06:22 GMT) and LTW,
    the call
    thisJoinPoint.getStaticPart().getSourceLocation().getLine()
    always returns 0

    My advice is an around advice. I test if( null !=
    thisJoinPoint.getStaticPart().getSourceLocation())
    The pointcut is correctly weaved, and the advice excecutes
    correctly ( except for retrieving the noLine)

    How can we explain this? a bug ?
    I  give below the code to test ( my tests give always a
    getLine() =0)  :

    The Class :

    package jlp.aspectj.test;

    import java.util.HashMap;
    public class TestingClass implements Runnable {
        private String name = "";
        public boolean running = true;
        private int limit = 1000000;
        Thread thread = new Thread(this);

        public String getName() {
            return name;
        }

        public void setName(String name) {
    this.name <http://this.name> = name;

        }

        public TestingClass(String name, int limit) {
    this.name <http://this.name> = name;
            this.limit = limit;
        }

        public TestingClass(String name) {
    this.name <http://this.name> = name;
        }

        public TestingClass() {
            this("no_name");

        }

        public void myShortMethod() {
            System.out.println("I will sleep for 100 ms");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public void myLongMethod() {
            System.out.println("I will sleep for 1s");
            try {

                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

        public void myStressingMethod(int limit) {
            HashMap<String, Integer> hm = new HashMap<String,
    Integer>();
            System.out.println("Entering in myStressingMethod
    limit=" + limit);
            for (int i = 0; i < limit; i++) {
                hm.put(new Integer(i % 100).toString(), new
    Integer(i % 1000));
            }
            hm.clear();

        }

        public void run() {
            while (running) {

                myShortMethod();

                myStressingMethod(limit);
                myLongMethod();
            }
        }

        public static void main(String[] args) {
            // TODO Auto-generated method stub
            TestingClass[] tabRunners = new
    TestingClass[Integer.parseInt(args[0])];
            for (int i = 0; i < tabRunners.length; i++) {
                tabRunners[i] = new TestingClass("thread_" + i,
    Integer.parseInt(args[1]));
                tabRunners[i].thread.start();
            }
        }

    }

    The AspectJ to (LTW) weave :

    package jlp.perf.aspects.concreteAspects;

    public aspect ConcreteTester {
        public  pointcut methods():execution(public * *..*.*(..));
        Object around() : methods()
        {
        Object ret = proceed();
        String str="Aspect ConcreteTester
    :"+thisJoinPointStaticPart.getSignature().getDeclaringTypeName()+"."+
    thisJoinPointStaticPart.getSignature().getName()+";"+thisJoinPointStaticPart
                .getSourceLocation().getLine();
        System.out.println(str);

        return ret;
        }

    }



    _______________________________________________
    aspectj-users mailing list
    [email protected]  <mailto:[email protected]>
    https://dev.eclipse.org/mailman/listinfo/aspectj-users
    but Compile Time Weaving makes the Aspect running correctly, as
    shown by the traces below :
    I will sleep for 1s
    Aspect ConcreteTester
    :jlp.aspectj.test.TestingClass.myShortMethod;*39*
    Entering in myStressingMethod limit=1000000
    Aspect ConcreteTester
    :jlp.aspectj.test.TestingClass.myStressingMethod*;61*

    I will sleep for 1s
    Aspect ConcreteTester :jlp.aspectj.test.TestingClass.myShortMethod;39
    Entering in myStressingMethod limit=1000000
    Aspect ConcreteTester
    :jlp.aspectj.test.TestingClass.myLongMethod;*49*

    I will sleep for 100 ms
    Aspect ConcreteTester
    :jlp.aspectj.test.TestingClass.myStressingMethod;61

    I will sleep for 1s
    Aspect ConcreteTester :jlp.aspectj.test.TestingClass.myShortMethod;39
    Entering in myStressingMethod limit=1000000
    Aspect ConcreteTester :jlp.aspectj.test.TestingClass.myLongMethod;49

    I will sleep for 100 ms
    Aspect ConcreteTester
    :jlp.aspectj.test.TestingClass.myStressingMethod;61

    I will sleep for 1s
    Aspect ConcreteTester
    :jlp.aspectj.test.TestingClass.myStressingMethod;61

    I will sleep for 1s
    Aspect ConcreteTester :jlp.aspectj.test.TestingClass.myShortMethod;39
    Entering in myStressingMethod limit=1000000
    Aspect ConcreteTester :jlp.aspectj.test.TestingClass.myShortMethod;39
    Entering in myStressingMethod limit=1000000
    Aspect ConcreteTester
    :jlp.aspectj.test.TestingClass.myStressingMethod;61

    I will sleep for 1s
    Aspect ConcreteTester
    :jlp.aspectj.test.TestingClass.myStressingMethod;61

    I will sleep for 1s


    _______________________________________________
    aspectj-users mailing list
    [email protected] <mailto:[email protected]>
    https://dev.eclipse.org/mailman/listinfo/aspectj-users




_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to