Some Classes with a public void close() don't implement AutoCloseable

Brian Goetz brian.goetz at oracle.com
Sat Apr 18 15:31:48 UTC 2020


> I think these issues were discussed and are the reason why
> try-with-resources requires the introduction of a new variable, to
> make clearer that there is no ownership in the evaluation of the
> expression.
> 
> I guess this probably was onl partially successful, due to the
> wrapping of streams and code like this:

These discussions illustrate the tensions inherent in proposing “pain reduction” features like TWR.  On the one hand, TWR addresses a real pain point; on the other, it was knowingly limited.  The arguments pro and con write themselves: “this is addressing a real problem”, “don’t let the perfect be the enemy of the good”, etc; while these might in fact be compelling arguments in any given situation, the fact remains that, should these features succeed in their essential purpose, their limitations will become immediately constraining.  (Similar complaints could be made of the for-each loop, in that it offers no way to access the index (for array loops) or iterator (for Iterable loops.)  And the limitations were known at the time the feature was being proposed.

So here we are, now trying to go back and fix something that was considered and rejected at the time, because we have since discovered that we were wrong when we said “we’d be happy if we could just solve X.”   And fixing it is harder now, because we have to work within the constraints of a feature that was deliberately designed to be limited (whereas, when the feature was being designed, more things were possible.)  

Without commenting on the merits of the current round of proposals, let me just remind everyone that nailing epicyclical bags on the side of an incomplete feature will not make it complete….


More information about the discuss mailing list