7

My understanding is that .. is 0-Many args and * is one arg of any name. Is this correct?

Does aspectj support syntax like args(..,myArg,..)?

Nishant
  • 54,584
  • 13
  • 112
  • 127
MikePatel
  • 2,593
  • 2
  • 24
  • 38

2 Answers2

11

This is from AspectJ site: http://www.eclipse.org/aspectj/doc/next/progguide/semantics-pointcuts.html

* represents any number of characters except "."

.. represents any number of characters including any number of "."

Update From AspectJ in Action - for method signatures:

In method signatures, the wildcard .. is used to denote any type and number of arguments taken by a method

* specifies a single argument

Biju Kunjummen
  • 49,138
  • 14
  • 112
  • 125
  • but also this : "If it is the "*" wildcard, then any argument will match, and if it is the special wildcard "..", then any number of arguments will match" – MikePatel Sep 06 '12 at 16:20
  • 1
    Yes, you are right, I have updated the answer accordingly for method signatures also. AspectJ does not support `(.., myarg, ..)`, not sure why though. – Biju Kunjummen Sep 06 '12 at 17:05
6

Others have answered part of the question before me, so I will only amend:

.., bla, .. does not work because if you bind parameter bla to a variable, there might be several matching combinations in case a matching type occurs multiple times in the parameter list. Example:

void foo(int a, String b, String c, File d)

Now what should happen if the advice is:

before(String bla) : call(void foo(.., bla, ..)) && args(bla)

Should bla be bound to the String value of b or c?

kriegaex
  • 63,017
  • 15
  • 111
  • 202