Home Help Center

Duplicate naming error while running slice2java

SameerreleSameerrele Member Sameer ReleOrganization: TRGProject: SOA
I would appreciate your help in understanding why this is not supported or what am I doing wrong.


My sample ice file is
[COLOR="Blue"]#ifndef TEST_ICE
#define TEST_ICE

module com
    module xxx
        module data
            module testsomething
                module service
                    interface TestSomething
                        int         getPoints();
                    interface TestSomethingHandler
                        TestSomething* getSomething(string name );



When I run slice2java I get following error

slice2java --output-dir c:\myproj\src c:\myproj\ice\test.ice
c:\\myproj\\ice\\test.ice:16: interface name `testsomething' cannot differ only in capitalization from enclosing module `testsomething' (first defined at c:\\myproj\\ice\\test.ice:11)
c:\\myproj\\ice\\test.ice:22: module name `TestSomething' is capitalized inconsistently with its previous name: `::com::xxx::data::testsomething'
c:\\myproj\\ice\\test.ice:22: `TestSomething' is not a type


  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    When you declared the module testsomething, you introduced that symbol into the enclosing scope. Slice does not permit you to introduce another symbol that differs only in capitalization (such as TestSomething) into the same scope, or into any nested scope. You'll need to rename the module or the interface.

    Take care,
    - Mark
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    By the way, initially, the rule what as that only immediately nested scopes could not have the same name because that can cause problems with constructors in many languages.

    Later, we made the rule more strict to prohibit scopes with the same name anywhere along the nesting chain because of C#: prior to C# 2.0, there was no way to anchor a symbol lookup at the global scope so, if you had nested scopes with the same name, anything outside the inner scope became inaccessible from within the inner scope.

    If we ever get to the point where we drop support for C# 1.0, we can relax this rule again. However, as a general point, I would still discourage having nested scopes with the same name as a matter of style--the potential for confusion this creates is almost certainly worse than having to use unique names for nested scopes.


  • SameerreleSameerrele Member Sameer ReleOrganization: TRGProject: SOA

    Thanks for the update and explaining me the reasoning behind the situation.

Sign In or Register to comment.