图说jdk1.8新特性(5)--- 编译器新特性
2024-09-05 17:14:39
/**
* Returns the name of the parameter. If the parameter's name is
* {@linkplain #isNamePresent() present}, then this method returns
* the name provided by the class file. Otherwise, this method
* synthesizes a name of the form argN, where N is the index of
* the parameter in the descriptor of the method which declares
* the parameter.
*
* @return The name of the parameter, either provided by the class
* file or synthesized if the class file does not provide
* a name.
*/
public String getName() {
// Note: empty strings as paramete names are now outlawed.
// The .equals("") is for compatibility with current JVM
// behavior. It may be removed at some point.
if(name == null || name.equals(""))
return "arg" + index;
else
return name;
}
说明:
- jdk1.8反射包增加了
Parameter
类,通过该类的getName
方法能在运行时得到参数的名称- 如果没有通过
-parameters
指定编译器在编译的时候将参数名编译进去,那么得到的参数名称将会是arg1、arg2、arg3这种默认的参数名
最新文章
- .net 的 Url 中文加密
- 换个角度说工作单元(Unit Of Work):创建、持有与API调用
- WPF oxyPlot 使用总结
- IIS7 IIS7.5 配置备份
- 夺命雷公狗---node.js---3commonJs 与 nodeJs的简介
- 【JS Note】undefined与null
- Appium —— desired_capabilities详解
- Java 并发专题 : Timer的缺陷 用ScheduledExecutorService替代
- IO流02_文件过滤器
- N!末尾有多少个零
- Python 练习冊,每天一个小程序
- CF 1138F 超级有意思的一道交互题QVQ
- autoconf配置的项目,编译debug版本
- uva 331 Mapping the Swaps 求交换排序的map 纯DFS
- STM8S——watchdog(IWDG)
- Oracle 11g 错误:ORA-28002: the password will expire within 7 days 解决方法
- ADO.NET数据库编程
- 解决 SVN版本冲突
- 安装python包
- crm使用soap删除下拉框