Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] bsh assignment not trigger set pointcut

John M. Adams wrote:
> > Is the problem here that the code that beanshell generates and compiles
> > isn't passed through ajc, so that join points in that code aren't
> > available to advice?
> 
> Certainly, the assignment statement I typed into BeanShell was not
> passed through ajc.  Maybe that explains it.  I don't know what
> assignment means in terms of Java bytecode.  And how AspectJ would
> relate to it.

BeanShell (as well as Jython and most other scripting languages for Java)
uses reflection for accessing fields and calling methods on Java objects.
AspectJ can't modify these reflective accesses to properly expose them to
advice.

The solution to this is to write an aspect-aware wrapper around
java.lang.reflect and then to modify all of the Java scripting languages to
use this instead of the standard reflection APIs.  Probably the best way to
modify the scripting languages would be to use around advice on calls to
java.lang.reflect to delegate to this new library.  This is a non-trivial
project but would be a very nice contribution if someone was feeling
ambitious.

-Jim




Back to the top