Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.7
Description
In the following situation Java doesn't compile (as per JLS8 - 8.4.8 Inheritance, Overriding, and Hiding):
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(); } }
$ javac FooBarTest.java
FooBarTest.java:3: error: cannot find symbol
Bar.foo();
^
symbol: method foo()
location: class Bar
1 error
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.
Attachments
Issue Links
- causes
-
GROOVY-10504 Cannot call static method from Java interface (Groovy 4)
- Closed
-
GROOVY-10590 Static methods of interfaces are not resolved anymore in implementig classes with Groovy 4.x
- Closed
-
GROOVY-10605 Regression of method argument resolution with Groovy 4
- Closed
-
GROOVY-11268 MissingMethodException for java Function<>
- Closed
- is related to
-
GROOVY-11107 EnumSet varargs constructor is not recognized (broken) in runtime
- Closed