using configuration file with extention interfaces restricted names of methods 
in interfaces
--------------------------------------------------------------------------------------------

         Key: XMLBEANS-205
         URL: http://issues.apache.org/jira/browse/XMLBEANS-205
     Project: XMLBeans
        Type: Bug
  Components: Compiler  
    Versions: Version 2    
 Environment: Does not related to platform
    Reporter: Denis Anisimov


Use .xsdconfig file.
Create two different interfaces with common method name. F.e. 
interface First {
void get();
}

interface Second {
void get();
}

Create two instructions in .xsdconfig for various bean neames from schema file 
for extending these interfaces with different handlers.
F.e.

<xb:extension for="test.First">
        <xb:interface name="schema.OneEntity">
            <xb:staticHandler>handlers.FirstHandler<xb:staticHandler>
        </xb:interface>
    </xb:extension>


<xb:extension for="test.Second">
        <xb:interface name="schema.AnotherEntity">
            <xb:staticHandler>handlers.SecondHandler<xb:staticHandler>
        </xb:interface>
    </xb:extension>

You will get error about method names collisions.
Compiler will tell to you that you have collide methods in SecondHandler and 
FirstHandler.

This is consequence of calling method void secondPhaseValidation() in 
BindingConfigImpl.java
And this is consequence wrong comparing algorithm for MethodSignatureImpl class.

Original equals()  and hashCode() methods don't perform comparing Handler 
names. So they use just method names and signature.

I suggest that those methods should be :

        private boolean interfacesEqual(MethodSignature signature){
            if ( getInterfaceName()==null ){
                if (((MethodSignatureImpl)signature).getInterfaceName()!= null 
){
                        return false;
                }
            }
            else if ( 
!getInterfaceName().equals(((MethodSignatureImpl)signature).getInterfaceName())){
                return false;
            }
            return true;
        }
        
        private boolean lightEqual(MethodSignature signature){
            if (!signature.getName().equals(getName()) )
                return false;

            String[] params = getParameterTypes();
            String[] msParams = signature.getParameterTypes();

            if (msParams.length != params.length )
                return false;

            for (int i = 0; i < params.length; i++)
            {
                if (!msParams[i].equals(params[i]))
                    return false;
            }

            return true;
        }

        public boolean equals(Object o)
        {
            if ( !(o instanceof MethodSignature))
                return false;

            MethodSignature ms = (MethodSignature)o;
                 
            if ( !interfacesEqual(ms ) ){
                return false;
            }
            return lightEqual( ms );

        }

        public int hashCode()
        {
            if (_hashCode!=NOTINITIALIZED)
                return _hashCode;

            int hash = getName().hashCode();
            
            if (getInterfaceName() != null) {
                                hash *= 19;

                                hash += getInterfaceName().hashCode();
                        }

            String[] params = getParameterTypes();

            for (int i = 0; i < params.length; i++)
            {
                hash *= 19;
                hash += params[i].hashCode();
            }

            _hashCode = hash;
            return _hashCode;
        }




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to