D called from Java

Juan Jose Comellas jcomellas at gmail.com
Sun Aug 19 12:11:56 PDT 2007


I don't know if it's a showstopper with D because I really haven't tried it,
but it was a showstopper for me. There is a way to remap the signals used
by the JVM but it was very cumbersome and it still presented problems
because the signals generated by the JVM kept interrupting system calls and
I had to patch a lot of code that did not belong to me to make everything
work (I was embedding the JVM in an Asterisk module).

I finally moved the JVM out of the process and communicated with it via a
socket. This change solved all my problems and made the system much easier
to debug. It did introduce more latency but it was acceptable for what I
needed to do. Besides avoiding the difficult task of analyzing crashes
where the Java code was part of the call stack, I also could forget about
dealing with all the JVM/JNI quirks (e.g. if you load the same dynamic
library from your C code and from the Java code at the same time all hell
breaks loose, etc.)

To sum it up, I'd really think twice before embedding the JVM inside another
process again.


Frank Benoit wrote:

> Is this a show stopper for Java/D bridges on linux?
> 
> Strange is, that there are only these two signals available for
> application use.
> 
> Well you said 'same process'. I don't know, do you think it would be
> possible spawning a new process and use IPC? Sounds very expensive.




More information about the Digitalmars-d mailing list