Q:

Can NOT pass java int to jni function

I have a simple jni function in test.cpp:
#include <jni.h>
#include <stdio.h>

extern "C" {

JNIEXPORT jint JNICALL Java_dri_put(JNIEnv* env, jstring js, jint ji){

    printf("%d \n", ji);
    int t = ji;
    printf("%d \n", t);
    int k = -3412;
    return k;
 }
 }

my java class javatest.java:
public class javatest {
  public static void main(String args[]) {
    System.loadLibrary("test");
    int t = 134;
    int k = dri.put("a", 5641);
    System.out.println(k);
  }
 }

the output just prints some random number of the passing integer:
1075968840
1075968840
-3412
however if i change jint to jdouble and pass java double variable, it works fine, appreciate any help here.
The dri java class is:
public class dri
{
  public final static native int put(String jarg1, int jarg2);
}

sizof(int) results in 4 bytes on my machine (red-hat)

A:

Your signature is incorrect (did you use javah?).  The second argument to a JNI function will be the object (for object methods) or the class (for static class methods).
Your declaration should look like this instead:
JNIEXPORT jint JNICALL Java_dri_put(JNIEnv* env, jclass cls, jstring js, jint ji);

