How to edit the method annotation attributes on runtime in springboot project?
I've known there's a way to edit by using reflection like invocationHandler.getClass().getDeclaredField("memberValues");
but in the newer springboot environment it doesn't work, cause the invocationHandler
that I got is not the instance of AnnotationInvocationHandler
but the instance of SynthesizedMergedAnnotationInvocationHandler
. In SynthesizedMergedAnnotationInvocationHandler
I can't find the method that let me change the value of the annotation fields on the fly.
I'm trying to reused the way that worked in old version just like:
InvocationHandler invocationHandler = Proxy.getInvocationHandler(rateLimit);
Field field = invocationHandler.getClass().getDeclaredField("memberValues");
field.setAccessible(true);
Map params = (Map)field.get(invocationHandler);
params.put("fields1",xxx);
but there's no fields called memberValues