[ImageJ-devel] imagej-loader / dlopen args

Lee Kamentsky leek at broadinstitute.org
Wed Mar 18 15:29:26 CDT 2015


On Wed, Mar 18, 2015 at 4:32 PM, Johannes Schindelin <
johannes.schindelin at gmx.de> wrote:

> Hi Lee,
> On 2015-03-18 14:47, Lee Kamentsky wrote:
>  I'm programming "monkey see, monkey do" style. I have very little idea
>> what
>> I'm doing, trying to replicate the logic for mac loading dylibs in
>> imagej-loader.
>> I've gotten pretty far, but at the end, I'm seeing the error,
>> "JavaNativeFoundation: GetGlobalVM: JNI_GetCreatedJavaVMs() failed to get
>> any VM" when I start an AWT app.
> Do you expect a JVM to be running already? If not, you should [create one](
> https://github.com/imagej/imagej-launcher/blob/
> 3e061521a/src/main/c/ImageJ.c#L307-L322).
>  I am guessing that this is why you dlopened libjli here
>> <https://github.com/imagej/imagej-launcher/blob/master/
>> src/main/c/ImageJ.c#L264>.
> Heh, I have to admit that I did not remember at all why I did that.
> Happily, even I learned to write kick-ass commit messages, and I also
> learned the awesomeness of the `Blame` button on GitHub:
> https://github.com/imagej/imagej-launcher/blame/master/
> src/main/c/ImageJ.c#L264 (I vaguely remember writing that commit message
> after spending something between twenty and thirty super-focused hours on
> hunting down this bug, that was not really fun, that one hunt).
>  I do the same, but (so far) with Python's ctypes.CDLL. That doesn't let
>> you
>> specify RTLD_LAZY as a dlopen mode. So, I think that's the big difference
>> between how you do things and how I do them. My first question is whether
>> RTLD_LAZY is needed as the mode. My second question is why you needed to
>> load libjli.dylib in the first place and, if you might grant me a third
>> wish, my third question is whether you've seen this error before.
> The JLI library is only needed for forward compatibility, so that MacOSX
> does not annoy the user by a "Do you want to install Java 6?" popup.
> And yes, I have seen an error like that before, but only when trying to
> attach to a running JVM from within Matlab (Matlab's very own GUI is
> written in Java... so there is already a JVM running in a Matlab instance
> although it is a bit tricky to get at it under certain circumstances, but
> it is impossible to run two Oracle JVMs in the same process in any case).
>  Thanks in advance, Mr. Wizard.
> Sorry, oh ye mighty Python God, I fear my input was not really helpful to
> your cause. But maybe you have a project for me to clone, with instructions
> that might let this poor Python pilgrim reproduce the issue?
> Ciao,
> Dscho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20150318/c50c0eff/attachment.html>

More information about the ImageJ-devel mailing list