I2JAV 1.1 NO IDEA Avatar
  1. OMG Issue

I2JAV11 — Enum mapping issue

  • Key: I2JAV11-122
  • Legacy Issue Number: 3669
  • Status: closed  
  • Source: Oracle ( Ken Cavanaugh)
  • Summary:

    The IDL to Java mapping spec (ptc/00-02-07) defines the
    mapping for IDL to Enums to Java. The generated enum
    class contains a method

    public static <TYPE> from_int( int i )

    However, the mapping spec does not call for an exception
    to be thrown if the parameter does not correspond to a
    valid enum for this enum type.

    ptc/00-02-08 defines the standard Java classes for
    the PIDL native types and the ORB portability interfaces.
    It includes several IDL enums in org.omg.CORBA:

    AttributeMode, CompletionStatus, DefinitionKind, OperationMode,
    ParameterMode, PrimitiveKind, SetOverrideType, and TCKind.

    All have signatures similar to:

    public static TCKind from_int( int val ) throws org.omg.CORBA.BAD_PARAM

    This is not compliant with the specification.

    If we look at the definition of BAD_PARAM, it is a SystemException, which
    extends java.lang.RuntimeException, so BAD_PARAM, like all system exceptions,
    is an unchecked java exception. Consequently there is no need to declare
    BAD_PARAM in the signature of the from_int methods. However, the behavior is
    useful and should be specified.

    I think this issue should be resolved with the following changes:

    1. Update ptc/00-02-08.zip to remove the "throws BAD_PARAM" clauses
    on all from_int methods for enums.

    2. Update ptc/00-02-07 section 1.7 as follows:

    replace the paragraph

    "The java class for the enum has an additional method from_int(),
    which returns the enum with the specified value."

    with

    "The java class for the enum has an additional method from_int(),
    which returns the enum with the specified value if the specified
    value corresponds to an element of the enum. If the specified
    value is out of range, a BAD_PARAM exception with a minor code
    of XXX is raised."

    where as usual XXX needs to be filled in with an appropriate minor code.

  • Reported: I2JAV 1.0 — Tue, 30 May 2000 04:00 GMT
  • Disposition: Resolved — I2JAV 1.1
  • Disposition Summary:

    No Data Available

  • Updated: Fri, 6 Mar 2015 21:38 GMT