This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: GCJ .jar to .so with native method


Andrew Haley writes:
 
 > 
 > The problem occurs when your program calls
 > java.lang.System.loadLibrary(java.lang.String)void with the arg
 > "ricochet-jni".  The library isn't there, so System.loadLibrary fails.
 > I don't know why it doesn't print a stack trace at that point: it
 > should.  I'll investigate.

Ha!  Stupid me!  

Yes, I do know why your stack trace isn't being printed: you need to
wrap your entire main in a handler, like this:

  try
    {

      ...

      ra->run ();
    }
  catch (::java::lang::Throwable *ex)
    {
      ex->printStackTrace ();
    }

You also need

      JvAttachCurrentThread (NULL, NULL);

That's in the docs, too.

You'll then get

zorro:tmp $ LD_LIBRARY_PATH=.:/home/aph/gcc/trunk/install/lib64/:. ./RicochetApp
Status from JvCreateJavaVM call is 0
Before call to JvInitClass
java.lang.UnsatisfiedLinkError: libricochet-jni: libricochet-jni.so: cannot open shared object file: No such file or directory
   at java.lang.Runtime._load(natRuntime.cc:188)
   at java.lang.Runtime.loadLibrary(Runtime.java:655)
   at java.lang.System.loadLibrary(System.java:608)
   at multishot.examples.RicochetApp.<clinit>(libricochet.so)
   at java.lang.Class.initializeClass(natClass.cc:780)

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903


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