Issue 1752: mapping of IDL enumerations to java (java-rtf) Source: (, ) Nature: Revision Severity: Significant Summary: Summary: he current mapping of IDL enumerations to Java relies on there being one and only one instance of an enum. The instance is held as a static variable in the enumeration class. Since there is only one instance, identity comparisons are used in comparing enums and the enumeration value class does not implement equality or hash methods based on the value of the enum. Resolution: Close, no action Revised Text: Actions taken: July 29, 1998: received issue June 4, 1999: closed issue Discussion: End of Annotations:===== Return-Path: Date: Wed, 29 Jul 1998 13:43:59 -0400 From: www To: juergen@omg.org, web-incoming@omg.org Subject: WWW Form output Name: Bruce Schuchardt Company: GemStone Email: bruce@gemstone.com Notification: Yes Specification: Mapping of OMG IDL to Java Section: 23.6 Formal #: 98-01-16 Version: 2.2 Revision_Date: December 1997 Page: 14 Nature: Revision Severity: Significant full_desc: The current mapping of IDL enumerations to Java relies on there being one and only one instance of an enum. The instance is held as a static variable in the enumeration class. Since there is only one instance, identity comparisons are used in comparing enums and the enumeration value class does not implement equality or hash methods based on the value of the enum. This assumption appears to fail if the enumeration value class is garbage collected in the course of execution. When the value class is reloaded, new objects are created and placed in the static variables holding the enum instances. These new objects do not have the same hash values as the previous enum instances, and comparisons fail to work. Another scenario where we've seen this problem arise is in an application that is storing enum objects in a persistent object store and later comparing them with the objects in the enumeration value class at runtime. Unless the class and its static variables are also made persistent, the unique enum value scheme falls apart. The class gets loaded by the Java VM and new enum objects are created. These are later compared with persistent enum objects by the application and the comparisons fail. Please consider revising the mapping of enums to require generation of equality and hash methods that are class and value based. Application developers should then be advised to use equals() when comparing enum objects. submit: Submit Issue Report