Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Proper behavior of overloaded pointcut definitions

What is considered to be the proper behavior of overloaded pointcut definitions? For example, the following program compiles with no warnings, produces no output when run under AspectJ 1.1.1.  It appears to behave as if the more specific definition is the only definition of the pointcut.

Here is a simple program that illustrates the question and odd behavior:

package lib;

public class RunnablePointcuts {
    public pointcut runnableCalls(Runnable runnable, Object caller) :
        call(* run(..)) && target(runnable) && this(caller);

    //public pointcut specialRunnableCalls(SpecialRunnable runnable, Object caller) :
    public pointcut runnableCalls(SpecialRunnable runnable, Object caller) :
        call(* run(..)) && target(runnable) && this(caller);
}
---
package lib;

public interface SpecialRunnable extends Runnable {
}
---
package client;

import lib.RunnablePointcuts;
import lib.SpecialRunnable;

public aspect Use {
    before(Object caller) : RunnablePointcuts.runnableCalls(*, caller) && target(MyRunnable) {
        System.out.println("my runnable called from "+caller);
    }
    public static void main(String args[]) {
	Use.aspectOf().doIt();
    }
    public void doIt() {
        new MyRunnable().run();
    }
}

// the advice will run if you make this implement SpecialRunnable
//class MyRunnable implements SpecialRunnable {
class MyRunnable implements Runnable {
    public void run() {}
}


...

I ask this because I ran into a bug when compiling client code like this that gives these errors when using a jar on the aspectpath, whereas if you include the source in the project it works fine. E.g.,

compile:
     [iajc] C:\eclipse\workspace\atrack\src\server\org\atrack\ui\error\TestBug.j
ava:30 incompatible type, expected javax.servlet.ServletRequest found BindingTyp
ePattern(javax.servlet.http.HttpServletRequest, 2)
     [iajc] C:\eclipse\workspace\atrack\src\server\org\atrack\ui\error\TestBug.j
ava:30 can't find referenced pointcut

I think the answer is to make overloaded PCD's an error. Also, please let me know if it's worth my trying to isolate this bug in a reproducable test case.

Ron

Ron Bodkin
Chief Technology Officer
New Aspects of Security
m: (415) 509-2895


Back to the top