Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

get method args types  RSS feed

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all
im querying class with reflection packge , im getting the class and found the method name but now
i like to find out what type of args types this method contains
what i got so far:


now when i print the method like this :
System.out.println(currentMethod.toString());
i do get the method name and its types the method get , but is there more elegant way to do it ?
the get the types in some array or so ?
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Method has a method "getParameterTypes" which delivers an array of Class objects representing the parameters of the method in the correct order.
Works like a charm, allowed me to create a rather interesting JSP to dynamically create test objects and use those as method parameters for testing EJBs on the fly
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!