JNA : Error when to call natives functions with pointer to struture as parameters
<p>I tested this int EMV_Init(EMV_PARAMS *params, EMV_HANDLE *hEMV) in C, it works well.
Now i want to call it in my java application by means of jna. This function is in a native library under windows (dll file).</p>

<p>EMV_PARAMS is a structure </p>

<pre><code>typedef struct
{

    HAL_UI_HANDLE           ui;

    HAL_SCR_HANDLE          card;

    HAL_PROPERTY_HANDLE     property;

    HAL_DATE_HANDLE         date;

    HAL_CRYPTO_HANDLE       crypto;

    HAL_CHV_HANDLE          chv;

} EMV_PARAMS;
</code></pre>

<p>Note that all attributes in EMV_PARAMS is is an opaque structure like this typedef void * HAL_UI_HANDLE;</p>

<p>EMV_HANDLE is also an opaque structure : typedef void *EMV_HANDLE;</p>

<p>I need your help to fix the following error:</p>

<pre><code>Exception in thread "main" java.lang.NullPointerException at 
com.sun.jna.Structure.getFields(Structure.java:895)

at com.sun.jna.Structure.deriveLayout(Structure.java:1042)

at com.sun.jna.Structure.calculateSize(Structure.java:966)

at com.sun.jna.Structure.calculateSize(Structure.java:933)

at com.sun.jna.Structure.allocateMemory(Structure.java:360)

at com.sun.jna.Structure.&lt;init&gt;(Structure.java:184)

at com.sun.jna.Structure.&lt;init&gt;(Structure.java:172)

at com.sun.jna.Structure.&lt;init&gt;(Structure.java:159)

at com.sun.jna.Structure.&lt;init&gt;(Structure.java:151)
</code></pre>

<p>I created a Java interface named "CInterface" which contains "EMV_PARAMS" class.</p>

<pre><code>public interface CInterface extends Library
{

    CInterface INSTANCE = (CInterface) Native.loadLibrary("path to dll",     CInterface.class);

    public int EMVCT_Init(EMV_PARAMS.ByReference params, Pointer hEMV);


    public static class PARAMS extends Structure

    {

        public static class ByReference extends PARAMS implements Structure.ByReference {}

        Pointer           ui;

        Pointer          card;

        Pointer     property;

        Pointer         date;

        Pointer       crypto;

        Pointer          chv;

        @Override

        protected List getFieldOrder() {

            // TODO Auto-generated method stub

            return null;
        }

    }

} 
</code></pre>

<p>java test class</p>

<pre><code>public static void main(String[] args) 

{

CInterface.EMV_PARAMS.ByReference emv_param = new 

CInterface.EMV_PARAMS.ByReference();

    int test= 0;

    Pointer hEMV = null;

    test=CInterfaceEMV.INSTANCE.EMVCT_Init(emv_param, hEMV);

    System.out.println("test="+test);

}
</code></pre>

<p>Thank you for your attention</p>