问题描述
要使用Java反射获取方法参数名称,我们必须使用"-parameters"选项编译Java类,但是当我使用VM Arguments从eclipse中进行操作时,在控制台中出现以下错误.
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.
我的系统中正在运行Java 8.我想念什么?
I have Java 8 running in my system. What am I missing?
推荐答案
问题是这不是VM参数. IE.;它不是要与java
一起使用,而是与javac
一起使用.
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:
- 窗口>首选项> Java>编译器,或
- 项目>属性> Java编译器
还有一个复选框,用于启用存储有关方法参数的信息(可通过反射使用)".可以用于此目的.
And there is a check box to enable "Store information about method parameters (usable via reflection)." That you can use for this.
这篇关于在Eclipse中使用-parameters选项进行反射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!