How to get the line number of a method?

后端 未结 3 902
情歌与酒
情歌与酒 2020-11-28 13:29

Is it possible to get the line number of an method using reflection or other magic?
It is possible if the method is inside the current Stacktrace. Using Thread.c

3条回答
  •  被撕碎了的回忆
    2020-11-28 14:16

    You can't get a line number from a Method because you don't know what method this applies to. A method can call any sub-class of the the one you chose.

提交回复
热议问题