|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
can arg names be accessed at a joinpoint?I am using a tracing aspect and it is printing the method arg values upon entry, but without arg names: trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: com.AjlibTest.DummyObject@18941f7, args: arg 0 = 5 using joinPoint.getArgs() - I can see in the debugger that the arg names are not in the joinpoint - is there a way an aspect can capture that info? 10911 Watchful Fox Drive Austin, TX 78748 512 280-1753 Home 512 634-5148 Office 512 659-5300 Cell _______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
Re: can arg names be accessed at a joinpoint?You get get the associated CodeSignature object as follows:
CodeSignature codeSignature = (CodedSignature) thisJoinPoint.getSignature(); String[] argNames = codeSignature.getParameterNames(); -Ramnivas On Wed, Nov 12, 2008 at 10:48 PM, Owen Corpening <owencorpening@...> wrote:
_______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
Re: can arg names be accessed at a joinpoint?But this will give the argument names as saved in .class file, normally arg0, arg1 etc.
not the original names as in source code. Is there any way to get original names as specified in source code?
|
|
|
Re: can arg names be accessed at a joinpoint?If you compile your code using ajc or javac with -g (for binary weaving purpose), you will get the original argument names.
-Ramnivas
On Fri, Nov 14, 2008 at 8:19 AM, rmahmood <rashid_m180@...> wrote:
_______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
Re: can arg names be accessed at a joinpoint?I not only compile with -g, I am running within the eclipse debugger and I still get "arg 0". Plus doesn't thisJoinPoint.getArgs() do the same thing? Seems to, sorry I didn't read the aspectj src to confirm, I am downloading that today. if (joinPoint.getArgs() != null && joinPoint.getArgs().length>0) { Object getargs[] = joinPoint.getArgs();
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); String[] argNames = codeSignature.getParameterNames(); logStr.append(", args using CodeSignature: "+arguments(argNames)); logStr.append(", args using getArgs: "+arguments(argNames)); } return logStr.toString(); } protected String arguments(Object[] arguments) { StringBuffer logStr = new StringBuffer(); for (int i = 0; i < arguments.length; i++) { logStr.append((i>0 ? ", ":"")+ "arg "+i+" = "+traceString(arguments[i])); } return logStr.toString(); } console output: INFO com.AjlibTest.DummyObject - trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: com.AjlibTest.DummyObject@152544e, args using CodeSignature: arg 0 = i, args using getArgs: arg 0 = i -3 [main] owen Ramnivas Laddad wrote: If you compile your code using ajc or javac with -g (for binary weaving purpose), you will get the original argument names. -Ramnivas
On Fri, Nov 14, 2008 at 8:19 AM, rmahmood <rashid_m180@...> wrote:
_______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
Re: can arg names be accessed at a joinpoint?Lord have mercy, ever wish you could take back a posting? I corrected my code, same results, the two lines below should have read: logStr.append(", args using CodeSignature: "+arguments(argNames)); logStr.append(", args using getArgs: "+arguments(getargs)); output is same darnit all owen From: Owen Corpening <owencorpening@...> To: aspectj-users@... Sent: Saturday, November 15, 2008 2:00:05 PM Subject: Re: [aspectj-users] can arg names be accessed at a joinpoint? I not only compile with -g, I am running within the eclipse debugger and I still get "arg 0". Plus doesn't thisJoinPoint.getArgs() do the same thing? Seems to, sorry I didn't read the aspectj src to confirm, I am downloading that today. if (joinPoint.getArgs() != null && joinPoint.getArgs().length>0) { Object getargs[] = joinPoint.getArgs();
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); String[] argNames = codeSignature.getParameterNames(); logStr.append(", args using CodeSignature: "+arguments(argNames)); logStr.append(", args using getArgs: "+arguments(argNames)); } return logStr.toString(); } protected String arguments(Object[] arguments) { StringBuffer logStr = new StringBuffer(); for (int i = 0; i < arguments.length; i++) { logStr.append((i>0 ? ", ":"")+ "arg "+i+" = "+traceString(arguments[i])); } return logStr.toString(); } console output: INFO com.AjlibTest.DummyObject - trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: com.AjlibTest.DummyObject@152544e, args using CodeSignature: arg 0 = i, args using getArgs: arg 0 = i -3 [main] owen Ramnivas Laddad
wrote: If you compile your code using ajc or javac with -g (for binary weaving purpose), you will get the original argument names. -Ramnivas
On Fri, Nov 14, 2008 at 8:19 AM, rmahmood <rashid_m180@...> wrote:
_______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
Re: can arg names be accessed at a joinpoint?It seems that it is all working correctly. Does your method is
declared as someMethod(int i)? Is so, the output seems to correctly print "i". You are getting "arg 0" part because you are printing "arg "+i. Right? -Ramnivas On Sat, Nov 15, 2008 at 3:26 PM, Owen Corpening <owencorpening@...> wrote: > > Lord have mercy, ever wish you could take back a posting? I corrected my code, same results, the two lines below should have read: > logStr.append(", args using CodeSignature: "+arguments(argNames)); > logStr.append(", args using getArgs: "+arguments(getargs)); > output is same > darnit all > owen > ________________________________ > From: Owen Corpening <owencorpening@...> > To: aspectj-users@... > Sent: Saturday, November 15, 2008 2:00:05 PM > Subject: Re: [aspectj-users] can arg names be accessed at a joinpoint? > > I not only compile with -g, I am running within the eclipse debugger and I still get "arg 0". > Plus doesn't thisJoinPoint.getArgs() do the same thing? Seems to, sorry I didn't read the aspectj src to confirm, I am downloading that today. > if (joinPoint.getArgs() != null && joinPoint.getArgs().length>0) { > Object getargs[] = joinPoint.getArgs(); > CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); > String[] argNames = codeSignature.getParameterNames(); > logStr.append(", args using CodeSignature: "+arguments(argNames)); > logStr.append(", args using getArgs: "+arguments(argNames)); > } > return logStr.toString(); > } > protected String arguments(Object[] arguments) { > StringBuffer logStr = new StringBuffer(); > for (int i = 0; i < arguments.length; i++) { > logStr.append((i>0 ? ", ":"")+ "arg "+i+" = "+traceString(arguments[i])); > } > return logStr.toString(); > } > console output: > INFO com.AjlibTest.DummyObject - trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: com.AjlibTest.DummyObject@152544e, args using CodeSignature: arg 0 = i, args using getArgs: arg 0 = i > -3 [main] > owen > Ramnivas Laddad wrote: > If you compile your code using ajc or javac with -g (for binary weaving purpose), you will get the original argument names. > -Ramnivas > > On Fri, Nov 14, 2008 at 8:19 AM, rmahmood <rashid_m180@...> wrote: >> >> But this will give the argument names as saved in .class file, normally arg0, >> arg1 etc. >> not the original names as in source code. >> >> Is there any way to get original names as specified in source code? >> >> >> Ramnivas Laddad wrote: >> > >> > You get get the associated CodeSignature object as follows: >> > CodeSignature codeSignature = (CodedSignature) >> > thisJoinPoint.getSignature(); >> > String[] argNames = codeSignature.getParameterNames(); >> > >> > -Ramnivas >> > >> > On Wed, Nov 12, 2008 at 10:48 PM, Owen Corpening >> > <owencorpening@...>wrote: >> > >> >> I am using a tracing aspect and it is printing the method arg values upon >> >> entry, but without arg names: >> >> trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: >> >> com.AjlibTest.DummyObject@18941f7, args: arg 0 = 5 >> >> >> >> using joinPoint.getArgs() - I can see in the debugger that the arg names >> >> are not in the joinpoint - is there a way an aspect can capture that >> >> info? >> >> >> >> Owen Corpening >> >> 10911 Watchful Fox Drive >> >> Austin, TX 78748 >> >> >> >> 512 280-1753 Home >> >> 512 634-5148 Office >> >> 512 659-5300 Cell >> >> >> >> >> >> _______________________________________________ >> >> aspectj-users mailing list >> >> aspectj-users@... >> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> >> >> >> >> > >> > _______________________________________________ >> > aspectj-users mailing list >> > aspectj-users@... >> > https://dev.eclipse.org/mailman/listinfo/aspectj-users >> > >> > >> >> -- >> View this message in context: http://www.nabble.com/can-arg-names-be-accessed-at-a-joinpoint--tp20474387p20500385.html >> Sent from the AspectJ - users mailing list archive at Nabble.com. >> >> _______________________________________________ >> aspectj-users mailing list >> aspectj-users@... >> https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > > _______________________________________________ > aspectj-users mailing list > aspectj-users@... > https://dev.eclipse.org/mailman/listinfo/aspectj-users > aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
|
|
Re: can arg names be accessed at a joinpoint?Aiieee thanks! the old "can't see my own handwriting" trick! Now calls to DummyObject.someMethod: public class DummyObject { public int someMethod(int i, int my2ndarg) log like this: -7 [main] INFO com.AjlibTest.DummyObject - trace enter: int com.AjlibTest.DummyObject.someMethod(int, int) , this: com.AjlibTest.DummyObject@152544e, args: i = 5, my2ndarg = 9 with this adjustment to the logging aspect: Object
arguments[] = joinPoint.getArgs(); CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); String[] argNames = codeSignature.getParameterNames(); logStr.append(", args: "+arguments(argNames, arguments)); } return logStr.toString(); }
protected String arguments(String[] argNames, Object[] arguments) { StringBuffer logStr = new StringBuffer(); for (int i = 0; i < arguments.length; i++) { logStr.append((i>0 ? ", ":"")+ argNames[i] + " = " + traceString(arguments[i])); } return logStr.toString(); } much thanks, owen From: Ramnivas Laddad <ramnivas@...> To: aspectj-users@... Sent: Saturday, November 15, 2008 2:42:55 PM Subject: Re: [aspectj-users] can arg names be accessed at a joinpoint? It seems that it is all working correctly. Does your method is declared as someMethod(int i)? Is so, the output seems to correctly print "i". You are getting "arg 0" part because you are printing "arg "+i. Right? -Ramnivas On Sat, Nov 15, 2008 at 3:26 PM, Owen Corpening <owencorpening@...> wrote: > > Lord have mercy, ever wish you could take back a posting? I corrected my code, same results, the two lines below should have read: > logStr.append(", args using CodeSignature: "+arguments(argNames)); > logStr.append(", args using getArgs: "+arguments(getargs)); > output is same > darnit all > owen > ________________________________ > From: Owen Corpening <owencorpening@...> > To: aspectj-users@... > Sent: Saturday, November 15, 2008 2:00:05 PM > Subject: Re: [aspectj-users] can arg names be accessed at a joinpoint? > > I not only compile with -g, I am running within the eclipse debugger and I still get "arg 0". > Plus doesn't thisJoinPoint.getArgs() do the same thing? Seems to, sorry I didn't read the aspectj src to confirm, I am downloading that today. > if (joinPoint.getArgs() != null && joinPoint.getArgs().length>0) { > Object getargs[] = joinPoint.getArgs(); > CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); > String[] argNames = codeSignature.getParameterNames(); > logStr.append(", args using CodeSignature: "+arguments(argNames)); > logStr.append(", args using getArgs: "+arguments(argNames)); > } > return logStr.toString(); > } > protected String arguments(Object[] arguments) { > StringBuffer logStr = new StringBuffer(); > for (int i = 0; i < arguments.length; i++) { > logStr.append((i>0 ? ", ":"")+ "arg "+i+" = "+traceString(arguments[i])); > } > return logStr.toString(); > } > console output: > INFO com.AjlibTest.DummyObject - trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: com.AjlibTest.DummyObject@152544e, args using CodeSignature: arg 0 = i, args using getArgs: arg 0 = i > -3 [main] > owen > Ramnivas Laddad wrote: > If you compile your code using ajc or javac with -g (for binary weaving purpose), you will get the original argument names. > -Ramnivas > > On Fri, Nov 14, 2008 at 8:19 AM, rmahmood <rashid_m180@...> wrote: >> >> But this will give the argument names as saved in .class file, normally arg0, >> arg1 etc. >> not the original names as in source code. >> >> Is there any way to get original names as specified in source code? >> >> >> Ramnivas Laddad wrote: >> > >> > You get get the associated CodeSignature object as follows: >> > CodeSignature codeSignature = (CodedSignature) >> > thisJoinPoint.getSignature(); >> > String[] argNames = codeSignature.getParameterNames(); >> > >> > -Ramnivas >> > >> > On Wed, Nov 12, 2008 at 10:48 PM, Owen Corpening >> > <owencorpening@...>wrote: >> > >> >> I am using a tracing aspect and it is printing the method arg values upon >> >> entry, but without arg names: >> >> trace enter: int com.AjlibTest.DummyObject.someMethod(int) , this: >> >> com.AjlibTest.DummyObject@18941f7, args: arg 0 = 5 >> >> >> >> using joinPoint.getArgs() - I can see in the debugger that the arg names >> >> are not in the joinpoint - is there a way an aspect can capture that >> >> info? >> >> >> >> Owen Corpening >> >> 10911 Watchful Fox Drive >> >> Austin, TX 78748 >> >> >> >> 512 280-1753 Home >> >> 512 634-5148 Office >> >> 512 659-5300 Cell >> >> >> >> >> >> _______________________________________________ >> >> aspectj-users mailing list >> >> aspectj-users@... >> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> >> >> >> >> > >> > _______________________________________________ >> > aspectj-users mailing list >> > aspectj-users@... >> > https://dev.eclipse.org/mailman/listinfo/aspectj-users >> > >> > >> >> -- >> View this message in context: http://www.nabble.com/can-arg-names-be-accessed-at-a-joinpoint--tp20474387p20500385.html >> Sent from the AspectJ - users mailing list archive at Nabble.com. >> >> _______________________________________________ >> aspectj-users mailing list >> aspectj-users@... >> https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > > _______________________________________________ > aspectj-users mailing list > aspectj-users@... > https://dev.eclipse.org/mailman/listinfo/aspectj-users > _______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users _______________________________________________ aspectj-users mailing list aspectj-users@... https://dev.eclipse.org/mailman/listinfo/aspectj-users |
| Free embeddable forum powered by Nabble | Forum Help |