It is not easy to weave the classes in JDK and it may not be legal. With a quick search I can only find http://aspectj.2085585.n4.nabble.com/IDT-in-JDK-classes-How-to-enable-java-weaving-tc2086437.html#none. Please check list archives and docs for details.
On Thu, Jun 7, 2012 at 11:53 PM, MattOng <on...@yahoo.com> wrote: > public final class MyString{} > > public privileged aspect StringRedef{ > private interface Redef{} > > // allowed *even* if MyString is *final*. > declare parents: (MyString) implements Redef; > *// NOT allowed even String is also final.* > declare parents: (java.lang.String) implements Redef; > > public String Redef.ltrim(){ > return "#LTRIMED"; > } > } > > 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()); > // This is NOT allowed because it is not expose to weaving. > System.out.println("LTRIM:"+string.ltrim()); > } > } > ====================================== > > How to expose java.lang/javax.lang or any classes to weaving? > > > > -- > View this message in context: > http://aspectj.2085585.n4.nabble.com/How-to-add-methods-to-java-lang-String-tp4650376p4650378.html > Sent from the AspectJ - users mailing list archive at Nabble.com. > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > https://dev.eclipse.org/mailman/listinfo/aspectj-users _______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users