You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2018/05/15 06:19:00 UTC

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

    [ 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)