I need to call a java method from JNI using reflection. (I know that this can be done without reflection, but the application I'm trying to do this in has protection and env - >GetMethodId returns nullptr) I successfully got the invoke function from java.lang.reflect.Method and I can call the method, but what do I do with the arguments? The invoke method takes the java.lang.Object array as arguments, and if I need to call the (void abc(int A)) method for example, what should I do?
I tried to do this via java/lang/Integer, but it doesn't seem to be correct and I end up getting a crash.
I apologize for the English, I used a translator.
jclass integerClass = jenv->FindClass("java/lang/Integer");
jmethodID integerConstructor = jenv->GetMethodID(integerClass, "<init>", "(I)V");
jenv->SetObjectArrayElement(Args,0, jenv->NewObject(integerClass, integerConstructor, 10));
I hope for your help.
Aucun commentaire:
Enregistrer un commentaire