Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get parameter names with Java reflection [duplicate]

How do I get method signatures with Java reflection?

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

like image 324
javatar Avatar asked Dec 21 '22 02:12

javatar


1 Answers

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.

like image 180
mtsz Avatar answered Mar 02 '23 01:03

mtsz