Calling a Java function from C++ using CNI

Shaun Jackman
Tue Aug 10 05:42:00 GMT 2004

I have relentlessly trolled documentation and still have a persistent
SIGSEGV. I'd appreciate any help you can lend.

Welcome to HelloWorld. I'm sure you're all familiar with it:

public class HelloWorld {

public static void
        System.out.println( "Hello, world!");


#include "HelloWorld.h"

        return 0;

I generated HelloWorld.h using gcjh. I now run ./hello and SIGSEGV.
Here's some gdb output:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1087308448 (LWP 4389)]
0x406f9c5a in _Jv_equalUtf8Consts () from /usr/lib/
(gdb) bt
#0  0x406f9c5a in _Jv_equalUtf8Consts () from /usr/lib/
#1  0x4071c1a5 in _Jv_GetMethodLocal () from /usr/lib/
#2  0x4071e015 in java::lang::Class::initializeClass ()
   from /usr/lib/
#3  0x408ccf98 in _Jv_InitClass () from /usr/lib/
#4  0x407f61cf in java::lang::reflect::Modifier::isAbstract ()
   from /usr/lib/

What am I missing here? I suspect it's some allocation call in the C++
file. From what I've read though, calling Java static functions from
C++ does not require any explicit initialization. I'd be happy to
provide any further logs if I've been to relentless in my clipping.

Please cc me in your reply. Many thanks,

More information about the Java mailing list