Implicit 'this' return for void methods
eirik.lygre at gmail.com
Thu Mar 27 22:05:23 UTC 2014
On Thu, Mar 27, 2014 at 10:02 PM, Jochen Theodorou <blackdrag at gmx.org>wrote:
> Am 27.03.2014 21:52, schrieb Eirik Lygre:
> The JavaBean specification, with it's "void setSomething()" functions
>> are fundamental to so many things Java that they will never go away
>> (good thing, too!).The suggested language change builds on top of that,
>> is beneficial to a large body of existing code and does not invalidate
>> any existing practices.
>> Hmm... isn't it a problem if I change "void setSomething()" to "MyClass
> setSomething()". In example, is that still a valid setter in terms of the
> JavaBean Spec? I might be wrong, but afaik there are bean based tools out
> there, not recognizing setters like that. At least I remember having such
> cases in the past. If I am right, then there is quite a chance of
> invalidating working code.
In terms of the JavaBeans specification, the setters must be void. If you
change the return type, it is no longer a JavaBeans setter, and many tools
will not see it. However, the above mentioned suggestion does not require a
change of the return type, so the bean methods and all their signatures
will be 100% backwards compatible.
With this suggested change, the only behavior that will change is that some
code which used to not compile will start compiling, with a reasonable
result. No code that used to compile will change.
More information about the core-libs-dev