You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Renato Athaydes (Jira)" <ji...@apache.org> on 2022/02/22 16:31:00 UTC
[jira] [Created] (GROOVY-10504) Cannot call static method from Java interface (Groovy 4)
Renato Athaydes created GROOVY-10504:
----------------------------------------
Summary: 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
Create a Java interface with a static method:
{color:#cc844f}public interface {color}{color:#c6a02f}JavaInterface {color}{
{color:#cc844f}static {color}{color:#c6c45e}String {color}{color:#8ec1ff}getString{color}({color:#c6c45e}String {color}{color:#c675b9}input{color}) {
{color:#cc844f}return {color}{color:#c675b9}input{color}{color:#cc7832};
{color}{color:#cc7832} {color}}
}
A simple Groovy class that uses that:
{color:#cc844f}class {color}Example {color:#cc844f}implements {color}{color:#c6a02f}JavaInterface {color}{
{color:#cc844f}static void {color}main(String[] {color:#c675b9}args{color}) {
println {color:#9876aa}getString{color}({color:#75aa5f}'OK'{color})
}
}
Running this works fine in Groovy 3.0.9.
In Groovy 4.0.0 I get this runtime error:
{{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)}}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)