Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

there are a couple of discussion on SO about setter methods returning "this" type. And looks like java 7 had the proposal of void methods returning this. But this proposal could not make it to java 7 features. I could not find if this proposal is moved on to java 8 or future or have been completely discarded. Is it?

Ref link - Design: Java and returning self-reference in setter methods

share|improve this question

migrated from stackoverflow.com Dec 1 '11 at 14:20

This question came from our site for professional and enthusiast programmers.

3  
It will be grate to have some links to the discussion you have mentioned in the question, so that it will be useful for others and will help them understand the question more. –  ManuPK Dec 1 '11 at 13:45
    
edited my question –  Tarun Dec 1 '11 at 13:57

2 Answers 2

up vote 10 down vote accepted

I can't seem to find any sources of that, but I believe this feature was dropped completely. There are numerous reasons I can think of:

  • performance - each void method now has an extra return opcode and every place where this method is called needs implicit pop unless it actually uses method chaining

  • backward compatibility - compiling against this feature suddenly makes the code backward incompatible because the contract of every void method has changed

Of course this can also be implemented by the compiler (calling method on void? You probably meant this, let me add this implicitly), don't know what are the disadvantages of this approach.

share|improve this answer
1  
The compiler would have to support this feature (so the calling code would compile) and it could save the object called and use it again without the calling method being altered. –  Peter Lawrey Dec 1 '11 at 14:34
    
Features to the OpenJDK of this nature are now handled as JDK Enhancement Proposals (JEPs) and indeed this is no longer listed (and I haven't seen it discussed in quite some time). –  Martijn Verburg Dec 1 '11 at 14:44

I don't believe this was ever formally proposed for the 2009 incarnation of Project COIN. This page purports to list all of the proposals, and I can't see one that corresponds.

If it wasn't proposed, it wouldn't have been considered.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.