Suppose I have a java.lang.reflect.Method
, and when printed out is the following:
public static void onWorldLoad(WorldEvent.Load event) {
}
I want to add an annotation to it and define it in a class I have, so it becomes like this (in my class):
@SubscribeEvent
public static void onWorldLoad(WorldEvent.Load event) {
}
However, I have no idea anyway that is possible to do this without defining the actual method itself in my other class instead of just using the Method
object from java.lang.reflect.Method
. In other words, I have two questions here:
- How do I add the
Method
to my class without strictly defining it? - For the
Method
, I want to add an Annotation to do it (without strictly defining the method itself). Is this possible via Reflection?
Edit: I am not editing the original method. I just want to add the Method itself to my class with the same name and arguments, and also add the annotation to my newly created method in my class.
Aucun commentaire:
Enregistrer un commentaire