You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/05/02 02:13:04 UTC

[jira] [Resolved] (GROOVY-6336) Support Java 7 ARM blocks

     [ https://issues.apache.org/jira/browse/GROOVY-6336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King resolved GROOVY-6336.
-------------------------------
       Resolution: Fixed
    Fix Version/s:     (was: 3.0)
                   2.6.0-alpha-1

> Support Java 7 ARM blocks
> -------------------------
>
>                 Key: GROOVY-6336
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6336
>             Project: Groovy
>          Issue Type: New Feature
>          Components: Compiler
>    Affects Versions: 2.2.0-beta-2
>            Reporter: Tom Dunstan
>            Assignee: Daniel Sun
>             Fix For: 2.6.0-alpha-1
>
>
> Currently Groovy does not have an equivalent to Java 7's ARM blocks. The closest is adding a method which takes a closure to the class that you'd like to be auto-closed (or whatever gives you that resource), and implementing the closing logic in that method. This has a host of problems:
>  - It's inefficient, requiring multiple method calls and an extra closure class over the Java solution
>  - Since the closure-accepting methods are added ad-hoc, they have different names and quite possibly subtly different behaviour, particularly around what happens if an exception is thrown during the closing. By contrast this is well defined in Java 7 so a programmer doesn't have to go hunting for documentation or source code on the method that they're calling 
>  - If you are trying to work with an existing Java library rather than Groovy code, you're out of luck, since short of metaclass hacking you won't be able to add a wrapper method anyway
> It would also be nice to keep Groovy and Java syntax as consistent as possible to ease porting between the two.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)