native jlong field access broken?

Peter C. Mehlitz pm at biss-net.com
Thu Sep 11 07:38:21 PDT 1997


I'm experiencing a strange difference between kaffe-0.8.4 and kaffe-0.9.1 when
trying to access 'jlong' fields of Java objects from within shared libraries.

With kaffe-0.8.4, I get the following (correct) result when running the
appended example:
 $ kaffe Fields
 A= 1, B= 2, C= 3, D= 4

However, running the same prog on kaffe-0.9.1 (rebuilt app, of course), I get
 $ kaffe Fields
 A= 1, B= 2, C= 12884901888, D= 0

Access to jlong fields (and all subsequent fields) seems to be broken. Any
ideas, fixes.. ? I'm using gcc-2.7.2 on a i586, Linux 2.0.30, libc-5.4.33.

Peter



---------------------------- Fields.java
 public class Fields {
   int  A = 1;
   int  B = 2;
   long C = 3;
   int  D = 4;

   native void foo ();

   static {
 	System.load( "/home/pm/java/test/libkaffe_fields.so");
   }

   public static void main ( String[] args ) {
 	Fields obj = new Fields();
 	obj.foo();
   }
 }

--------------------- fields.c
 #include <stdlib.h>
 #include "Fields.h"

 void Fields_foo ( HFields* fields ) {
   jint  a = unhand(fields)->A;
   jint  b = unhand(fields)->B;
   jlong c = unhand(fields)->C;
   jint  d = unhand(fields)->D;

   printf( "A= %ld, B= %ld, C= %Ld, D= %ld\n", a, b, c, d);
 }



More information about the kaffe mailing list