From 204041aed790ba145afc6a7eccfa941a7fb88a53 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 7 May 2005 06:01:32 +0000 Subject: [PATCH] add static NetConnection.getStateString --- bindings/java/src/jni/generate.pl | 6 +++++- bindings/java/src/jni/javasigar.c | 7 ++----- 2 files changed, 7 insertions(+), 6 deletions(-) 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)