1

Look question Parameter passing in native a method. What to do if I want to write a native method Traverser (String path), which returns a value? How do I convert a long int type in C in Java type that returns a native method Traverser (String path)? For example how to transform long int to jlong? If I want to write a method

public native long Traverser (String path),

whether will be correct this code

JNIEXPORT jlong JNICALL Java_ParallelIndexation_Traverser(JNIEnv* env, jobject obj, jstring path) 
{ 
    long int result;
    const jbyte* path2 = env->GetStringUTFChars(path, nullptr); 
    if (path2 == nullptr) 
        return; 

    result=Traverser(path2); 

    env->ReleaseStringUTFChars(path, path2); 
    return result;
} 

?

Or is it necessary to convert

long int result 

to

jlong?

And whether Java_ParallelIndexation_Traverser is possible instead of

long int result;

to declare

jlong result;

?

Community
  • 1
  • 1
user1730626
  • 437
  • 1
  • 8
  • 16
  • 5
    what's the point of asking the same question again on the same forum when your previous one is still open? – Arham Oct 21 '12 at 16:21
  • @Arham Unless you don't see distinction in questions (look millimoose comments on http://stackoverflow.com/questions/12990929/parameter-passing-in-native-a-method - Don't move the goalposts. If your original question was answered, accept an answer and ask additional questions separately, instead of expanding the scope of one question forever)? – user1730626 Oct 21 '12 at 17:52
  • What happened when you tried it? – user207421 Oct 23 '12 at 10:17

0 Answers0