Sun IDL compiler generates invalid Java code!

Sun IDL compiler generates invalid Java code!

Post by Wernk » Sat, 29 Apr 2006 21:56:43

This problem was noticed with Sun IDL compiler 3.1 and 3.2 but not with
3.0 and not with JacORB. CORBA IDL allows a switch variable of type
boolean whereas Java only allows integers (and enumerations).

The IDL code:
// ----------------- Start IDL --------------------------------
union OptType switch (boolean) {
case TRUE: short aNumber;

interface A {
void doit( in OptType opt );
// ------------------- End IDL ------------------------------

produces Java code that contains:

// ------------------- Start Java ------------------------------
private void verifyDefault( boolean value )
switch (value) {
case true:
throw new org.omg.CORBA.BAD_OPERATION() ;

// --------------------End Java -----------------------------

This is invalid as the variable 'value' of type boolean must not be
used as a switch variable.

Has anybody come across this problem? I could not find anything on the
web... why has nobody encountered this yet?