[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 Andy,

Apply that to the JVM classes:
ajc -inpath rt.jar StringUtils.java -outjar newrt.jar

Thanks very much, this shows that it is an eclipse AJDT only restriction and
not the AspectJ compiler.

The reason I am asking this sort of question is because JRuby(which also
supports this sort of Meta Programming in "open class" done it even at
script level to allow java class to access the new feature introduce to a
final class.)

Here is something that I do not understand. Why this is perfectly working
without error in eclipse plugin AJDT and NOT 

public aspect JavaLangSystemAspect {
     * Selects calls to System.currentTimeMillis() occurring within tested
    pointcut currentTimeMillis() :             
             call(public long System.currentTimeMillis());

    long around() : currentTimeMillis(){
        return 12345;

public class SystemUser

    public static void MillisUser(){
        // will show only 12345
    public static void main(String[] args)
        MillisUser(); // will show only 12345


I can't comment on  the legality of it, but I perhaps wouldn't advise
shipping a product that included a modified set of classes like this. 
This is strange, because the above around point cut is more dangerous than
to introduce new methods to a immutable objects.

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