[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Addressing classes that arent being compiled
|
Hello,
Thank you for your reply. I had tried this, however without the '+', as
this is new to me (as I understand this means also for any subclass). It
matches fine when I use:
pointcut textFieldInit () :
call(JTextField+.new(..));
after () returning : textFieldInit()
{
System.out.println("TextFieldInit!");
}
This matches fine, but I cannot relate to the instance of JTextField.
Due to the nature of my experimenting I would like to get hold of the
actual instance of the JTextField after it has been initialised, so I
figured to use the following:
pointcut textFieldInit (JTextField textField) :
call(JTextField+.new(..)) && target(textField);
after (JTextField textField) returning : textFieldInit(textField)
{
System.out.println("TextFieldInit!" + textField);
}
Now this does not match very well as I receive the following error:
D:\..\userinterface\TestAspect.aj:22 [warning] advice defined in
userinterface.TestAspect has not been applied [Xlint:adviceDidNotMatch]
after (JTextField textField) returning : textFieldInit(textField)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
So something is going wrong there :-(, what am I doing wrong? Or am I
trying to do something that isn't that natural? (I am making new
instances of JTextField obviously in my program...)
Cheers,
Mark
You /can/ pass compiled .class files into the AspectJ weaver using the
-inpath option, but you probably don't want to be weaving rt.jar. Changing
your aspect slightly to:
pointcut textFieldInit() : call(JTextField+.new(..));
after () returning(JTextField textField) : textFieldInit()
{
System.out.println("TextFieldInit!" + textField);
}
should give you want you want. The "call" pointcut matches join points on
the calling side, which is where you are...