groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (GROOVY-8164) Groovy allows a Java class to inherit static methods from its interface
Date Tue, 25 Apr 2017 08:56:04 GMT

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

Paul King edited comment on GROOVY-8164 at 4/25/17 8:55 AM:
------------------------------------------------------------

Actually I was going to suggest we discuss this on the mailing list too. It's not a given
that we want to follow Java but we want to have well-specified behavior for all cases. I know
we don't have test coverage for all cases and I imagine that what is currently implemented
hasn't changed in some places even with changes to Java etc. If someone doesn't beat me to
it, I'll try to formulate an email over the next few days while I am waiting for the 2.4.11
VOTE to timeout! :-)


was (Author: paulk):
Actually I was going to suggest we discuss this on the mailing list too. It's not a given
that we want to follow Java but we want to have well-specified behavior for all cases. I know
we don't have test coverage for all cases and I imagine that what is currently implemented
hasn't changed in some places even with changes to Java etc.

> 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