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 2024/02/28 16:53:00 UTC

[jira] [Assigned] (GROOVY-11327) Groovy 3.0.20 cannot invoke static method on interface implemented by context

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

Eric Milles reassigned GROOVY-11327:
------------------------------------

    Assignee: Eric Milles

> 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
>            Assignee: Eric Milles
>            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)