public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bryce McKinlay <bmckinlay@gmail.com>
To: Yi Lin <qinsoon@gmail.com>
Cc: java@gcc.gnu.org
Subject: Re: Interface gcj-compiled library with Java programs in a runtime (other than gij)?
Date: Tue, 14 Feb 2012 11:44:00 -0000	[thread overview]
Message-ID: <CALUNu-o7UfQb9a7GSNTPwHyJd3VCMXMsDKwLGtKyzYuNWYBkHQ@mail.gmail.com> (raw)
In-Reply-To: <4F3A44DB.4070605@gmail.com>

On Tue, Feb 14, 2012 at 11:26 AM, Yi Lin <qinsoon@gmail.com> wrote:
>
> Thank you all for the answers. I think I have some clue about CNI/JNI on the interface.
>
> But I still have doubt about how a shared library compiled from Java can be used by a) c/c++, b) Java code running on other JVM (not libgcj interpreter). I think b) is straightforwad if a) is possible.
>
> So for a), is calling a shared library of compiled java code any different than calling a shared library from normal c/c++ code? I have been spending two days exploring this and trying different approaches. My expectation is to load the compiled Java lib and use its method via dlopen, dlsym, etc. I guess another possibility is to use JvCreateVM(), and do everything in Java fashion. I don't have any success in either yet. Any hint would be very helpful so I could stop wasting time on a wrong track.


a) is certainly possible, using either JNI or CNI. Whichever one you
use, you need to call a couple of functions to initialize the Java VM
before you start calling your Java classes. You just need to make sure
libgcj gets loaded somehow, either using -lgcj or dlopen.
See here for a CNI example:
http://gcc.gnu.org/onlinedocs/gcj/Invocation.html#Invocation

b) "Should" work, but maybe you'd get conflicts with things like
signal handlers since you effectively have 2 Java runtimes running in
the same process.

      reply	other threads:[~2012-02-14 11:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-13  3:01 Yi Lin
2012-02-13  4:01 ` Brian Jones
2012-02-13  4:30   ` Yi Lin
2012-02-13 18:33     ` David Daney
2012-02-14  9:48       ` Andrew Haley
2012-02-14 10:31         ` Bryce McKinlay
2012-02-14 11:26           ` Yi Lin
2012-02-14 11:44             ` Bryce McKinlay [this message]

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=CALUNu-o7UfQb9a7GSNTPwHyJd3VCMXMsDKwLGtKyzYuNWYBkHQ@mail.gmail.com \
    --to=bmckinlay@gmail.com \
    --cc=java@gcc.gnu.org \
    --cc=qinsoon@gmail.com \
    /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).