CNI Segfault

Daniel Hanlon daniel.hanlon@man.ac.uk
Mon Feb 16 15:10:00 GMT 2004


Hello,
I'm using gcj from gcc 3.3.2(20031218) on compiled with CFLAGS
-O3 -march=pentium4 -pipe -fomit-frame-pointer 
Whilst simple java classes work I'm getting a segmentation fault when I try to 
use CNI to call java from C++. For example
#include <iostream>
#include <string>
#include <gcj/cni.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
using namespace std;
main( int argc, char **argv ){
 string s;
 cin >> s;
 jstring jstr = JvNewStringUTF(s.c_str());
 java::lang::System::out->println(jstr);
}
compiled with 
g++ mytest2.cpp -lgcj -ggdb
and run in gdb segfaults with:
(gdb) step
JvNewStringUTF (bytes=0x804a1b4 "Hello") at cni.h:95
95 return _Jv_NewStringUTF (bytes);
(gdb) step
Program received signal SIGSEGV, Segmentation fault.
0x40398d82 in _Jv_equalUtf8Consts(_Jv_Utf8Const*, _Jv_Utf8Const*) ()
 from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libgcj.so.4
I get similar problems with other test code.
Hope I'm not missing something stupidly obvious. Any help would be greatly 
appreciated!
Cheers,
Daniel.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /