groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitry Khamitov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8164) Groovy allows a Java class to inherit static methods from its interface
Date Mon, 24 Apr 2017 20:38:04 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-8164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15981849#comment-15981849
] 

Dmitry Khamitov commented on GROOVY-8164:
-----------------------------------------

Meanwhile, I'm trying to figure out how it can be fixed. I'll create a PR or post here if
any questions

> 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
>
> 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
(v6.3.15#6346)

Mime
View raw message