Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1760

Static methods on a extending class are just ignored and hidden by the extended class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.0
    • 1.1-beta-1
    • None
    • None
    • all

    Description

      > I think there are two different issues here at hand. The first one is
      > that the 'extending' class does not expose the static methods of the
      > 'extended' class. And this is down to whether or not you want to
      > support it. Personally I think this is a must, since so many utility
      > classes would no longer be useful (at least on my work environment).
      > The second issue is that the 'extending' class does not hide the
      > 'extended' class' static method, and when invoking the method on the
      > 'extending' class, the 'extended' class' method is invoked instead.
      > This I think is a pretty huge bug.
      > Non-static methods work fine, but static methods on the extending
      > class are just ignored and hidden by the extended class (this should
      > work the other way around).

      > [[ EXAMPLE ]]
      >
      > Fruit.java:
      > public class Fruit {
      >
      > public static void say()

      { > System.out.println("I am a fruit..."); > }

      >
      > public void whisper()

      { > System.out.println("shhh.... I am a fruit...."); > }

      >
      > }
      >
      > Apple.java:
      > public class Apple extends Fruit {
      >
      > public void whisper()

      { > System.out.println("shhh... I am an apple..."); > }

      >
      > public static void say()

      { > System.out.println("I am an apple...."); > }

      > }
      >
      > script.groovy
      > import Fruit;
      > import Apple;
      >
      > println "The fruit says...";
      > Fruit.say();
      > println "The apple says...";
      > Apple.say();
      >
      > Fruit fruit = new Fruit();
      > Apple apple = new Apple();
      >
      > println "The fruit whispers...";
      > fruit.whisper();
      > println "The apple whispers...";
      > apple.whisper();
      >
      > Output:
      > The fruit says...
      > I am a fruit...
      > The apple says...
      > I am a fruit...
      > The fruit whispers...
      > shhh.... I am a fruit....
      > The apple whispers...
      > shhh... I am an apple...

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            rcracel Roger Cracel
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: