Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-128

Detect illegal overloaded JavaBeans properties methods (e.g. setters)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.8
    • 2.2.0
    • Core
    • None
    • iBatis 2.0.7

    Description

      ClassInfo keys setters by their names.

      private void addMethods(Class cls) {
      Method[] methods = cls.getMethods();
      for (int i = 0; i < methods.length; i++) {
      String name = methods[i].getName();
      if (name.startsWith("set") && name.length() > 3) {
      if (methods[i].getParameterTypes().length == 1)

      { name = dropCase(name); --> setMethods.put(name, methods[i]); setTypes.put(name, methods[i].getParameterTypes()[0]); }

      See http://cvs.sourceforge.net/viewcvs.py/ibatisdb/ibatis-dbl-2/src/com/ibatis/common/beans/ClassInfo.java?rev=1.8&view=markup

      So if you overload a method in your bean, you never know which one is going to be stored last in the map.

      With:

      public void setFeatureIDs(Set featureIDs)

      { this.featureIDs = featureIDs; }

      public void setFeatureIDs(List featureIDs)

      { this.featureIDs = new TreeSet(featureIDs); }

      I end up with the following error:

      Error setting property 'setFeatureIDs(java.util.Set=[2] $Proxy4 implements interface java.util.List)' of 'Part-20021'. Cause: java.lang.IllegalArgumentException: argument type mismatch Caused by: java.lang.IllegalArgumentException: argument type mismatch];

      See issue IBATIS-127 for debugging

      Attachments

        Activity

          People

            Unassigned Unassigned
            lacostej Jerome Lacoste
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: