Pobierz obiekt z obiektu z JNI w C
public class Student
{
private People people;
private Result result;
private int amount;
}
Oto przykład klasy w Javie; w C próbowałem zdobyć „ludzi” w „Uczniu”, ale zawiodłem. Jednak jestem w stanie uzyskać typ int „kwota” z „Ucznia”.
jobject getObjectFromObject(JNIEnv *env, jobject obj, const char * fieldName)
{
jfieldID fid; /* store the field ID */
jobject i;
/* Get a reference to obj's class */
jclass cls = (*env)->GetObjectClass(env, obj);
/* Look for the instance field s in cls */
fid = (*env)->GetFieldID(env, cls, fieldName, "L");
if (fid == NULL)
{
return 0; /* failed to find the field */
}
/* Read the instance field s */
i = (*env)->GetObjectField(env, obj, fid);
return i;
}
Próbuję przekazać „ludzi” jako nazwę pola do metody, ale nadal daje następujący błąd: „java.lang.NoSuchFieldError: people”