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:15:04 UTC

[jira] [Updated] (GROOVY-6285) static declared type should influence method selection for null values

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

Paul King updated GROOVY-6285:
------------------------------
    Fix Version/s:     (was: 3.0)
                   3.x

> static declared type should influence method selection for null values
> ----------------------------------------------------------------------
>
>                 Key: GROOVY-6285
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6285
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-runtime
>    Affects Versions: 2.1.6
>            Reporter: frenchyan
>             Fix For: 3.x
>
>         Attachments: glu235.groovy
>
>
> See file attached to reproduce the problem: E1 is an exception class, E2 extends from E1 but define only the constructor with {{String}}.
> using new E2(null) end up calling {{E1(Throwable)}} => calling {{initCause}} then fails because the cause has been already been set.
> I am expecting {{E1(String)}} to be called...
> {code}
> > groovy -version
> Groovy Version: 2.1.6 JVM: 1.7.0_25 Vendor: Oracle Corporation OS: Mac OS X
> > groovy glu235.groovy
> called E1.throwable null
> called E2.string null
> Caught: java.lang.IllegalStateException: Can't overwrite cause
> java.lang.IllegalStateException: Can't overwrite cause
> 	at java_lang_Throwable$initCause.call(Unknown Source)
> 	at glu235.run(glu235.groovy:43)
> {code}
> Reproducible with groovy 2.0.7 as well.



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