相关疑难解决方法(0)

有没有办法在Java中获取方法参数的名称?

我正在编写小而非常DRY的框架,它严重依赖于元数据.我想知道是否有办法获取方法参数名称,即给定一些方法

public void a(int myIntParam, String theString) { ... }
Run Code Online (Sandbox Code Playgroud)

得到字符串"myIntParam""theString".

我知道我可以注释参数,但这不会很好......

public void a(
    @Param("myIntParam") int myIntParam,
    @Param("theString") String theString
) { ... }
Run Code Online (Sandbox Code Playgroud)

java reflection

17
推荐指数
4
解决办法
1万
查看次数

标签 统计

java ×1

reflection ×1