Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Help - Compilation works with 1.1 but fails w ith 1.2

Thanks. This solves my problem.
-----Original Message-----
From: Andrew Clement [mailto:CLEMAS@xxxxxxxxxx]
Sent: Friday, May 28, 2004 9:35 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Help - Compilation works with 1.1 but fails with 1.2


The fix for bug 61568 introduced this message.  There are certain
situations where you can get into trouble when binding multiple
times with args.  We decided it was better to fail at compile
time than in an unusual way at runtime - but we are looking at
possibly supporting this in future.  In your case, the use
of args is ...ok... but you trigger the error message.  
However , this program works:

class OverloadMethodTest {

   public void test(String one)            { }

   public void test(String one, int two)   { }

   public void test1(String one)           { }

   public void test1(String one, int two)  { }
}


aspect OverloadMethodAspect {

  public pointcut test() :
    execution(* OverloadMethodTest.test(String,..));

  public pointcut test1() :
    execution(* OverloadMethodTest.test1(String,..));

  public pointcut both(String strArg) :
    (test() || test1()) && args(strArg,..);

  before(String strArg) : both(strArg) {
    System.out.println("Before Calling method " +
      thisJoinPointStaticPart.getSignature().getName()
      + " strArg " + strArg);
  }
}

Can you still achieve what you need with this approach?

I know your next question will be, what if the arguments
you want to extract aren't always in the same position,
suppose you wanted the 2nd String argument from a
test2(String,String) method.  I think in that case
I would write a 2nd piece of advice - does that sound
reasonable?

Andy.




Kamal Govindraj <Kamal.Govindraj@xxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

28/05/2004 13:28

Please respond to
aspectj-users

To
"'aspectj-users@xxxxxxxxxxx'" <aspectj-users@xxxxxxxxxxx>
cc
Subject
[aspectj-users] Help - Compilation works with 1.1 but fails with  1.2





> Hi,
>
> This is the class I have defined.
> public class OverloadMethodTest
> {
>                  public void test(String one)                 {
>                  }
>                  public void test(String one, int two)                 {
>                  }
>                  public void test1(String one)                 {
>                  }
>                  public void test1(String one, int two)                 {
>                  }
> }
>
> This is the aspect that I want to weave with the above class.
>
> public aspect OverloadMethodAspect
> {
>                  public pointcut test(String strArg) :
>                                   execution(* OverloadMethodTest.test(String,..)) &&
> args(strArg,..);
>                  
>                  public pointcut test1(String strArg) :
>                                   execution(* OverloadMethodTest.test1(String,..)) &&
> args(strArg,..);
>
>                  public pointcut both(String strArg) : test(strArg)  ||
> test1(strArg);
>
>                  before(String strArg) : both(strArg) {
>                                   System.out.println("Before Calling method " +
> thisJoinPointStaticPart.getSignature().getName()
>                                                                                      + " strArg " + strArg);
>                  }
> }
>
> It works with the aspectj 1.1 version, but fails when compiled using
> aspectJ 1.2  with the following errors
>
> D:\work\TestAspects\OverloadMethodTest.java:9 error Ambiguous binding of
> type ja
> va.lang.String using args(..) at this line.  Use one args(..) per matched
> join p
> oint, see secondary source location for location of extraneous args(..)
> (no source information available)
>
>         see also: D:\work\TestAspects\OverloadMethodAspect.aj:7
>         see also: D:\work\TestAspects\OverloadMethodTest.jar
> D:\work\TestAspects\OverloadMethodTest.java:11 error Ambiguous binding of
> type j
> ava.lang.String using args(..) at this line.  Use one args(..) per matched
> join
> point, see secondary source location for location of extraneous args(..)
> (no source information available)
>
>         see also: D:\work\TestAspects\OverloadMethodAspect.aj:7
>         see also: D:\work\TestAspects\OverloadMethodTest.jar
> D:\work\TestAspects\OverloadMethodTest.java:5 error Ambiguous binding of
> type ja
> va.lang.String using args(..) at this line.  Use one args(..) per matched
> join p
> oint, see secondary source location for location of extraneous args(..)
> (no source information available)
>
>         see also: D:\work\TestAspects\OverloadMethodAspect.aj:7
>         see also: D:\work\TestAspects\OverloadMethodTest.jar
> D:\work\TestAspects\OverloadMethodTest.java:7 error Ambiguous binding of
> type ja
> va.lang.String using args(..) at this line.  Use one args(..) per matched
> join p
> oint, see secondary source location for location of extraneous args(..)
> (no source information available)
>
>         see also: D:\work\TestAspects\OverloadMethodAspect.aj:7
>         see also: D:\work\TestAspects\OverloadMethodTest.jar
>
> 4 errors
>
> Is there something wrong with the aspect I have defined? How do I get this
> to work using aspectJ 1.2.
> I have attached the source files.
>
> Java Version - Sun jdk1.3.08
> AspectJ version - (AspectJ Compiler 1.2 built on Friday May 21, 2004 at
> 15:06:22 GMT)
>
> Thanks
> Kamal
>
>  <<OverloadMethodAspect.aj>>  <<OverloadMethodTest.java>>


Back to the top