
Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
>> List myList = new ArrayList();
>>
>> What method of myList can I call to return the String "myList"?
>
> the names of local variables don't exist in the class file,
Don't exist in all class files, because the LVT (LocalVariableTable) is
an optional part of a class file (assumed a part of a debugging info).
> so this is
> impossible without some preprocessing get it added.
Java compiler (javac) can do that with -g switch (-g:vars is enough).
> However the names
> of instance and class methods and variables are in there.
With local variable debugging information present, the names of local
variables (and method parameters) are also in there. It just requires a
bit more effort to retrieve them, an example is there:
http://tinyurl.com/yqgz3q
piotr