Issue 3669: Enum mapping issue (java-rtf) Source: Oracle (Mr. Ken Cavanaugh, nobody) Nature: Uncategorized Issue Severity: 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. Resolution: Revised Text: 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. Actions taken: May 30, 2000: received issue January 9, 2001: closed issue Discussion: End of Annotations:===== ate: Tue, 30 May 2000 22:52:00 -0700 (PDT) From: Ken Cavanaugh Reply-To: Ken Cavanaugh Subject: Enum mapping issue To: issues@omg.org Cc: Ken.Cavanaugh@eng.sun.com MIME-Version: 1.0 Content-MD5: 05sgQ61jmfZmcr6madYzqA== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc Content-Type: TEXT/plain; charset=us-ascii X-UIDL: n'6e9AL#"!cCTd9F?_!! This is an issue for the IDL to Java language mapping RTF. 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 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. Ken.