pa1b parameter type formatting

30 views
Skip to first unread message

Mark Tyrrell

unread,
Feb 15, 2012, 12:03:14 PM2/15/12
to cs63...@googlegroups.com
Is there a way to get clean parameter types from the reflection API?

Of the methods available for getting parameter types, one lacks information about <Generics> while the other prefixes class names by the word class. And neither appear to handle array syntax well (prefixing by [L instead of suffixing with []). I've gotten the output that I want through string manipulation, but I was wondering if there might be a cleaner way to do this.

Betty O'Neil

unread,
Feb 15, 2012, 12:40:36 PM2/15/12
to Mark Tyrrell, cs63...@googlegroups.com
I'm afraid there is some non-pretty string manipulation needed to
get everything you need. --Betty O.

Max Ward

unread,
Feb 15, 2012, 12:52:03 PM2/15/12
to cs63...@googlegroups.com, cs63...@googlegroups.com
Use Method.getParameterTypes() to get the array of Class<?> and then I think Class<?>.getName() will give you the parameter type without the prefix "class".

mohamed

unread,
Feb 16, 2012, 11:56:33 AM2/16/12
to cs639_s12
Using the above still results with the contrived stuff. For example
for main it results with [Ljava.lang.String;. We still need more
String manipulation to get to String[] unless some one else found an
alternative.
Reply all
Reply to author
Forward
0 new messages