Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] inner method calls


Hi Evert,

If I follow the scenario laid out in your note I am unable to recreate the problem you describe. If I compile and run the below simple class and aspect ...


public class A {

  public static void main(String[] args) {
    System.out.println("main method calling static method start...");
    start();
  }

  public static void start() {
    System.out.println("static method start here");

    System.out.println("start calling static methodA...");
    methodA();


    System.out.println("start calling static methodB...");
    methodB();
  }


  public static void methodA() {
    System.out.println("static method A here");
  }

  public static void methodB() {
    System.out.println("static method B here");
  }
}// end of class A



aspect TestAspect
{
  pointcut pe(): call(static * A.*(..));
                 
  before() : pe()
  {
    System.out.println("PE !!!!!!");
  }
}// end of TestAspect


... then the following console output is seen ...

main method calling static method start...
PE !!!!!!
static method start here
start calling static methodA...
PE !!!!!!
static method A here
start calling static methodB...
PE !!!!!!
static method B here

The advice text is written on the call to the start() method from main() and similarly the advice text gets written out again each time there is a call from start() to another of the static methods in class A.

Does this simple case adequately reflect your set up or have I misunderstood your note ? Also, could you let us know what version of AspectJ you are working with and what compiler options you are using.

Best regards,
George

PS, For future reference, this kind of question should really be posed on the aspectj-users list.
________________________________________
George C. Harley



Evert <evert@xxxxxxxxxx>
Sent by: aspectj-dev-admin@xxxxxxxxxxx

30/08/2004 21:34

Please respond to
aspectj-dev

To
aspectj-dev@xxxxxxxxxxx
cc
Subject
[aspectj-dev] inner method calls





Hi all,

I am new to AspectJ and I have an question about it.
I got an aspect like

public aspect TestAspect
{
                pointcut pe(): call(static * sourceforge.gpe.engine.PluginEngine.*(..));
               
                before() : pe()
                {
                                 System.out.println("PE !!!!!!");
                }

}

The class PluginEngine contains some static methods
like start(java.util.List) loadPlugin(URL url) and shutdown().

When I call from a class PluginEngine.start() the text is printed to the
console, also when I call another method on PluginEngine.
The start method calls other static methods in PluginEngine.
when the method start called text is printed out to the console before
the start method is entered but noting no text is printed out before
other methods are entered that are called by the start method.

What I am doing wrong ?

Best regards,
Evert
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev


Back to the top