From: Joe Hoffert <jhoffert@dre.vanderbilt.edu>
To: Andrew Haley <aph@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: GCJ .jar to .so with native method
Date: Tue, 04 Dec 2007 19:04:00 -0000 [thread overview]
Message-ID: <1196795057.3362.83.camel@sirion.dre.vanderbilt.edu> (raw)
In-Reply-To: <18261.39111.838608.411440@zebedee.pink>
Hi, Andrew.
On Tue, 2007-12-04 at 18:13 +0000, Andrew Haley wrote:
> Joe Hoffert writes:
>
> > You're right that using gcj or g++ to link doesn't matter. The
> > difference with what I was doing before was the compiler/linker
> > options.
>
> Can you let us know what in our instructions didn't give you the
> information you needed? It might help us improve our documentation.
I didn't see anything in gcj.pdf that talks about conflicting compiler
or linker options. The options that gave me trouble are the
-fvisibility=hidden and -fvisibility-inlines-hidden. When I take these
out the program compiles and links. I think I'll be fine without these
options.
Now the program is aborting with the first "Java" call. I'm simply
calling a method specified by the gcjh generated header file. The code
is aborting from initializeClass:
(gdb) where
#0 0x00110402 in __kernel_vsyscall ()
#1 0x0084bfa0 in raise () from /lib/libc.so.6
#2 0x0084d8b1 in abort () from /lib/libc.so.6
#3 0x02da0d38 in _Jv_Throw () from /usr/lib/libgcj.so.8rh
#4 0x02ddc888 in java::lang::Class::initializeClass ()
from /usr/lib/libgcj.so.8rh
#5 0x02dddd36 in _Jv_InitClass () from /usr/lib/libgcj.so.8rh
#6 0x00145a44 in
multishot.examples.RicochetApp.initialize(java.lang.String,
java.lang.String, int, java.lang.String)multishot.examples.RicochetApp
()
from /home/jhoffert/Ricochet/trimmed/c
++-java/linux-jdk1.5/libricochet.so
#7 0x08048ec2 in main (argc=4, argv=0xbfca39e4) at
RicochetAppMain.cpp:95
I also saw in the documentation (i.e., chapter 12, section 12.7 of
gcj.pdf) that the C++ compiler doesn't invoke extra code to make sure a
class is initialized. The method I'm calling is static. I added code to
try and initialize the class:
JvInitClass(&multishot::examples::RicochetApp::class$); // this is
line 87
but the program aborts in that call:
(gdb) where
#0 0x02da2610 in _Jv_Linker::verify_class ()
from /usr/lib/libgcj.so.8rh
#1 0x02da4762 in _Jv_Linker::wait_for_state ()
from /usr/lib/libgcj.so.8rh
#2 0x02ddc6b4 in java::lang::Class::initializeClass ()
from /usr/lib/libgcj.so.8rh
#3 0x02dddd36 in _Jv_InitClass () from /usr/lib/libgcj.so.8rh
#4 0x0804908d in JvInitClass (cls=0x804a690)
at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c
++/4.1.2/gcj/cni.h:30
#5 0x08048f7e in main (argc=4, argv=0xbfe54394) at
RicochetAppMain.cpp:87
Is there I'm not doing when calling JvCreateJavaVM? I called this
initially with an empty JvVMInitArgs argument and the program aborted so
I added the -D option for the .jar file. This seems redundant to me but
I wasn't sure what else to try. This argument is what I pass when I'm
using the invocation API.
I appreciate your time but don't want to waste it. Please point me to
documentation, examples, or tutorials if you don't have time to keep
helping me.
Thanks!
-Joe
> > One more question. Is there any advantage to converting a .jar
> > library to a .so library and using it as opposed to simply using
> > the original .jar file with the Java invocation API and the JNI to
> > call back to C++ from Java? I thought I would get a performance
> > increase with using the .so library but perhaps there are no
> > substantive differences between the two approaches.
>
> You will probably get a performance increase, yes. In particular,
> calling native code from compiled code is very quick.
>
> Andrew.
>
next prev parent reply other threads:[~2007-12-04 19:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-04 13:20 Joe Hoffert
2007-12-04 13:28 ` Andrew Haley
2007-12-04 14:06 ` Joe Hoffert
2007-12-04 15:16 ` Andrew Haley
[not found] ` <1196782972.3362.22.camel@sirion.dre.vanderbilt.edu>
2007-12-04 15:59 ` Andrew Haley
2007-12-04 16:35 ` Joe Hoffert
2007-12-04 16:43 ` Andrew Haley
2007-12-04 17:47 ` Joe Hoffert
2007-12-04 18:06 ` David Daney
2007-12-04 18:13 ` Andrew Haley
2007-12-04 19:04 ` Joe Hoffert [this message]
2007-12-05 11:02 ` Andrew Haley
[not found] ` <1329.129.59.82.132.1196873567.squirrel@www.dre.vanderbilt.edu>
2007-12-05 17:32 ` Andrew Haley
2007-12-05 17:42 ` Andrew Haley
2007-12-05 17:56 ` jhoffert
2008-01-10 21:39 ` Joe Hoffert
2008-01-10 21:46 ` Andrew Haley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1196795057.3362.83.camel@sirion.dre.vanderbilt.edu \
--to=jhoffert@dre.vanderbilt.edu \
--cc=aph@redhat.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).