title: Android: getting a c++ std::string up to JNIEXPORT gets unexpectedly cleared out
body: <p>On an Android application, I'm trying to get a string from native code up to Java, but exactly at the JNIEXPORT level, the std::string gets wiped out of its contents.
  Here's the code for all the three layers:</p>
  
  <p>C++ code (original x-patform class):</p>
  
  <pre><code>std::string GTAInterface::GetConfigurationJSON()
  {
      std::string m_cfgJSON = "a bare test";
      return m_cfgJSON;
  }
  </code></pre>
  
  <p>C++ wrapper code (since JNI on Android can only call static C++ functions... no words on this):</p>
  
  <pre><code>const char *gtaGateway::GetConfigurationJSON(int sysId)
  {
      string ret = ((GTAInterface*)gtaSystemArray[sysId])-&gt;GetConfigurationJSON();
      return ret.c_str(); // here the "ret" string is still retaining the retrieved value
  }
  </code></pre>
  
  <p>An finally, the JNIEXPORT class:</p>
  
  <pre><code>JNIEXPORT jstring JNICALL
  Java_com_gta_sdk_gtaGateway_GetConfigurationJSON(JNIEnv *env, jobject obj, jint sys)
  {
      std::string cfgJson = gtaGateway::GetConfigurationJSON(sys);
  
      return env-&gt;NewStringUTF(cfgJson.c_str()); // here the debugger shows that "cfgJson" is "" (empty)??!!
  }
  </code></pre>
  
  <p>So, the code correctly gets executed throughout all the call chain, but for some reason I can't figure out why the "cfgJson" string @ the JNIEXPORT level gets cleared out!
  Could someone please help out, since I have no other clue of what I could be doing wrong...</p>
  
  <p>Many thanks!</p>