在Java 8中编译时,为某些类存储方法参数名称 [英] Store method parameter names for some classes when compiling in Java 8

查看:297
本文介绍了在Java 8中编译时,为某些类存储方法参数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Eclipse在Java Compiler选项卡中有一个选项:

Eclipse has an option in Java Compiler tab:

Store information about method parameters (usable via reflection)

如果我选中了该选项。我可以通过Parameter API获取方法参数。这很好。

If I checked on the option. I am able to get method parameter via Parameter API. It is good.

如果我打开选项,编译器会在所有编译类中存储方法参数信息。这可能会使class / jar文件更大。 Eclipse默认关闭它。

If I turn on the option, Compiler will stored method parameter information in All my compiling classes. This may make the class/jar file bigger. Eclipse turn it off by default.

我的问题是:有没有办法打开我想要的某个类的选项?是否有任何编译器指令可以将其添加到我的java类中用于此目的?

My question is: Is there any way to turn on the option for some class I want? Is there any compiler directive that I can add it into my java class for this purpose?

谢谢!

推荐答案

在某种程度上是的。这是 javac 的选项(请参阅 - 参数)和javac可以在你想要的任何文件集上运行。但是,在多个文件上运行javac时,没有任何选项可以选择性地将参数应用于某些类,因此您最不可能运行多个javac。这可以通过最有可能使用构建语言的构建文件来完成(例如Ant或Gradle)。

Yes in a way. This is an option to javac (see -parameters) and javac can be run on whatever set of files you would like. However, there is not any option to selectively apply -parameters to certain classes when running javac on multiple files, so you would have to run multiple javac's most likely. This could be done through a build file most likely with a build language (for instance Ant or Gradle).

这篇关于在Java 8中编译时,为某些类存储方法参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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