Description
Create a Java interface with a static method:
public interface JavaInterface { static String getString(String input) { return input; } }
A simple Groovy class that uses that:
class Example implements JavaInterface { static void main(String[] args) { println getString('OK') } }
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)
Attachments
Issue Links
- is caused by
-
GROOVY-8164 Groovy allows a Java class to inherit static methods from its interface
- Closed
- relates to
-
GROOVY-10590 Static methods of interfaces are not resolved anymore in implementig classes with Groovy 4.x
- Closed