public static class HTCSP_RSA_ST extends Structure{
public HTCSP_RSA_PUB_ST ht_RSA_pub_st;
public HTCSP_RSA_PRI_ST ht_RSA_pri_st;

public static class ByValue extends HTCSP_RSA_ST implements
Structure.ByValue {
} public static class ByReference extends HTCSP_RSA_ST implements
Structure.ByReference {
}
} public static class HTCSP_RSA_PUB_ST extends Structure {
public int dwbits;
public byte[] byModulus;
public byte[] bypublicExponent; public static class ByValue extends HTCSP_RSA_PUB_ST implements
Structure.ByValue {
} public static class ByReference extends HTCSP_RSA_PUB_ST implements
Structure.ByReference {
}
} public static class HTCSP_RSA_PRI_ST extends Structure {
public int dwbits;
public byte[] byModulus;
public byte[] bypublicExponent;
public byte[] byexponent;
public byte[][] byprime;
public byte[][] byprimeExponent;
public byte[] bycoefficient; public static class ByValue extends HTCSP_RSA_PRI_ST implements
Structure.ByValue {
} public static class ByReference extends HTCSP_RSA_PRI_ST implements
Structure.ByReference {
}
}
以上是结构体其中HTCSP_RSA_ST 中的属性为其他2个结构体
HTCSP_RSA_ST.ByReference phtcsp_rsa_st = new HTCSP_RSA_ST.ByReference();
在调用时报错java.lang.IllegalStateException: Array fields must be initialized
为什么new不出来?求助

解决方案 »

  1.   

    这哪里是java代码呀,太NB了。
      

  2.   

    ----------------------------------
    数组成员就是2个结构体已经初始化了现在是只要一new就报这个错
      

  3.   

    HTCSP_RSA_PUB_ST csppublic = new HTCSP_RSA_PUB_ST();
    csppublic.dwbits = 256;
    csppublic.byModulus = new byte[((2048 + 7) / 8)];
    csppublic.bypublicExponent = new byte[((2048 + 7) / 8)]; HTCSP_RSA_PRI_ST cspprivate = new HTCSP_RSA_PRI_ST();
    cspprivate.dwbits = 256;
    cspprivate.byModulus = new byte[((2048 + 7) / 8)];
    cspprivate.bypublicExponent = new byte[((2048 + 7) / 8)];
    cspprivate.byexponent = new byte[((2048 + 7) / 8)];
    cspprivate.byprime = new byte[2][((((2048 + 1) / 2) + 7) / 8)];
    cspprivate.byprimeExponent = new byte[2][((((2048 + 1) / 2) + 7) / 8)];
    cspprivate.bycoefficient = new byte[((((2048 + 1) / 2) + 7) / 8)]; HTCSP_RSA_ST phtcsp_rsa_st = new HTCSP_RSA_ST();
    phtcsp_rsa_st.ht_RSA_pub_st = csppublic;
    phtcsp_rsa_st.ht_RSA_pri_st = cspprivate;
    代码
      

  4.   

    java.lang.Object
      com.sun.jna.Structure
        int calculateSize(boolean force)Calculate the amount of native memory required for this structure.
    May return CALCULATE_SIZE if the size can not yet be determined (usually due to fields in the derived class not yet being initialized). 
    If the force parameter is true will throw an IllegalStateException if the size can not be determined. Throws: IllegalStateException - an array field is not initialized 
      

  5.   

    不是这段
    HTCSP_RSA_ST phtcsp_rsa_st = new HTCSP_RSA_ST();这段报错
      

  6.   


    7L已经出文档说明了,也就是你的类的两个属性ht_RSA_pub_st和ht_RSA_pri_st的size都是未知的,你可以试试在构造函数里调用 super.calculateSize(false)试试看