Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Using AspectJ for internationalization

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
this:
 
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
jvms...


- Bo

________________________________

From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Arjun Singh
Sent: Friday, December 15, 2006 12:16 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Using AspectJ for internationalization


Hi,

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.

Arjun






Back to the top