title: JNA Structure ByReference
body: <p>below the method and the unit test for that method. 
  The problem is that I'm not able to return the value of result from the Load method.
  the unit test below fails!</p>
  
  <p>I thought that by default JNA's object were ByRef by default so I tried instantiating and passing LoadResults "without" .ByReference ... </p>
  
  <p>where is my mistake?</p>
  
  <pre><code>@Test
  public void testLoad () {
     MY_Processor proc = new MY_Processor();
     // LoadResults result = new LoadResults ();
     LoadResults.ByReference result = new LoadResults.ByReference();
     ByteByReference [] pathToFile = new ByteByReference[256];
     // fill pathToFile out ... 
  
     try {
        proc.Load (pathToFile, result);
        assertEquals(0, result.errorCode);
        assertEquals(1, result.elaborationTime);
        assertEquals(2, result.coreItem);
     } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
     }
  }
  
  
  
  public Integer Load ( ByteByReference[] pathToFile, 
                            LoadResults.ByReference result ) throws Exception {
  
     // here result is correctly filled out !
     LoadResults result = null;
     result = native.getResult (numCore);
  }
  </code></pre>
  
  <p>added the native code.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre class="lang-c prettyprint-override"><code>// header
  typedef struct
  {
     int     errorCode;
     int     elaborationTime;
     int     coreItem;
  } LoadResults;
  
  //[in]  path
  //[out] result
  int Load (char path[MY_BUFFER_DEFINE], LoadResults* result);
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>// implementation ...
  
  LoadResults* getResult (int numCore)
  {
     // some check ... 
  
     LoadResults *localResult = new LoadResults();
     // fill out ... 
  
     return localResult;
  }
  </code></pre>
  
  <p>there is a "free" method exposed by the native code but I didn't show in order to keep the focus on my problem :-)</p>
  
  <p><strong>/UPDATE</strong></p>
  
  <p>thanks!</p>
  
  <p>O.</p>