Re: [aspectj-users] How to add methods to java.lang.String

2012-06-13 Thread MattOng
Thanks Andy. -- View this message in context: http://aspectj.2085585.n4.nabble.com/How-to-add-methods-to-java-lang-String-tp4650376p4650390.html Sent from the AspectJ - users mailing list archive at Nabble.com. ___ aspectj-users mailing list aspectj-use

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-11 Thread Andy Clement
Hi, The bugzilla for bugs/enhancement requests is here: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ > JRuby(highly dynamic scripting language) allows to do such meta programming > with ease. To me this kind of task is more suitable for a dynamic language (which allow calling thi

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-09 Thread MattOng
Hi Henrique, Anyway to suggest the changes in the weaving process to the AspectJ Deverloper and where do I go for such a feature change request? Any bugzilla(not that it is a bug), but to enhance the user experience of AspectJ? This is what I would also suggest, just like in the case of call poin

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-09 Thread Henrique RebĂȘlo
Hi MattOng, How come it is not done the same way like in the case of the StringUtils? Based on the same discussion, you used an ITD (inter-type declaration of AspectJ). By doing that you need to expose the target type (String in this case) to the weaver since you do not control the source code.

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-09 Thread MattOng
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 w

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-08 Thread Henrique RebĂȘlo
Hi MattOng, Please take a time to understand the semantics of call and execution pointcuts in AspectJ. The latter one instruments the supplier code. Hence, when you used the call pointcut, you interceped only the "calls" in your app code. In other words, you're not instrumenting the supplier code

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-08 Thread MattOng
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

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-08 Thread Andy Clement
There are certain limitations and restrictions when modifying the system classes. Here is what works: Your aspect: public privileged aspect StringUtils { public String String.ltrim() { return "test ltrim"; } } Apply that to the JVM classes: ajc -inpath rt.jar StringUtils.java -outjar

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-08 Thread Hemal Pandya
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

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-07 Thread MattOng
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 Rede

Re: [aspectj-users] How to add methods to java.lang.String

2012-06-07 Thread MattOng
Correction to the code posted earlier. public class Point{} -- Should be: public final class Point{} -- View this message in context: http://aspectj.2085585.n4.nabble.com/How-to-add-methods-to-java-lang-String-tp4650376p4650377.html Sent from the AspectJ - us

[aspectj-users] How to add methods to java.lang.String

2012-06-07 Thread MattOng
>From what I can see in sample code: public class Point{} public aspect Point { // a new method is introduced into the Point Class. public String Point.toLongString(){ return "### FROM ASPECT ###"; } } public class Main{ public static void main(String[] args){ Point p