[jira] [Commented] (GROOVY-8586) Support Java 9 ARM blocks

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (GROOVY-8586) Support Java 9 ARM blocks

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/GROOVY-8586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16475330#comment-16475330 ]

Daniel Sun commented on GROOVY-8586:
------------------------------------

Examples:
 [https://dzone.com/articles/try-with-resources-enhancement-in-java-9]
{code:java}
public void loadDataFromDB() throws SQLException {
    Connection dbCon = DriverManager.getConnection("url", "user", "password");
    try (dbCon; ResultSet rs = dbCon.createStatement().executeQuery("select * from emp")) {
        while (rs.next()) {
            System.out.println("In loadDataFromDB() =====>>>>>>>>>>>> " + rs.getString(1));
        }
    } catch (SQLException e) {
        System.out.println("Exception occurs while reading the data from DB ->" + e.getMessage());
    }
}
{code}

> Support Java 9 ARM blocks
> -------------------------
>
>                 Key: GROOVY-8586
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8586
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Compiler
>    Affects Versions: 3.x
>            Reporter: Jesper Steen Møller
>            Assignee: Daniel Sun
>            Priority: Minor
>
> Java 9 introduces a ARM-with-existing-resources construct, like this:
> {code:java}
> OutputStream stream = foo();
> try (stream) {
>    stream.write(whatever());
> }
> {code}
> In other words, the resource need not be in the form of an initialization, but can just be a variable.
> Now that we have ARM in Groovy, we should be able to add this form as well.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)