Passing Strings as argument in a native method
Hi,
I have to return from my C++ code a string. I have read that is not recommended to change the String object in the native function, so I chosen to work with StringBuffer. The problem is that when I call CallObjectMethod an exception is raised by StringBuffer.append : NullPointerException .
My code is:
//-- stringBuf is jobject function parameter
classStringBuffer = pEnv->GetObjectClass(stringBuf);
methodId = pEnv->GetMethodID(classStringBuffer, "append", "(Ljava/lang/String;)(java/lang/StringBuffer;");
pEnv->CallObjectMethod(obj, methodId, pEnv->NewStringUTF("a string"));
//--this is the place where the NullPointerException appears ...
I verified that CallObjectMethod return NULL.... I have no ideea where I wrong.
Please advise me!
Thanks and Regards,
Cosmin Petra

