• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNI newbie - different const qualifiers

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody, this is is my first time using jni and i�m getting a few warnings which i would like to fix if possible.
I have this C function, Getdata (char * Getdata(char *q, char *t)) and i want to send its return value to the java side doing this

JNIEXPORT void JNICALL Java_DBtools_execute_1upd
(JNIEnv *env, jobject obj, jstring query, jstring table)
{
const char *query_c = (*env)->GetStringUTFChars(env, query, 0);
const char *table_c = (*env)->GetStringUTFChars(env, table, 0);

jclass cls = (*env)->GetObjectClass(env, obj);
jmethodID mid = (*env)->GetMethodID(env, cls, "print_upd",
"(Ljava/lang/String;Ljava/lang/String V");
if (mid == 0) {
return;
}
(*env)->CallVoidMethod(env,obj,mid,
(*env)->NewStringUTF(env,Getdata(query_c,table_c)),
(*env)->NewStringUTF(env,get_writeset()));
}

but i get two warnings (warning C4090) saying that there are different const qualifiers and it points to the CallVoidMethod line, because of query_c and table_c variables. Is this an important warning? How do i fix it?
Thanks!

[ November 24, 2004: Message edited by: Gus Spain ]
[ November 24, 2004: Message edited by: Gus Spain ]
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The signature of your Getdata method is
char* Getdata(char* , char*).

The problem that the compiler is warning about is that the parameters are char*, but you are passing const char*.

To relieve this, simply remove the const qualifier in the JNI function; cast to a (char*) if needed.
[ November 24, 2004: Message edited by: Joel McNary ]
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic