0
C 프로그램과 통신하는 Java 프로그램이 있습니다. 이전에 JNI를 작성했지만 출력 구조가 더 단순하고 C 구조에 double/int 및 double/int 배열이 포함되어 있습니다.JNI 및 하위 클래스 액세스
내 구조는 하위 구조 (클래스/하위 클래스)가 포함되어 있으며 하위 클래스 데이터/필드에 액세스하는 코드를 변경하는 방법을 알지 못합니다.
내 C 코드는 다음과 같습니다.하지만이 코드 아래의 Java 클래스를 보면 DefaultFeeAmount
과 같은 값을 어떻게 액세스합니까? 하위 클래스 내의 요소는 어떻게 얻을 수 있습니까?
C는 간단합니다 ....
{
jclass out_rec_cls = jenv->GetObjectClass(ptrTo_out_rec);
jfieldID fldID, fldID2;
jintArray arr;
jdoubleArray darr;
jobjectArray oarr;
jsize len;//,len2;
jint *arrElems;
jdouble *darrElems;
jobject *oarrElems;
int i;
char temp_str[100],temp_str2[10000];
fldID = jenv->GetFieldID(out_rec_cls, "ErrorCode", "I");
if(fldID != NULL)
jenv->SetIntField(ptrTo_out_rec, fldID, out_rec->error_code);
}
자바
class FeeOutput {
public double DefaultFeeAmount;
public double MaximumAmount;
public int FeeID;
public int CompType;
public int Handling;
public int CapType;
public int ProfitType;
public int EffectiveDateMonth;
public int EffectiveDateDay;
public int EffectiveDateYear;
public int VendorBasedFee;
public int DealerRequestedFee;
public int DealerFixedTranFee;
public double FeeAmount;
public int FeeCompliant;
public String FeeName = "";
public FeeOutput() {
}
}
public class VFeeOutput {
public static final int NUM_FEES = 100;
public FeeOutput[] FeeStruct = new FeeOutput[NUM_FEES];
public int ErrorCode;
public String ErrorString = "";
public String Version = "";
public VFeeOutput() {
}
}