0
我希望從具有名爲key的字段的特定批註(例如@Callcount)獲取批註值。如何從AnnotationDescription.Loadable在Bytebuddy中獲取註釋值
MethodList<MethodDescription.InDefinedShape> methods = typeDefinition.getDeclaredMethods();
for (MethodDescription.InDefinedShape method : methods) {
AnnotationDescription.Loadable<CalledCount> callCountAnno;
if ((callCountAnno = method.getDeclaredAnnotations().ofType(CalledCount.class)) != null) {
callCountAnno.getValue(?);//how can i do here?
}
}
我不知道如何建立方法callCountAnno.getValue()的參數是我務必做好?
沒有這方面的經驗,所以我不覺得很自在地做出答案。我剛剛瀏覽了Byte Buddy的javadoc,並且它看起來像參數類型需要是'MethodDescription.InDefinedShape'。所以試試'getValue(method)' – kunruh