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 2022/02/23 01:16:00 UTC

[jira] [Assigned] (GROOVY-10504) Cannot call static method from Java interface (Groovy 4)

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

Eric Milles reassigned GROOVY-10504:
------------------------------------

    Assignee: Eric Milles

> Cannot call static method from Java interface (Groovy 4)
> --------------------------------------------------------
>
>                 Key: GROOVY-10504
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10504
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 4.0.0
>            Reporter: Renato Athaydes
>            Assignee: Eric Milles
>            Priority: Major
>
> Create a Java interface with a static method:
> {code}
> public interface JavaInterface {
>    static String getStringString input) {
>      return input;
>   }
> }
> {code} 
> A simple Groovy class that uses that:
>  {code}
> class Example implements JavaInterface {
>    static void main(String[] args) {
>      println getString('OK')
>   }
> }
> {code}
> Running this works fine in Groovy 3.0.9.
> In Groovy 4.0.0 I get this runtime error:
> {noformat}
> Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: static tests.Example.getString() is applicable for argument types: (String) values: [OK]
> Possible solutions: toString(), toString(), getAt(java.lang.String)
>         at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1677)
>         at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1663)
>         at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.callStatic(StaticMetaClassSite.java:64)
>         at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:54)
>         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217)
>         at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:231)
>         at tests.Example.main(Example.groovy:5)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)