Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7196163

Project Coin: Allow final or effectively final variables to be used as resources in try-with-resources

    Details

    • Subcomponent:
    • Introduced In Build:
      b130
    • Introduced In Version:
      7
    • Resolved In Build:
      b42
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        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.

          Issue Links

            Activity

            Hide
            darcy Joe Darcy added a comment -
            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.
            Show
            darcy Joe Darcy added a comment - 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.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/langtools/rev/f62d01419621
            User: jlahoda
            Date: 2014-11-19 12:59:11 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/langtools/rev/f62d01419621 User: jlahoda Date: 2014-11-19 12:59:11 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/langtools/rev/f62d01419621
            User: lana
            Date: 2014-12-10 19:54:42 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/langtools/rev/f62d01419621 User: lana Date: 2014-12-10 19:54:42 +0000

              People

              • Assignee:
                jlahoda Jan Lahoda
                Reporter:
                darcy Joe Darcy
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: