diff --git a/bindings/java/src/jni/generate.pl b/bindings/java/src/jni/generate.pl index 9d5f3d6f..6dcb719c 100644 --- a/bindings/java/src/jni/generate.pl +++ b/bindings/java/src/jni/generate.pl @@ -1038,7 +1038,11 @@ EOF NetConnection => <<'EOF', public native String getTypeString(); - public native String getStateString(); + public native static String getStateString(int state); + + public String getStateString() { + return getStateString(this.state); + } EOF Mem => <<'EOF', public String toString() { diff --git a/bindings/java/src/jni/javasigar.c b/bindings/java/src/jni/javasigar.c index 97da4b36..8b18d683 100644 --- a/bindings/java/src/jni/javasigar.c +++ b/bindings/java/src/jni/javasigar.c @@ -765,13 +765,10 @@ JNIEXPORT jstring SIGAR_JNI(NetConnection_getTypeString) } JNIEXPORT jstring SIGAR_JNI(NetConnection_getStateString) -(JNIEnv *env, jobject obj) +(JNIEnv *env, jobject cls, jint state) { - jclass cls = JENV->GetObjectClass(env, obj); - jfieldID field = JENV->GetFieldID(env, cls, "state", "I"); - jint type = JENV->GetIntField(env, obj, field); return JENV->NewStringUTF(env, - sigar_net_connection_state_get(type)); + sigar_net_connection_state_get(state)); } JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getWhoList)