XMLBeans
  1. XMLBeans
  2. XMLBEANS-205

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Version 2
    • Fix Version/s: Version 2.2.1
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      Does not related to platform

      Description

      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;
      }

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Denis Anisimov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development