I've been using the Blackdown JDK sucessfully for many weeks now.
I recently tried to invoke a java vm from an existing C application
using the JNI_CreateJavaVM call. It seems that simply linking
with libjava_g.so (where JNI_CreateJavaVM is defined) breaks calls
to open(). Here is a small example. The code calling JNI_CreateJavaVM
hadn't been called yet in my real app and isn't necessary to show
the problem. I checked using nm and libjava_g.so does define open().
The program works if you use:
cc jtest.c -o jtest -g && jtest
It fails with a segv at the first statement in __errno_location() if you use:
cc jtest.c -o jtest /src/java/jdk_linux/lib/linux/green_threads/libjava_g.so -g &&
jtest
This is jdk-1.1.6-v5-glibc-x86
I tried linking with -L/src/java/jdk_linux/lib/linux/green_threads -lsysresource_g
-lmath -lnet -lmmedia -lagent_g and even
/src/java/jdk_linux/lib/linux/green_threads/linuxlibs/libc.so.6 thinking there
was something linking from my system libc that should've come from a jdk lib but
no joy.
------------------------------------------------------------------------
/* jtest.c -- test interface to JVM */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
main(int argc, char *argv[]) {
int f = open("foo", O_CREAT | O_TRUNC, 0666);
printf("OK\n");
}
------------------------------------------------------------------------
Under gdb:
tetra:zclisp > gdb jtest
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (i386-redhat-linux), Copyright 1996 Free Software Foundation, Inc...
(gdb) list
1 /* jtest.c -- test interface to JVM */
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <fcntl.h>
6
7 main(int argc, char *argv[]) {
8 int f = open("foo", O_CREAT | O_TRUNC, 0666);
9 printf("OK\n");
10 }
(gdb) b main
Breakpoint 1 at 0x80485aa: file jtest.c, line 8.
(gdb) run
Starting program: /p/be/builds/zclisp/jtest
Breakpoint 1, main (argc=1, argv=0xbffff364) at jtest.c:8
8 int f = open("foo", O_CREAT | O_TRUNC, 0666);
(gdb) s
0x4009f15f in open () at ../../../../src/genunix/java/green_threads/src/iomgr.c:272
../../../../src/genunix/java/green_threads/src/iomgr.c:272: No such file or directory.
(gdb) s
0x400ce260 in __errno_location () at ../sysdeps/generic/errno-loc.c:28
../sysdeps/generic/errno-loc.c:28: No such file or directory.
(gdb) s
Program received signal SIGSEGV, Segmentation fault.
0x0 in ?? ()
-------------------------------------------------------------------------
Thanks for any ideas
Andy
--
Andrew Burgess
[EMAIL PROTECTED]
Available for software contract work: www.scruz.net/~cichlid