You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/05/30 18:20:00 UTC
[jira] [Commented] (GROOVY-11075) The method pointer operator suppresses checked exceptions and results in a MethodMissingException
[ https://issues.apache.org/jira/browse/GROOVY-11075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17727645#comment-17727645 ]
Eric Milles commented on GROOVY-11075:
--------------------------------------
Your example method does not declare that it throws any checked exceptions, so Groovy must be wrapping the {{IOException}} in an unchecked exception before the method returns.
> The method pointer operator suppresses checked exceptions and results in a MethodMissingException
> -------------------------------------------------------------------------------------------------
>
> Key: GROOVY-11075
> URL: https://issues.apache.org/jira/browse/GROOVY-11075
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.12
> Reporter: Joe Li
> Priority: Major
>
> The method pointer operator suppresses checked exceptions and results in a MethodMissingException instead in groovy 4.0.12. This issue seems to first appear in groovy 3.0.16, which is the earliest version I am able to reproduce. Example code
> {code:java}
> class Foo {
> static void bar(String str) {
> throw new IOException()
> println str
> }
> }
> def baz = Foo.&bar
> baz('hi') {code}
> This results in a MethodMissingException despite the IO Exception being thrown. This seems to be the case for any checked exception.
>
> {code:java}
> class Foo {
> static void bar(String str) {
> throw new IOException()
> println str
> }
> }
> Foo.bar("hi") {code}
> When calling the method directly I get an IO Exception as expected
--
This message was sent by Atlassian Jira
(v8.20.10#820010)