Legacy Issue Number: 19264
Source: Real-Time Innovations ( Sumant Tambe)
For Union Types the xTypes spec does not handle the following two cases:
What is the criteria to select a value for the discriminator when a default case is specified?
What happens if a default case label is specified when the set of case labels completely covers all the possible values for the discriminator.
Note: This information is stated in section 1.9 (Mapping for Union) of the IDL to Java spec.
If the branch corresponds to the default case label, then the simple modifier for that
branch sets the discriminant to the first available default value starting from a 0 index
of the discriminant type.
It is illegal to specify a union with a default case label if the set of case labels
completely covers the possible values for the discriminant*. It is the responsibility of
the Java code generator (e.g., the IDL complier, or other tool) to detect this situation
and refuse to generate illegal code.
Proposal to determine what is the default value for a union discriminator:
If there is no default case value, the default discriminator value is the lowest value associated with any union member. If the discriminator type is an enumeration, the value is the enumerator with the lowest ordinal.
if there is default case value:
For integer, boolean, byte, char, wchar: The default discriminator value is the first available value starting from a 0 value of the discriminant type.
For enumerations: The default discriminator value is the first enumerator in the order declared in the enumeration that is not associated with any case value.
Reported: DDS-XTypes 1.1 — Thu, 27 Feb 2014 05:00 GMT
Disposition: Duplicate or Merged — DDS-XTypes 1.2
Updated: Thu, 22 Jun 2017 16:42 GMT