Issue 3200: Container/member name clashes (java2idl-rtf) Source: International Business Machines (Mr. Simon C. Nash, nash@hursley.ibm.com) Nature: Uncategorized Issue Severity: Summary: There is a commonly occurring name collision that is not covered by the current name mangling rules. This is demonstrated by the Java to IDL mapping of java.util.Date. The IDL generated gives a custom valuetype "Date" which contains an attribute "date", which is illegal in IDL. This problem is not unique to java.util.Date. More generally, this collision occurs whenever a Java interface or class being mapped to IDL contains a method or data member with the same name as the interface or class (using a case-insensitive comparison). For example, the following Java definitions cause this problem: Resolution: Revised Text: Actions taken: January 9, 2000: received issue May 16, 2006: closed issue Discussion: End of Annotations:===== Date: Sun, 09 Jan 2000 23:17:45 +0000 From: Simon Nash Organization: IBM X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 To: issues@omg.org CC: java2idl-rtf@omg.org Subject: Container/member name clashes Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=iso-8859-1 X-UIDL: `b`!!oXd!!Rk~!!?JQd9 There is a commonly occurring name collision that is not covered by the current name mangling rules. This is demonstrated by the Java to IDL mapping of java.util.Date. The IDL generated gives a custom valuetype "Date" which contains an attribute "date", which is illegal in IDL. This problem is not unique to java.util.Date. More generally, this collision occurs whenever a Java interface or class being mapped to IDL contains a method or data member with the same name as the interface or class (using a case-insensitive comparison). For example, the following Java definitions cause this problem: public interface Foo extends java.rmi.Remote { public void foo() throws java.rmi.RemoteException; } public interface Foo extends java.rmi.Remote { public void Foo() throws java.rmi.RemoteException; } public class Bar implements java.io.Serializable { public int bar; } public class Bar implements java.io.Serializable { public int Bar; } It has been suggested that the rule in the section 1.3.2.7 may apply to these cases. This rule talks about IDL names that are defined in the same IDL name scope. However, in these cases, two different (but colliding) IDL name scopes are involved: the scope in which the container is defined, and the scope within the container. If the 1.3.2.7 rule did apply, the first example above would be treated as follows: - the name of the IDL interface would be mangled to Foo_0 - the name of the IDL operation would be mangled to foo_ This does not seem satisfactory because of the mangling of the interface name. Also, this fails to deal with the second example above, in which the names do not differ in case. Therefore, the 1.3.2.7 rule should not apply and a new mangling rule is required. I propose that the following new section be added as 1.3.2.9, with the existing 1.3.2.9 renumbered to 1.3.2.10. 1.3.2.9 Container names that clash with their members In some cases, applying these rules for name mappings would generate OMG IDL with collisions between a container name and members of the container. This is because a Java member can have the same name as its container, but OMG IDL members cannot. The following rules are used to avoid such name collisions in OMG IDL: Container names are mapped unchanged (subject to other mangling rules). Java method, constant, or field names whose mapped name collides with the mapped name of their Java container are mapped with an additional trailing underscore. For example, if a remote Java interface Foo has a method foo, the OMG IDL interface is called Foo and the OMG IDL operation is called foo_. Simon -- Simon C Nash, Technology Architect, IBM Java Technology Centre Tel. +44-1962-815156 Fax +44-1962-818999 Hursley, England Internet: nash@hursley.ibm.com Lotus Notes: Simon Nash@ibmgb