How can i get the `signature` field of java reflection Method object

Viewed 8748

i'm using ASM to build class file base on another Interface , i could use java reflection to get methods of the Interface , but i need to get the signature of it . enter image description here

i found it's a private field , and there's no direct method to get it . is there any way out ? i use jdk7 . tks advance .

2 Answers

Replacing '.' with '/' makes Gabriel Tofvesson's answer complete:

... .toString().replace('.', '/');

Otherwise, the signature returned would be something like ()Ljava.lang.Object;. However, in signatures, the package names must be separated using slashes instead of periods: ()Ljava/lang/Object;.

Related