From 5f3deb89270fe2a567c58e8ee1cbee0ff4294738 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 6 Sep 2004 17:43:37 +0000 Subject: [PATCH] change sigar pointer field from int to long. on tru64 size(void*) == 8 which does not fit into sizeof(int) == 4 --- bindings/java/src/jni/javasigar.c | 15 +++++---------- bindings/java/src/net/hyperic/sigar/Sigar.java | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/bindings/java/src/jni/javasigar.c b/bindings/java/src/jni/javasigar.c index 6bd2ca70..7e16c866 100644 --- a/bindings/java/src/jni/javasigar.c +++ b/bindings/java/src/jni/javasigar.c @@ -130,8 +130,8 @@ static jni_sigar_t *sigar_get_pointer(JNIEnv *env, jobject obj) { cls = JENV->GetObjectClass(env, obj); - pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "I"); - jsigar = (jni_sigar_t *) JENV->GetIntField(env, obj, pointer_field); + pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "J"); + jsigar = (jni_sigar_t *) JENV->GetLongField(env, obj, pointer_field); if (!jsigar) { sigar_throw_exception(env, "sigar has been closed"); @@ -149,15 +149,10 @@ static jni_sigar_t *sigar_get_pointer(JNIEnv *env, jobject obj) { static void sigar_set_pointer(JNIEnv *env, jobject obj, const void *ptr) { jfieldID pointer_field; - int pointer_int; - jclass cls; - - cls = JENV->GetObjectClass(env, obj); + jclass cls = JENV->GetObjectClass(env, obj); - pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "I"); - pointer_int = (int)ptr; - - JENV->SetIntField(env, obj, pointer_field, pointer_int); + pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "J"); + JENV->SetLongField(env, obj, pointer_field, (jlong)ptr); } JNIEXPORT jstring SIGAR_JNI(Sigar_formatSize) diff --git a/bindings/java/src/net/hyperic/sigar/Sigar.java b/bindings/java/src/net/hyperic/sigar/Sigar.java index 612e11e1..c259c17b 100644 --- a/bindings/java/src/net/hyperic/sigar/Sigar.java +++ b/bindings/java/src/net/hyperic/sigar/Sigar.java @@ -33,7 +33,7 @@ public class Sigar implements SigarProxy { private static SigarLoader loader = new SigarLoader(Sigar.class); private FileSystemMap mounts = null; - int sigarWrapper = 0; //holds the sigar_t * + long sigarWrapper = 0; //holds the sigar_t * // lastCpu is used to calculate the cpuPerc; private Cpu lastCpu;