1 Reply Latest reply on Mar 19, 2013 10:24 PM by jschellSomeoneStoleMyAlias

    code behaves differently in c and c++

      I have a function which calls java code.
      The function is working fine when placed in c file, but when placed in c++ (cpp) file the return value from the java function is wrong and looks like garbage.

      Does anybody know why ?

      Here is the code

      unsigned char pKey[] = {'0','1','2','3','4','5','6','7','8','9','1','2','3','4','5','6'};
      unsigned char pIv[] = {'0','1','2','3','4','5','6','7','8','9','1','2','3','4','5','6'};
      size_t nBufInLen = 1000;
      size_t nKeyLen = sizeof(pKey);
      size_t nIvLen = sizeof(pIv);

      jbyteArray jKey = env->NewByteArray(nKeyLen);
      jbyteArray jIv = env->NewByteArray(nIvLen);

      jclass cls = env->GetObjectClass(obj);
      jmethodID midGetCryptSize = env->GetStaticMethodID(cls, "GetBufSize", "(I[B[B)I");

      jint nBufOutSize = env->CallStaticIntMethod(cls, midGetCryptSize, nBufInLen, jKey, jIv);

      return nBufOutS