在 Eclipse 中使用 -parameters 选项进行反射 [英] Using -parameters option in eclipse for reflection

查看:39
本文介绍了在 Eclipse 中使用 -parameters 选项进行反射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要使用 java 反射获取方法参数名称,我们必须使用-parameters"选项编译 Java 类,但是当我使用 VM 参数从 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.

在eclipse中,你可以去:

In eclipse, you can go to:

  • Window > Preferences > Java > Compiler ,或者到
  • 项目 > 属性 > 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 选项进行反射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆