0

Duplicate: In a method is there a way to query the name of the method I am in? - Duplicate of Get the Current Stack Trace.

Still valid: And is there a way to get the parameters that were passed to the method?

Yes I can see all that in the method and use them literally, this is for a very weird idea where this might be useful. Also, I'm curious.

Community
  • 1
  • 1
David Thielen
  • 28,723
  • 34
  • 119
  • 193
  • 1
    Possible duplicate: [Get the Current Stack Trace](http://stackoverflow.com/questions/1069066/get-current-stack-trace-in-java). I don't think there's any way to reflectively access a method parameter. – markspace Dec 02 '15 at 23:56
  • @markspace - Thank you on the method name part. – David Thielen Dec 02 '15 at 23:58
  • 2
    Please clarify how you're intending to use this. – Sotirios Delimanolis Dec 03 '15 at 00:05
  • You might find [AOP](https://en.wikipedia.org/wiki/Aspect-oriented_programming) more useful here - see [AspectJ](https://en.wikipedia.org/wiki/AspectJ) (or similar library) for more info. – Bohemian Dec 03 '15 at 00:11
  • The parameters are passed in local variables to your method. 1) they are named *local* variables for a reason 2) your method can modify these variables freely and the JVM is not holding a copy of all parameter variables just for the sake of some potential reflective access. So even with a debugger, there is no way to undo the manipulation of local variables to get their initial value. – Holger Jan 13 '16 at 17:42

0 Answers0