JDK-4387842 : Introspector detects indexed property when get and set have conflicting types
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.1.6,1.3.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_7,windows_nt
  • CPU: x86,sparc
  • Submitted: 2000-11-09
  • Updated: 2001-07-25
  • Resolved: 2001-07-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta2Fixed
Related Reports
Duplicate :  
Description

Name: krC82822			Date: 11/09/2000


9 Nov 2000, eval1127@eng -- reproducible with 1.3.0.  See also 4168833.

java version "1.2.2"
Classic VM (build JDK-1.2.2-001, green threads, sunwjit)

Consider the following java bean with test routine.
The getProp() and setProp() methods conflict because
the former returns a float while the latter takes an int.
However, the Introspector detects both methods (this is
the bug).

It should reject one or the other -- as it does in the
case of a non-indexed property, where it rejects the
'get' method...

----test program------

import java.beans.*;
import java.lang.reflect.*;
public class BeanTest {
  public static void main(String[] args) throws Exception {
      BeanInfo info = Introspector.getBeanInfo(BeanTest.class);
      PropertyDescriptor[] props = info.getPropertyDescriptors();
      for (int i = 0; i < props.length; i++) {
        PropertyDescriptor prop = props[i];
        if (Class.class.equals(prop.getPropertyType())) continue;
        System.out.println("Property: type " + prop.getPropertyType());
        System.out.println("  read " + prop.getReadMethod());
        System.out.println("  write " + prop.getWriteMethod());
        if (prop instanceof IndexedPropertyDescriptor) {
          IndexedPropertyDescriptor iprop = (IndexedPropertyDescriptor)prop;
          System.out.println("  idx read " + iprop.getIndexedReadMethod());
          System.out.println("  idx write " + iprop.getIndexedWriteMethod());
        }
      }
  }
  public float getProp(int i) { return 0f; }
  public void setProp(int i, int x) { }
}


-----java output-----

Property: type null
  read null
  write null
  idx read public float BeanTest.getProp(int)      <=== should be null
  idx write public void BeanTest.setProp(int,int)
(Review ID: 102302) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2
14-06-2004

EVALUATION The essence of this bug is the same as 4277957. That bug will be driving the work. mark.davidson@Eng 2001-05-11 There is a lot more to this bug than previously thought. This bug touches upon aspects of the Beans specifcation that have not quite been cleared up. There is nothing in the Beans spec which states a precedence of read only or write only properties. - If a property has a setter method and a getter method but the type changes then what method has precedence? This is the essence of bug 4387842. public float getProp(int) public void setProp(int, int) The "prop" IndexedProperty can be either: - read only property of type float - write only property of type int Should setter methods have precedence over getter methods? The submitter is inferring that write only properties should have precedence. I think that the resolution of the legality of read only properties will resolve this. mark.davidson@Eng 2001-07-12
12-07-2001