[zeromq-dev] Java API is not notifed of C++ assert failures.

Vladimir & Mihaela puiuvlad at optonline.net
Tue Apr 14 03:44:32 CEST 2009


Here is the modified Jzmq.java file. Nothing has changed in the C++ layer. I
have put the wrapper for the api_thread_t inside class Jzmq as inner class
JApiThread. I hid the createQueue methods on the Jzmq object and exposed
them in the JApiThread object.

The usage is this:

    _jzmq = new Jzmq(zmqHost, 2);

    Jzmq.JApiThread api = _jzmq.getApiThreadProxy();
    _xId = api.createExchange("E", Jzmq.SCOPE_LOCAL, host);
    api.bind("E", "disQ");

and in a different thread:

    Jzmq.JApiThread api = _jzmq.getApiThreadProxy();
    api.createQueue("Q", Jzmq.SCOPE_LOCAL, _host);
    api.bind("disX", "Q");
    byte[] msg = api.receive();

Finally, "I release the code (C++ and Java) under MIT license."


-----Original Message-----
From: Vladimir & Mihaela [mailto:puiuvlad at optonline.net]
Sent: Monday, April 13, 2009 6:44 AM
To: Martin Sustrik
Cc: zeromq-dev at lists.zeromq.org
Subject: RE: [zeromq-dev] Java API is not notifed of C++ assert

Sorry, my mistake. I was delegating createExchange to createQueue and that
caused my problem. Malo's suggestion helped (thanks, Malo). I will send the
final code tonight. Vladimir

-----Original Message-----
From: Martin Sustrik [mailto:sustrik at fastmq.com]
Sent: Saturday, April 11, 2009 3:21 PM
To: Vladimir & Mihaela
Cc: zeromq-dev at lists.zeromq.org
Subject: Re: [zeromq-dev] Java API is not notifed of C++ assert


> If I use the old Jzmq methods (with the thread id) then all's OK, but if I
> use the wrapper methods (which ultimately get translated into the same
> to the old methods) the second process dies when trying to bind.

IIRC you are working on Win32 and I assume the process dies without a
diagnostic message.

We've been looking into the problem last week and found out that
standard Win32 assert macro misbehaves when used within JNI.

It aborts the process, as it should, however, it doesn't print the
message. It's completely incomprehensible why it is so, as printing to
stdout works OK, printing to stderr works OK and CrtDbgReport works OK
as well. assert internally calls undocumented _wassert function. There's
no source available for that one afaics.

To fix the problem I've replaced all 930 (sic!) asserts in
libzmq/libjzmq code by proprietary zmq_assert. Developing for Windows
can make even a strong man cry :(

Anyway, if you get the trunk, you should get a meaningful message when
the process fails. The message would help us to track the problem down.
(Note that Java API have changed slightly since version 0.5, so when
you'll switch to trunk you will have to adjust your code.)

Let us know how it goes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Jzmq.java
Type: application/octet-stream
Size: 4439 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20090413/8aaa21c7/attachment.obj>

More information about the zeromq-dev mailing list