I am running a simple JNI program using the Invocation API on z/os with C. The Java program has a simple sayHello() method like this-
public static String sayHello(){
return "Hello World!!!";
}
the code that calls this method and prints the output is as follows-
jmethodID mid=(*env)->GetStaticMethodID(env,cls2,sHStr,sigVoidString);
jstring j = (jstring)(*env)->CallStaticObjectMethod(env,cls2, mid);
const char *str = (*env)->GetStringUTFChars(env, j, NULL);
printf("%s", str);
(*env)->ReleaseStringUTFChars(env,j,str);
The output is printed as follows-
..%%?..?.%....
Turning HEX on shows the following which indicates that it is indeed HelloWorld!!!-
46666256766222
85CCF07F2C4111
I have checked few SO posts about the same problems such as this and this and each suggests using GetStringUTFChars which I am using without any success. Is there anything specific to z/os going on here?