What do .. and * mean in aspectj

为君一笑 提交于 2019-12-22 05:18:06

问题


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,..)?


回答1:


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




回答2:


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?



来源:https://stackoverflow.com/questions/12303142/what-do-and-mean-in-aspectj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!