[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to add methods to java.lang.String

Hi Henrique,

In other words, you're not instrumenting the supplier code by changing a
method or trying to access a private field. Because of that you do not need
to weave the java classes.

In summary, you aspect below is intercepting only the call to the method
"System.currentTimeMillis()" made within the static method MillisUser().
------------------------------
Ok. That makes some sense. The weaving is done on the user class instead of
the internal rt.jar. I am an aspectj user and not a developer of aspectj.
The compilation or weaving mechanism is not known to me. 

How come it is not done the same way like in the case of the StringUtils?

--------------------------------
public class StringRedefUser
{
    public static void main(String[] args)
    {
        String string="ABCDEFG";
        MyString mystring=new MyString();
        // This is allowed and has no compilation error.
        System.out.println("LTRIM:"+mystring.ltrim());  <<< The same weaving
can be done for non-existing method at the USER class level instead of the
rt.jar level.

        // This is NOT allowed because it is not expose to weaving.
        System.out.println("LTRIM:"+string.ltrim());
    }
} 
--------------------------------------
Could not that be also less dangerous and does not need the user to change
any of the bootclasspath and also the rt.jar? 

Yes. I am not incline to change the rt.jar and also bootclasspath for a
simple enhancement such as this.




--
View this message in context: http://aspectj.2085585.n4.nabble.com/How-to-add-methods-to-java-lang-String-tp4650376p4650385.html
Sent from the AspectJ - users mailing list archive at Nabble.com.