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 2016/04/21 14:06:25 UTC

[jira] [Comment Edited] (GROOVY-7821) @CompileStatic and exception list throws ClassCastException

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

Paul King edited comment on GROOVY-7821 at 4/21/16 12:05 PM:
-------------------------------------------------------------

When I run this example:
{code}
import groovy.transform.*
import groovy.util.logging.*

@Grab('org.slf4j:slf4j-simple:1.7.21')
@Slf4j
@CompileStatic
class TestException {
    static void main(String[] args) {
        try {
            throw new NullPointerException('ahh!')
        } catch (NullPointerException | IOException e) {
            log.error('error {}', e.message)
        }
    }
}
{code}
I get the same error as you on the GROOVY_2_4_X branch but I get no error and this output on master:
{noformat}
[Thread-3] ERROR TestException - error ahh!
{noformat}
I looked for an issue that might have fixed this (in case it could be easily back-ported) but I haven't found one yet.

Also, worth noting that changing @CompileStatic to @TypeChecked also avoids the CCE on 2.4.6.


was (Author: paulk):
When I run this example:
{code}
import groovy.transform.*
import groovy.util.logging.*

@Grab('org.slf4j:slf4j-simple:1.7.21')
@Slf4j
@CompileStatic
class TestException {
    static void main(String[] args) {
        try {
            throw new NullPointerException('ahh!')
        } catch (NullPointerException | IOException e) {
            log.error('error {}', e.message)
        }
    }
}
{code}
I get the same error as you on the GROOVY_2_4_X branch but I get no error and this output on master:
{noformat}
[Thread-3] ERROR TestException - error ahh!
{noformat}
I looked for an issue that might have fixed this (in case it could be easily back-ported) but I haven't found one yet.

> @CompileStatic and exception list throws ClassCastException
> -----------------------------------------------------------
>
>                 Key: GROOVY-7821
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7821
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.6
>         Environment: OSX, java version "1.8.0_40"
>            Reporter: Brendon Anderson
>            Priority: Minor
>
> {code:title=Bar.java|borderStyle=solid}
> @Slf4j
> @CompileStatic
> class TestException {
>     static void main(String[] args) {
>         try {
>             throw new NullPointerException('ahh!')
>         } catch (NullPointerException | IOException e) {
>             log.error('error {}', e.message)
>         }
>     }
> }
> {code}
> This throws a ClassCastException:
> {noformat}
> Exception in thread "main" java.lang.ClassCastException: java.lang.NullPointerException cannot be cast to java.io.IOException
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)