Hi-

Apologize if this is a FAQ.  It seems that a "Hello World" JNI demo (see
below .sig) that uses iostreams for output give a SEGV on Linux and
FreeBSD, but not Windoze.  I didn't have the compiler to build a .dll to
see the latter case with my own eyes, but someone did it for me and it
works on Windoze fer shure, I've seen it in action.

Wonder how come?

Bob L.

P.S. Of course the example works when using <stdio.h> and printf(..).
-- 
Robert Lynch-Berkeley CA [EMAIL PROTECTED]
http://www.best.com/~rmlynch/
--
class test
{
   public native void display();

   static { System.loadLibrary("hello"); }

   public static void main(String[] args)
   {
      new test().display();
   }
}
---
/* hello.C */
#include <jni.h>
#include "test.h"
#include <iostream.h>

JNIEXPORT void JNICALL
Java_test_display(JNIEnv *env, jobject obj)
{
 cout << "Hello world!\n" << endl;
 return;
}
---
[user@ravel native]$ g++ -Wall -shared -fPIC
-I/usr/local/jdk1.1.6/include -I/usr/local/jdk1.1.6/include/genunix -o
libhello.so hello.C
---
[user@ravel native]$ LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH java test > err
2>&1
Aborted
[user@ravel native]$ more err
SIGSEGV   11*  segmentation violation
        stackbase=0xbffff668, stackpointer=0xbffff56c

Full thread dump:
    "Finalizer thread" (TID:0x40660208, sys_thread_t:0x413a4e0c,
state:R) prio=1
    "Async Garbage Collector" (TID:0x40660250, sys_thread_t:0x41383e0c,
state:R)
 prio=1
    "Idle thread" (TID:0x40660298, sys_thread_t:0x41362e0c, state:R)
prio=0
    "Clock" (TID:0x40660088, sys_thread_t:0x41341e0c, state:CW) prio=12
    "main" (TID:0x406600b0, sys_thread_t:0x81a4908, state:R) prio=5
*current thr
ead*
        test.main(test.java:9)
Monitor Cache Dump:
Registered Monitor Dump:
    Thread queue lock: <unowned>
    Name and type hash table lock: <unowned>
    String intern lock: <unowned>
    JNI pinning lock: <unowned>
    JNI global reference lock: <unowned>
    BinClass lock: <unowned>
    Class loading lock: <unowned>
    Java stack lock: <unowned>
    Code rewrite lock: <unowned>
    Heap lock: <unowned>
    Has finalization queue lock: <unowned>
    Finalize me queue lock: <unowned>
    Monitor IO lock: <unowned>
    Child death monitor: <unowned>
    Event monitor: <unowned>
    I/O monitor: <unowned>
    Alarm monitor: <unowned>
        Waiting to be notified:
            "Clock" (0x41341e0c)
    Monitor registry: owner "main" (0x81a4908, 1 entry)
Thread Alarm Q:
----------END msg.------------

Reply via email to