Hi,
Here are the symptoms of a problem I'm facing. Has anyone faced such
an issue and managed to solve it?
To me, all the symptoms seem to point to the Sun Java interpreter
being the culprit. I basically wrote some code to create a shared
library(say X.so) that has a single function that accesses more
libraries to get some stuff done. I then wrote a Java program to
access X.so using JNI. Here are the symptoms,
i) when I run a C++ program that opens X.so, and executes the function
exposed by it, it works fine. The entire function runs correctly, and
gives the right output.
ii) when I compile and link the source code of X.so statically so that
it creates an executable instead of a ".so", and run the executable,
again the executable runs fine
iii) but when I use the Java program to load X.so, and execute the
exposed function, it loads the library successfully, starts executing
the code in it too (displays some output), but the function returns
with a failure when it attempts to create an instance of an object
from another shared library.
iv) what strengthened my view even further today is that when the SAME
Java class is executed using the 'gij' interpreter isntead of Sun's
'java' interpreter, it runs perfectly, loading the shared library X.so
and executing everything nicely...
Which probably means that there is an incorrect call or incorrectly
resolved symbol somewhere in the 'java' interpreter, which is causing
the problem...
Can any one help?
Tahir.
Andrew Thompson - 07 Sep 2004 20:36 GMT
> Here are the symptoms of a problem I'm facing. Has anyone faced such
> an issue and managed to solve it?
Funny you should say that, some guy over
on c.l.j.programmer was asking the same thing,
maybe if you watch that converstaion you'll get
your answer. He's already got a response.
Oh, and please refrain from multi-posting.
<http://www.physci.org/codes/javafaq.jsp#netiquette>

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
hitectahir - 19 Sep 2004 13:57 GMT
> > Here are the symptoms of a problem I'm facing. Has anyone faced such
> > an issue and managed to solve it?
[quoted text clipped - 6 lines]
> Oh, and please refrain from multi-posting.
> <http://www.physci.org/codes/javafaq.jsp#netiquette>
Hi,
Sorry for the multi-post. It was more out of frustration than anything
else... But I finally got it to work and discovered the error causing
the problems...
The problem that was occurring was that I was loading a POOL library
using System.loadLibrary() in the Java part of the code. Now this
library was required by the C++ code as well, but perhaps since it was
already loaded in the JVM, it wasnt loaded by the C++ part at runtime.
As a result, the C++ portion was unable to find the library in its own
address space (I think), and was unable to use the library.
I hope this helps any future JNI programmers
Tahir.
Andrew Thompson - 19 Sep 2004 15:05 GMT
> Sorry for the multi-post. ..
I forgive you but..
(snip explanation of solution)
> I hope this helps any future JNI programmers
..are you now intending to post the solution
to the other two threads you started?
<http://google.com/groups?as_ugroup=comp.lang.java*&as_usubject=JNI+works+with+gi
j+but+not+java>

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane