Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10504

Cannot call static method from Java interface (Groovy 4)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Information Provided
    • 4.0.0
    • None
    • Compiler
    • None

    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

          Activity

            People

              emilles Eric Milles
              renatoathaydes Renato Athaydes
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: