This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug with JNI on Solaris (wrong function address?)


Hi!
I am back from vacation again and now i will continue with producing errors ;-)

This is the problem:
$ cat bug.c

#include <jni.h>
#include <stdio.h>

int main()
{
 JNIEnv *env;
 JavaVM *jvm;
 JavaVMInitArgs vm_args;
 jint res;
 jclass cls;

 vm_args.version = JNI_VERSION_1_2;

 JNI_GetDefaultJavaVMInitArgs(&vm_args);

 /* Create the Java VM */
 res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
 if (res < 0)
    {
     fprintf(stderr, "Can't create Java VM\n");
     return(1);
    }

 puts("FindClass:");
 cls = (*env)->FindClass(env, "java/lang/String");
 if (cls == 0) {
     fprintf(stderr, "Can't find hello class\n");
     return(1);
 }
 return 0;
}

$ gcj -o bug bug.c
$ ./bug
FindClass:
Abort (core dumped)

$ gcj -v
Reading specs from
/data/titan_1/kahlert/gcc-3.1/lib/gcc-lib/sparc-sun-solaris2.7/3.1/specs
Reading specs from
/data/titan_1/kahlert/gcc-3.1/lib/gcc-lib/sparc-sun-solaris2.7/3.1/../../../libgcj.spec
rename spec lib to liborig
Configured with: ../gcc-20020204/configure --prefix=/data/titan_1/kahlert/gcc-3.1
   --enable-languages=c++,f77,java --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld
Thread model: posix
gcc version 3.1 20020202 (experimental)

The prog works (i.e. it doesn't segfault) on Linux.

This is, what i get with dbx ./bug core:

=>[1] __sigprocmask(0x0, 0xffbeed30, 0x0, 0xffffffff, 0xffffffff, 0x0), at 0xfebd9d18
  [2] _resetsig(0xfebec9ac, 0x0, 0x0, 0x0, 0x210bc, 0x210c0), at 0xfebcf354
  [3] _sigon(0xfebf42c0, 0xfebf42a0, 0x210b8, 0xffbeee04, 0x6, 0xfea4df94), at 0xfebceb10
  [4] _thrp_kill(0x0, 0x1, 0x6, 0xfebec9ac, 0x21040, 0x9), at 0xfebd18e4
  [5] abort(0xfeab5ad4, 0xfee83160, 0xff154a80, 0x0, 0x0, 0x0), at 0xfea395d0
  [6] _Jv_ThrowSignal(0xfe984fa8, 0xff1c9f50, 0x0, 0x0, 0x0, 0x0), at 0xfee66984
  [7] _Z10catch_segviP7siginfoPv(0xb, 0xffbef448, 0xffbef190, 0xfebec9ac, 0x210c8, 0x210a8), at 0xfee669c4
  [8] 0x0(0x25b68, 0xff1564dc, 0x0, 0xff1700b8, 0x0, 0x0), at 0xffffffffffffffff
  [9] _Z10wrap_valueIN4java4lang5ClassEEPT_P10_Jv_JNIEnvS4_(0x25b68, 0xff1564dc, 0xfe983140, 0xfee8d49c, 0xffbef608, 0xff0000), at 0xfee6b3f8
  [10] _Z17_Jv_JNI_FindClassP10_Jv_JNIEnvPKc(0xfe96c118, 0x10ca8, 0xfee6938c, 0x20f1e, 0xfeab5ad4, 0xfeab9708), at 0xfee69478
  [11] main(0x1, 0xffbef72c, 0xffbef734, 0x20ef8, 0x0, 0x0), at 0x10b90

Stack level 8 seems strange to me. Shouldn't this be _Jv_JNI_NewLocalRef (env, (jobject) value))?

Thanks a lot in advance,
Martin.

-- 
The early bird catches the worm. If you want something else for       
breakfast, get up later.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]