This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygwin crashes when loading DLL


Thanks Alan. I have tried this out and it narrows the problem down somewhat.
It seems to me that my problem is that I am running java from a rxvt and/or
xterm. I'll bullet some observations:

 * I normally enter commands into a bash shell running under a rxvt window.
 * When I ran the sample code from http://www.whitecaps.net/jni/expr.jar
(here in known as expr code), it worked as expected. This is a strange
exception that I'll comeback to.
 * Going back to the previous examples I was using, I rebuilt the dll in the
same way as the build.xml from the expr code does.
 * Not using ant in this instance, I ran the example by entering the java
command line directly.
 * The error changed in nature, but it was still a no-go.
 * Curiosity aroused, I went back to the expr code, and tried entering in
the java command line (as per build.xml) into the rxvt and indeed, it failed
in the same way.
 * I started up a Windows cmd prompt, copied and pasted the command-line,
and it worked as it did under the ant build.
 * I started up a cmd prompt based Cygwin session, copied and pasted the
command-line, and it worked as it did under the ant build.
 * Doing the same with my previous example worked as well.
 * Doing the same under Cygwin native xterm, in an xession failed in the
same was as rxvt.

So, I think it's safe to say, the problem has something to do with the
terminal the Win32 native java interpreter is running under, and perhaps how
cygwin handles pseudo-terminals??? But strangely, when run from within an
ant process as mentioned, it worked ok. I just don't get it.

Regards,
Shaddy



----- Original Message -----
From: "Alan Thompson" <athompson@alphatech.com>
To: "Shaddy Baddah" <Shaddy_Baddah@hotmail.com>; <cygwin@cygwin.com>
Sent: Thursday, May 22, 2003 5:54 AM
Subject: Re: cygwin crashes when loading DLL


> Shaddy -
>
> I have uploaded some sample code to http://www.whitecaps.net/jni/expr.jar
.  The expr/jni/hello directory contains a "standard" JNI example (where
java calls into a C++ program) that works on Cygwin and has an ant buildfile
(I assume you are using ant.....if not, get it and you'll be happy).  The
expr/jni/invoke directory has an example using the JNI invocation interface,
where a C++ program creates a JVM to print "hello".  Output is pasted below.
>
> Also, if you haven't seen it, look at the excellent writeup on JNI for
Cygwin at http://www.inonit.com/cygwin/
>
> Alan Thompson
>
>
****************************************************************************
************************
>
> cd expr/jni/hello
> ant
>
> Buildfile: build.xml
>
> clean:
>
> init:
>     [mkdir] Created dir: C:\export\expr\jni\hello\bin
>     [mkdir] Created dir: C:\export\expr\jni\hello\gen
>
> javaSrcComp:
>     [javac] Compiling 2 source files to C:\export\expr\jni\hello\bin
>
> ctags:
>
> javaComp:
>
> javah:
>      [echo] building *_jni.h...
>
> ccComp:
>     [mkdir] Created dir: C:\export\expr\jni\hello\ctmp
>      [copy] Copying 2 files to C:\export\expr\jni\hello\ctmp
>
>      [echo] Compiler Name:     g++
>      [echo] Compiler Version:
>      [exec] g++ (GCC) 3.2 20020927 (prerelease)
>      [exec] Copyright (C) 2002 Free Software Foundation, Inc.
>      [exec] This is free software; see the source for copying conditions.
There is NO
>      [exec] warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
>
>
>      [echo] Compiling for Cygwin...
>      [echo] Linking for Cygwin...
>    [delete] Deleting directory C:\export\expr\jni\hello\ctmp
>
> build:
>
> go:
>      [java] loading library
>      [java] calling sayHello
>      [java] Hello World from C!
>      [java] trying to get array
>      [java] answerArrayObj=0x8b74cc
>      [java] trying to get elem[0]
>      [java] elem0=0x8b74d0
>      [java] elemClass=0x8b74d4
>      [java] valueFieldID=0x22
>      [java] trying to get valueObj
>      [java] valueObj=0x8b74d8
>      [java] trying to get string chars
>      [java] initial string = 'initial value from java'
>      [java] trying to set string chars
>      [java] newJString=0x8b74dc
>      [java] getting constructor MID
>      [java] msgCID=0x8bbf18
>      [java] calling constructor
>      [java] trying to set string chars
>      [java] newJString2=0x8b74e4
>      [java] setting newElem value
>      [java] trying to set elem[1]
>      [java] sayHello() returning
>      [java] sayHello done
>      [java] answer[ 0 ] = 'Hello World from C!'
>      [java] answer[ 1 ] = 'the new C string value'
>      [java] answer[ 2 ] = 'initial value from java'
>
> clean:
>    [delete] Deleting directory C:\export\expr\jni\hello\bin
>    [delete] Deleting directory C:\export\expr\jni\hello\gen
>
> BUILD SUCCESSFUL
> Total time: 9 seconds
>
>
>
>
>
>
> cd expr/jni/invoke
> ant
>
> Buildfile: build.xml
>
> clean:
>
> init:
>     [mkdir] Created dir: C:\export\expr\jni\invoke\bin
>
> javaComp:
>     [javac] Compiling 1 source file to C:\export\expr\jni\invoke\bin
>
> ccCygwin:
>      [echo] Compiling C++ for Cygwin
>
> dlltoolCygwin:
>
>
> ccCompCygwin:
>
>      [echo] Compiler Name:     g++
>      [echo] Compiler Version:
>      [exec] g++ (GCC) 3.2 20020927 (prerelease)
>      [exec] Copyright (C) 2002 Free Software Foundation, Inc.
>      [exec] This is free software; see the source for copying conditions.
There is NO
>      [exec] warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
>
>
>
> ccSun:
>
> ccComp:
>
> build:
>
> go:
>
> goCygwin:
>      [exec] <C++> program starting
>      [exec]   <java> Hello World from C!
>      [exec] <C++> program terminating
>
> goSun:
>
> clean:
>    [delete] Deleting directory C:\export\expr\jni\invoke\bin
>
> BUILD SUCCESSFUL
> Total time: 12 seconds
>
>
> At 02:12 PM 5/20/2003 +0800, Shaddy Baddah wrote:
>
> >I am having exactly the same problem trying to build Java JNI's under
Cygwin
> >(actually, they are the examples from the 'GNU Win32 related projects'
> >page ). Robert Bercik, did discover a fix for the problem you
encountered?
> >
> >I have more weirdness to describe. I can run the Java app that loads in
the
> >JNI under a regular Windows 2000 'cmd' window and it works fine,
regardless
> >of whether there is a cygwin1.dll active or not. But if I try and run the
> >same Java app from within a cygwin shell, it crashes in the same way.
There
> >must be a simple explanation/fix to this one. Help would be greatly
> >appreciated.
> >
> >Thanks in advance,
> >Shaddy
>
>
>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]