javareflectionmethod-signature

How to get parameter names with Java reflection


How do I get method signatures with Java reflection?

EDIT: I actually need the parameter NAMES not the types of a method.


Solution

  • To get the method i of a class C you call C.class.getMethods()[i].toString().

    EDIT: Obtaining parameter names is not possible using the reflection API.

    But wen you compiled your class with debug information, it is possible to extract the information from bytecode. Spring does it using the ASM bytecode engineering library.

    See this answer for further information.