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 2021/12/13 20:03:00 UTC

[jira] [Assigned] (GROOVY-8164) Groovy allows a Java class to inherit static methods from its interface

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

Eric Milles reassigned GROOVY-8164:
-----------------------------------

    Assignee: Eric Milles

> Groovy allows a Java class to inherit static methods from its interface
> -----------------------------------------------------------------------
>
>                 Key: GROOVY-8164
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8164
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler, Static compilation
>    Affects Versions: 2.4.7
>            Reporter: Dmitry Khamitov
>            Assignee: Eric Milles
>            Priority: Major
>
> In the following situation Java doesn't compile (as per JLS8 - 8.4.8 Inheritance, Overriding, and Hiding):
> {code:java}
> interface Foo {
>   static void foo() {
>     System.out.println("static void foo() called");
>   }
> }
> class Bar implements Foo { }
> public class FooBarTest {
>     public static void main(String[] args) {
>         Bar.foo();
>     }
> }
> {code}
> {code}
> $ javac FooBarTest.java
> FooBarTest.java:3: error: cannot find symbol
>         Bar.foo();
>            ^
>   symbol:   method foo()
>   location: class Bar
> 1 error
> {code}
> But Groovy does compile, both dynamic and @CompileStatic and we get {{static void foo() called}} in the output
> Just in case, here is a snippet from _JLS8_:
> *8.4.8 Inheritance, Overriding, and Hiding*
> A class C inherits from its direct superclass all concrete methods m (both static and instance) of the superclass for which all of the following are true:
> ...
> A class does not inherit static methods from its superinterfaces.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)