Bug 162844 - Allow args test for inexact type pattern when not binding
Summary: Allow args test for inexact type pattern when not binding
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-31 01:49 EST by Ron Bodkin CLA
Modified: 2006-10-31 01:49 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ron Bodkin CLA 2006-10-31 01:49:01 EST
I'd like to write a pointcut to match the first String argument in the first two positions, for an API where this is the best rule I can use (see also bug #160509, which is a more general request). Unfortunately this doesn't work:
    public pointcut firstString(String first) :
        args(first, ..) || args(!String, first, ..);

C:\devel\scratch\args\FirstArg.aj:3 [error] exact type pattern required
args(first, ..) || args(!String, first, ..);

Nor does this:
    public pointcut firstString(String first) :
        args(first, ..) || (!args(String, ..) && args(*, first, ..));
C:\devel\scratch\args\FirstArg.aj:3 [error] ambiguous binding of parameter(s) fi
rst across '||' in pointcut

Work-around: write advice on args(first, ..) and separate advice on !args(String, ..) && args(*, first, ..)
Comment 1 Ron Bodkin CLA 2006-10-31 01:49:35 EST
Sample program:

public aspect FirstArg {
    public pointcut firstString(String first) :
        args(first, ..) || (!args(String, ..) && args(*, first, ..));
    before(String first) : firstString(first) {
        System.out.println("At "+thisJoinPoint+", first is "+first);
    }
    public static void main(String argz[]) {
        one("test");
        two("more", "test");
        three("top", "more", "test");
    }
    static void one(String z) {}
    static void two(String y, String z) {}
    static void three(String x, String y, String z) {}
}