JDK-7196163 : Project Coin: Allow final or effectively final variables to be used as resources in try-with-resources
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-09-05
  • Updated: 2021-09-01
  • Resolved: 2014-11-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b42Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8065600 :  
Description
While general expression support was outlawed for the try-with-resources statement during the developement of Java SE 7, it would be helpful to allow limited expression support in the form of final or effectively final variables.  Using (effectively) final variables avoids the need to declare a dummy variable for the purpose of using the try-with-resources statement and avoid the semantic ambiguity of whether the close method should be called on the initial or final value of the variable.

Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/langtools/rev/f62d01419621 User: lana Date: 2014-12-10 19:54:42 +0000
10-12-2014

URL: http://hg.openjdk.java.net/jdk9/dev/langtools/rev/f62d01419621 User: jlahoda Date: 2014-11-19 12:59:11 +0000
19-11-2014

To a first approximation, this change should be able to be implemented by selectively undoing the changes in JDK-7013420 and adding checks to make sure that the variable being used as an expression is final or effectively final.
19-06-2014