【发布时间】:2019-05-11 00:03:40
【问题描述】:
我正在尝试使用 bytebuddy 重新定义现有的类。我正在寻找带有特定注释的字段。我已经用类似这样的代码弄清楚了:
new ByteBuddy()
.redefine(<some class>)
.field(
ElementMatchers.isAnnotatedWith(<some annotation>)
)
...
我想做的是进一步完善我的 ElementMatcher 以包括对指定注释上的属性的检查 - 像这样:
new ByteBuddy()
.redefine(<some class>)
.field(
ElementMatchers.isAnnotatedWith(<some annotation>)
.havingAttribute(<some attribute>, "value")
)
我正在寻找的是执行“havingAttribute”部分的方法。这是可能的还是我以错误的方式接近这个?任何见解都值得赞赏。
【问题讨论】:
标签: java byte-buddy