Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] reflective calls

I have been asked what is the "AspectJ answer" to "how to match
reflective calls" such as with:

call(* *.doA())

public void invokeA(Object instance) throws Throwable {
  Method mA = instance.getClass().getDeclaredMethod("doA", new Class[0]);
  mA.invoke(instance, new Object[0]); // NO MATCH
}


I don't find a correct answer to that.
I don't like the way JBossAOP does it for scalabilty reasons (though
it is a good answer) - ie in short intercept all reflect calls, and
deals with some runtime matching and reflective advice invocation when
the reflective call has to be matched (possible with an underlying
aop.xml repository as where we are heading in AspectJ 5 load time
weaving) (in JBoss this is an optional aspect - hence you may change
the semantics if you have it or not).

We could off course provide that but that sounds like a wrong answer
to an important question.
The answer might be a best practice around "use execution instead -
possibly with control flow" but that 's like avoiding the question and
implictly say. We don't because we can't.

What are your thoughts about that ? What have been the decisions
behind (the situation is roughly the same with old source level
weaving since "doA" string may be a variable etc) ?

Alex


Back to the top