To obtain method parameters names using java reflection we have to compile the Java class with "-parameters" option, but when I do it from eclipse using VM Arguments, I get the following error in console.
Unrecognized option: -parameters
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I have Java 8 running in my system. What am I missing?
解决方案
The problem is that this is not a VM argument. i.e.; It's not meant to be used with java, but rather with javac.
In eclipse, you can go to:
Window > Preferences > Java > Compiler , or to
Project > Properties > Java Compiler
And there is a check box to enable "Store information about method parameters (usable via reflection)." That you can use for this.