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

Eric Milles closed GROOVY-11327.
--------------------------------
    Resolution: Information Provided

> Groovy 3.0.20 cannot invoke static method on interface implemented by context
> -----------------------------------------------------------------------------
>
>                 Key: GROOVY-11327
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11327
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.20
>            Reporter: KAHA
>            Priority: Minor
>         Attachments: GroovyTest.java
>
>
> This is simple example parsing easy source and run script.
> {code:java}
> import groovy.lang.DelegatingMetaClass;
> import groovy.lang.GroovyClassLoader;
> import groovy.lang.GroovyObject;
> import groovy.lang.Script;
> public class GroovyTest {
>     public static final GroovyClassLoader cLoader = new GroovyClassLoader();
>     public static interface A {
>         public static void test() {
>             System.out.println("OK");
>         }
>     }
>     public static class MyContext implements A {
>         public MyContext(){
>         }
>     }
>     public static void main(String[] args) {
>         try {
>             String scriptText = "test();";
>             Class cls = cLoader.parseClass(scriptText);
>             GroovyObject object = (GroovyObject) 
> cls.getConstructor().newInstance();
>             if (object instanceof Script) {
>                 Script scr = ((Script) object);
>                 MyContext ctx = new MyContext();
>                 scr.setMetaClass(new DelegatingMetaClass(MyContext.class));
>                 scr.run();
>             }
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
>  {code}
> [^GroovyTest.java]
> Groovy version 3.0.12 correctly calls the test() method which is static on 
> the A interface and prints "OK"
> Groovy version 3.0.20 will print an error 
> "groovy.lang.MissingMethodException: No signature of method: 
> GroovyTest$MyContext.test() is applicable for argument types: () values: []"



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to