The OpenORB complier generates incorrect code for IDL
unions due to a mis-reading of the OMG's Java language
mapping.
The easiest way to explain this is with an example.
Consider the following IDL:
enum PayCode { CASH, CHECK, CREDIT_CARD };
union PaymentUnion switch(PayCode)
{
case CHECK: wstring check_number;
case CREDIT_CARD wstring credit_card_number;
};
In Java, you should be able to create a Union like this:
PaymentUnion payment = new PaymentUnion();
payment.__default(PayCode.CASH);
OpenORB creates the union, but it has no discriminator
set! With the code that OpenORB generates, you can
never tell what kind of union was created. According to
the Java language mapping v1.2, this is incorrect.
"Two default modifier methods, both named __default(),
are generated if there is no explicit default case
label, and the set of case labels does not completely
cover the possible values of the discriminant. The
simple method taking no arguments and returning void
sets the discriminant to the first available default
value starting from a 0 index of the discriminant type.
The second method takes a discriminator as a parameter
and returns void. BOTH OF THESE METHODS SHALL LEAVE THE
UNION WITH A DISCRIMINATOR VALUE SET, AND THE VALUE
MEMBER UNINITIALIZED."
I have patched my own OpenORB libraries with a tiny
patch (attached) that partly addresses the problem.
This patch is against Version 1.4.0
Patch against OpenORB 1.4.0