This is noy exactly a Java question, it's more that I need a second opinion.
From Javadoc, when you invoke a getMethods() on a Class, methods are returned in no particular order, randomly ordered in fact.
Not good, but tolerable. Now imagine we have a "bean" with a property of type String with its get and set method and in additon a set method that accepts a char for some dark reasons.
Let's serialize this. In my opinion, the property should be serialized as a String, discarfind the char setter. I'd even understand that the propery were ignored, as is not fully standard.
To my surprise, I found that Introspector, when looking for the property, sometimes shows is, sometimes not.
The reason: it get the methods and iterate with them. If it first finds the char one, nice, it gets overwritten by the String one and the property is serialized.
If the String is first, it gets overwritten, there's an incompatibility between get and set methods and the property just fades.
Is just me or do you think this is almost a bug from Java?
Cheers,
Dian
From Javadoc, when you invoke a getMethods() on a Class, methods are returned in no particular order, randomly ordered in fact.
Not good, but tolerable. Now imagine we have a "bean" with a property of type String with its get and set method and in additon a set method that accepts a char for some dark reasons.
Let's serialize this. In my opinion, the property should be serialized as a String, discarfind the char setter. I'd even understand that the propery were ignored, as is not fully standard.
To my surprise, I found that Introspector, when looking for the property, sometimes shows is, sometimes not.
The reason: it get the methods and iterate with them. If it first finds the char one, nice, it gets overwritten by the String one and the property is serialized.
If the String is first, it gets overwritten, there's an incompatibility between get and set methods and the property just fades.
Is just me or do you think this is almost a bug from Java?
Cheers,
Dian