Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] LTW into javax.swing

Hi,

Take a look at:
http://andrewclement.blogspot.com/2009/02/load-time-weaving-basics.html
and try some of the debug/verbose options there - that will tell you
whether the classloader is able to pass the types you are interested
to a weaver.  If they cannot be passed to a weaver they will never be
woven, regardless of options or pointcuts.  Can you use compile time
weaving? That would definetly work.

Andy

2009/9/25 Kajetan Abt <kdansky@xxxxxxxxx>:
> That did not work, I get an identical behaviour. Still, thanks for finding a
> bug.
>
> 2009/9/25 <jeanlouis.pasturel@xxxxxxxxxxxxxxxxxx>
>>
>> I have made the same error few months ago. You have to set only one Xset
>> like :
>>
>> -Xset:weaveJavaxPackages=true,weaveJavaPackages=true
>>
>>
>>
>>
>>
>> Jean-Louis Pasturel
>>
>>
>>
>> ________________________________
>>
>> De : aspectj-users-bounces@xxxxxxxxxxx
>> [mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de Kajetan Abt
>> Envoyé : vendredi 25 septembre 2009 14:14
>> À : aspectj-users@xxxxxxxxxxx
>> Objet : [aspectj-users] LTW into javax.swing
>>
>>
>>
>> What I am trying to do: Swing has support for Tooltips, but that
>> functionality is very basic. There are two functions (SetToolTip() and
>> GetToolTip()) which either take a String argument or return one. I would
>> like to have different Tooltips, to be precise, different verbosity levels,
>> for all tooltips in my project. Of course I could either overload all used
>> JComponents (hah!) or use some other nontrivial approach (manage my own
>> listeners...) to set these values anew every time the user changes the
>> verbosity level.
>>
>> But on the other hand, having an Aspect weave into GetToolTip() would
>> instantly solve my issues, as I could then change the return parameter (read
>> from a properties file). I have managed to figure out how to basically do
>> this, and it works, as long as I am weaving into my own code (I suppose it
>> would work at compile time even). But for some reason, weaving into Swing
>> fails without error messages, it just does not happen. I assume the class
>> loader has my classes prepared before the weaver kicks in, but I have
>> absolutely no idea how to do that different. There is also not a lot of
>> literature on the subject and I only assume this happens because I've read
>> somewhere that writing a classloader might be necessary (without explanation
>> as to why or how). I am settnig the option to the weaver to include javax,
>> but it won't find JComponent. If I don't exclude the org.jdesktop package,
>> it even tries to find the superclasses of some of the jdesktop parts at
>> javax.jnlp.*, so it doesn't completely fail.
>> As for the call I want to intercept: javax.swing.ToolTipManager is the
>> class that calls my target function. It never gets woven.
>>
>> As for the code I use:
>>
>> aop.xml:
>>          <aspectj>
>>             <aspects>
>>               <aspect name="<something>.weaver.
>>
>> Wrangler"/>
>>                <include within="<something>..*"/>
>>                <include within="javax.swing..*"/>
>>                <exclude within="org.jdesktop..*"/>
>>             </aspects>
>>             <weaver options="-verbose -Xset:weaveJavaxPackages=true
>> -Xset:weaveJavaPackages=true -showWeaveInfo" >
>>                <include within="<something>..*"/>
>>                <include within="javax.swing..*"/>
>>                <exclude within="org.jdesktop..*"/>
>>             </weaver>
>>           </aspectj>
>>
>> public aspect Wrangler {
>>     before(JComponent component):
>>         call( public String JComponent.getToolTipText(MouseEvent) )
>>         && target(component)
>>         {
>>             System.out.println("Intercepted!");
>>             //target.setToolTip("My new thing");
>>         }
>> }
>>
>> The output I get:
>> [AppClassLoader@19134f4] weaveinfo Join point
>> 'method-call(java.lang.String javax.swing.JMenuItem.getToolTipText())' in
>> Type <something>.gui.AppClientView' (AppClientView.java:596) advised by
>> before advice from '<something>.weaver.Wrangler' (Wrangler.aj:33)
>>
>> And all other calls I make myself. Changing this to execution or anything
>> like that does not help at all. No Javax.Swing classes are woven at all.
>>
>> *********************************
>> This message and any attachments (the "message") are confidential and
>> intended solely for the addressees.
>> Any unauthorised use or dissemination is prohibited.
>> Messages are susceptible to alteration.
>> France Telecom Group shall not be liable for the message if altered,
>> changed or falsified.
>> If you are not the intended addressee of this message, please cancel it
>> immediately and inform the sender.
>> ********************************
>>
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top