As the title says I'm trying to modify a method's annotation String parameter at runtime in Java on Android. I've found an answer to another question asked some time ago which should solve the problem. However, it didn't on Android. In the linked answer there is the following code line
Object handler = Proxy.getInvocationHandler(annotation);
It assigns a libcore.reflect.AnnotationFactory Object to the handler variable. Three lines later in the code it is tried to get the class's field "memberValues", which is said to provide the annotation's member-value-pairs. It is realized using this line of code:
f = handler.getClass().getDeclaredField("memberValues");
However, Android's AnnotationFactory class does not have a field named "memberValues". That's why I get an exception telling me: java.lang.NoSuchFieldException: No field memberValues in class Llibcore/reflect/AnnotationFactory; (declaration of 'libcore.reflect.AnnotationFactory' appears in /apex/com.android.art/javalib/core-libart.jar). I am trying to apply this runtime modification to the functionName value of a simple interface looking like this:
public interface LambdaFunctionInterface {
@LambdaFunction(functionName = "PLACEHOLDER")
Object lambdaFunction(Object request);
}
How can I realize it on Android? Where are the mentioned member-value-pairs of annotations stored on Android? Thanks a lot in advance!
Aucun commentaire:
Enregistrer un commentaire