title: SWIG change function signature
body: <p>I am using Swig to create a Java interface. Basically, in C++ I have template (</p>
  
  <pre><code>template&lt;class T&gt; class TSizedArray
  {
      int GetLength();
      T* GetElements() const;
      ...
  }
  
  class Producer
  {
      TSizedArray&lt;long&gt; GetLongs();
      ...
  }
  </code></pre>
  
  <p>This template is used as return value of some functions of API I need to export to Java via SWIG. However, in Java we want to use native Java arrays instead of this simple wrapper:</p>
  
  <pre><code>Java:
      long[] result = Producer.GetLongs();
  </code></pre>
  
  <p>I am not sure how to achieve this with SWIG. The template has multiple instantiations, and is used as input and output of multiple methods in different classes. I was able to use:</p>
  
  <pre><code>%typemap(jstype) TCustomElementList "long[]"
  </code></pre>
  
  <p>to get the generated Java interface as long[] GetLongs(), but the generated implementation creates new object of type TCustomElementList.</p>
  
  <p>Thanks for any ideas.</p>