cygnus, egcs and jni bug ?

Kaveh Goudarzi km2@doc.ic.ac.uk
Thu May 13 17:30:00 GMT 1999


Hi,

	I'm trying to create a dll using egcs for use with Java but
find that functions returning double or float values don't work
properly.  That is in the conversion between C double to Java double
something goes wrong.  I was wondering if anyone else has had this
problem or it's peculiar to my setup.

	Sample code, setup and compile options follow.

thanks in advance,

Kaveh.

my setup is as follow :
   Win98 on a PII 300 MHz IBM ThinkPad
   Cygnus 20.1 
   chaman:~% gcc -v 
   Reading specs from E:\Unix\Cygnus20.1\cygwin-b20\H-i586-cygwin32\lib\gcc-lib\i586-cygwin32/egcs-2.91.60/specs
   gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
   chaman:~% java -version
   java version "1.2"
   Classic VM (build JDK-1.2-V, native threads)

   I've also applied the necessary patch to jni_md.h

	I've attatched the sample program which illustrates this.  The
Java class has three static native methods returnInt, returnFloat and
returnDouble.  The native C counterparts simply print the input
parameter and return it.  Running the code gives me :

chaman:~/java/jni% java Bug 10 3.14 3.141592
        C returning input parameter 10
Java Calling native returnInt ( 10 ) = 10
        C returning input parameter 3.14
Java Calling native returnFloat ( 3.14 ) = NaN
        C returning input parameter 3.14159
Java Calling native returnDouble ( 3.141592 ) = NaN
chaman:~/java/jni%


	Bug.java contains the java code, BugImp.c contains the C
sources.  I compile the code as follows :


	chaman:~/java/jni% make
        javac Bug.java
        javah  Bug
        gcc  -c  -DBUILDING_DLL=1 -D_DLL=1  -I. -Ie:/Java/jdk1.2/include -Ie:/Java/jdk1.2/include/win32 -g -Wall -O2 -o BugImp.o BugImp.c
        dllwrap --output-def bug.def --add-stdcall-alias --driver-name gcc   -o bug.dll BugImp.o -Wl,-e,__cygwin_noncygwin_dll_entry@12 -s
        Warning: no export definition file provided
        dllwrap will create one, but may not be what you want
        chaman:~/java/jni%
BugImp.c
Bug.java
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list