title: Return java.lang.Object using SWIG %native function
body: <p>I'm declaring an inline native JNI function, getId.  I'm unsure of how to tell SWIG, in the %native snippet below, how to just return a java.lang.Object.  I have TBD there for now.  I believe a typemap is the proper approach, but I'm unsure of how to declare it for a native JNI method using the %native function.  Any ideas? </p>
  
  <pre><code>%module Sample
  %{
  JNIEXPORT jobject JNICALL Java_com_test_SampleJNI_getID(JNIEnv *env, jclass cls) 
  {
      jmethodID cnstrctr;
      jvalue args[2];
      jobject obj;
      jbyteArray bArray;
  
      bArray = (*env)-&gt;NewByteArray(env, 32);
  
     (*env)-&gt;SetByteArrayRegion(env, bArray, 0, 32, (jbyte *)foo);
  
     cls = (*env)-&gt;FindClass(env, "com/test/jni/DeviceId");
     cnstrctr = (*env)-&gt;GetMethodID(env, cls, "&lt;init&gt;", "(ILjava/lang/String;[B)V");
  
     args[0].i = (*env)-&gt;NewStringUTF(env, "id");
     args[1].i = bArray;
  
     obj = (*env)-&gt;NewObjectA(env, cls, cnstrctr, args);
  
     return obj;
  }
  %}
  %native(getID) TBD getID();
  </code></pre>
  
  <p><strong>DeviceId.java:</strong></p>
  
  <pre><code>package com.test.jni;
  
  public class DeviceId {
      private String id;
      private byte[] cache;
  
      public DeviceId(String id, byte[] cache){
          this.id=id;
          this.cache=cache;
      }
  
      public byte[] getCache() {
          return cache;
      }
  
      public void setCache(byte[] cache) {
          this.cache = cache;
      }
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }   
  }
  </code></pre>