[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-dev] getArgs() and primitive types
|
A clarification; I looked at this a little more carefully and here's
what I discovered.
It looks like calling "getClass()" on an object in the array returned by
"thisJoinPoint.getArgs()" does not equal Integer.TYPE, etc. if the
original arg was a primitive type.
However, if you use Java reflecton calls on a Class instance, e.g., you
call "getDeclaredMethods()", then call "getParameterTypes()" on any of
the returned methods, then those Class instances will equal the *.TYPE
instances if the original arg/parameter was primitive.
So, I guess the question remains, does anyone know of a way to determine
whether or not an object returned from "getArgs()" wraps a primitive or
not? I could use the answer, too ;)
dean
Dean Wampler wrote:
Oleg,
I ran into a similar problem recently while working on
<shamelss-plus>Contract4J</shameless-plus>. I believe that getClass()
on your objects will return Integer.TYPE, rather than some other
instance of the Integer class, and similarly for the other wrappers, if
the object is actually a wrapper around a primitive type.
If you just need to report the "true" type of the object, I think that
obj.getClass().toString() on one of these wrappers outputs "int",
"float", etc., while an object that isn't primitive will result in
"java.lang.Integer", etc.
Let me know if this works!
dean
Oleg Lebedev wrote:
Greetings.
How can I tell whether an argument in an Object array returned from
JointPoint.getArgs() has a primitive type?
What I am trying to do is to record a method execution and all the
parameters passed to the method. I also need to be able to distinguish
between Integer and int parameters. However, ints are wrapped in
Integers when returned by getArgs() method. Is there a way to tell
that even though getArgs() returned an Integer object, in reality the
method takes an int as a parameter?
Thanks.
*Oleg Lebedev*
Software Architect
Waterford Research Institute
Phone: 801.938.1724
Cell: 801.209.6706
------------------------------------------------------------------------
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev
--
Dean Wampler, Ph.D.
dean at aspectprogramming.com
http://www.aspectprogramming.com
http://www.contract4j.org
I want my tombstone to say:
Unknown Application Error in Dean Wampler.exe.
Application Terminated.
[Okay] [Cancel]