I am passing an object as a parameter to a method.
i’d like to know the name of that object–
that specific reference variable i’ve been using to pass the object to the method.
is there a way to find out about this?
Or, generally, is there a way to find out about the name of variable used by the
calling method to pass that value to the method invoked ? thanks in advance.
Note— regarding the first Q above: i am aware that an object can have
many handles pointing to it. this is rather a question of whether the
parameter names are getting “special attention” of some sort in the method, or aren’t of any concern once they pass the value.
I believe what you are asking for is more than the information placed on the stack by Java. The JVM has no reason to record the name of a variable when it takes the handle held by that variable and puts it into the stack to call a method. In fact, there’s usually no real reason to preserve that name past compilation. If you can give more information about why you’d want to do such a thing you’ll probably get more reasonable responses.
If what you wanted were possible, it would be via a StackTraceElement, but looking at the API, there’s nothing like what you’re asking for.