Where does an introspector look for properties into a Java Bean?

Hi

I have looked at the source code of java.beans.Introspector and a lot of classes in the package java.beans, I haven’t succeeded in finding the source code of the default introspection used when the programmer does not provide a custom bean info for a class, do you know where it is?

According to the specification of Java Beans, a setter should not return any value. However, some people on StackOverflow pretend that the implementation of this mechanism is quite laxist and allows setters to return a value. Is it true? Should I rely on such a behaviour? In my humble opinion, I should not rely on this behaviour as there are multiple implementations of the JVM and some APIs based on Java Beans might expect setters to return nothing.

I would imagine the introspector looks at the signature, and if it doesn’t return void, it isn’t a proper setter. That said, 1) BeanInfo might convince it to use a different signature and 2) a lot of tools ignore the javabeans spec, don’t bother using java.beans.Introspector, and just look for “getFoo/setFoo” methods directly and in that case probably don’t care about anything but the name.

Hi

By default, if you don’t provide any custom bean info, XMLEncoder ignores setters not returning void, Renanse made a small test to check that, you’re right, thanks.