lundi 29 mai 2023

how to edit method annotation attributes on runtime in springboot project?

how to edit 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 cant find the method that let me change the value of the annotation fields on the fly,thx in advance

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'





Aucun commentaire:

Enregistrer un commentaire