안녕하세요. JNI 질문이 있습니다. 클래스가 있습니다. 사용자 공간의 UserConfig 클래스에 변수 a, b, c 및 d를 설정했습니다.클래스 내의 클래스 배열에있는 변수에 액세스하십시오. JNI
public class SetConfig extends Config {
int status;
public native int setConfig_IOCTL();
}
public class Config {
public Config() { User = new UserConfig[100]; }
int number;
UserConfig[] user;
}
public class UserConfig {
int a;
int b;
int c;
int d;
}
다음 변수를 커널 드라이버에 전달되는 구조체에 할당하려고합니다.
typedef struct {
int status;
Config_t config;
} getConfig;
typedef struct {
int number;
UserConfig_t userConfig[100];
} Config_t;
typedef struct {
int a;
int b;
int c;
int d;
} UserConfig_t;
나는 제대로 UserConfig를 클래스 내의 필드에 액세스 할 수 fieldID가를 얻는 데 문제가 올바른 방향으로 날 가리 키도록 도움을 찾고 있었다.
나는 이것이 잘못되었다는 것을 알고 있습니다.
JNIEXPORT jint JNICALL com_example_test_Config_config_IOCTL(JNIEnv *env, jobject instance) {
getConfig_t tempConfig;
jclass thisClass = (*env)->GetObjectClass(env, instance);
jfieldID fid = (*env)->GetFieldID(env, thisClass, "a", "[LTest/jni/UserConfig;");
tempConfig.config.userConfig[0] = (*env)->GetIntField(instance, fid);
}
JNI 사용을 시작한 사람이라면 도움이 될 것입니다.
답장을 보내 주셔서 감사합니다. 코드는 예제 코드이며 구현 한 코드는 아닙니다. 나는 너의 제안 감사를 시도 할 것이다. – Spoons