-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.3.0
-
sparc
-
solaris_2.5
Name: dsC58869 Date: 06/29/99
This bug was introduced in Kestrel.
The constructor PropertyDescriptor(String propName, Class beanClass)
works wrong if beanClass does not contain getter.
JavaDoc says:
_____
Constructs a PropertyDescriptor for a property that follows the standard Java convention
by having getFoo and setFoo accessor methods.
^^^^^^^^^^^^^^^^^^^^^^^^^^
_____
So, it should throw IntrospectionException (JDK1.2.2), but it accepts wrong bean.
Here is an example to demonstrate this bug:
import java.beans.*;
public class Test01 {
public static void main (String[] args) {
try {
PropertyDescriptor pd = new
PropertyDescriptor("noGetter",WrongBean.class);
} catch (IntrospectionException e) {
e.printStackTrace();
System.out.println("OKAY");
return;
}
System.out.println("Failed");
return;
}
}
class WrongBean {
int noGetter;
public void setNoGetter (int noGetter) {
this.noGetter = noGetter;
}
}
Here is output:
%java -fullversion
java full version "JDK-1.3-I"
%java Test01
Failed
%
%java -fullversion
java full version "JDK-1.2.2-U"
%java Test01
java.beans.IntrospectionException: No method "getNoGetter" with 0 arg(s)
at java.beans.Introspector.findMethod(Introspector.java, Compiled Code)
at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java, Compiled Code)
at Test01.main(Test01.java, Compiled Code)
OKAY
------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4247526 kestrel H fails api/java_beans/PropertyDescriptor/descriptions.html#Ctor1
-
- Closed
-