[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [aspectj-users] Using AspectJ for internationalization
- From: "Bo Zimmerman" <bo.zimmerman@xxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Dec 2006 13:46:26 -0600
- Delivered-to: email@example.com
- Thread-index: AccgdTcJ3w6Og0sETfO4vLJLISLSaAACmz6Q
Thank you Arjun,
Sometimes knowing any something doesn't work can turn into the key to making
it go. You are correct that I neglected to mention many details, despite
the long post: I tried both execution and call.
BTW, with StringBuffers, things look great. For instance, on code like
String s1="a string";
System.out.println("blah "+s1+" bloo");
.. I get advice calls on the creation of the string "blah " as a
StringBuffer, a subsequent call to StringBuffer.append for the +s1 part, and
a final call to append for the +" bloo" part. Great stuff!
However, String s1="a string", and the initialization of "blah " and " bloo"
respectively elude my probing pointcutting tools, probably for the reasons
you mention. I'll keep looking into this though -- I'm wanting to do
load-time weaving, so there would be no danger to unaffecteded rt.jars or
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Arjun Singh
Sent: Friday, December 15, 2006 12:16 PM
Subject: Re: [aspectj-users] Using AspectJ for internationalization
It sounds like you tried an advice that uses execution(String.new(..)). I'm
not entirely sure, but I believe the reason this is not working for you is
because this method does not exist in your project (it is defined in Java's
rt.jar), meaning the compiler will not deal with it when weaving occurs.
Note however that an advice that uses call(String.new(..)) will be woven
properly, but only for string constructions of the form String str = new
String(...), and not for String str = "..." (since this doesn't directly use
the new method).
There is a way to expose the rt.jar to the weaving process such that using
and advice with execution(String.new(..)) would work, but doing so seems
like a bad idea because modifying the rt.jar would modify the way all java
projects run on your system, not just this project you are working on.
So I'm not sure what the best approach would be to advice statements such as
String str = "...", but I hope this helped you understand why your attempts
have not worked so far.