home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (Groovy1706_Bug.groovy)

This example Groovy source code file (Groovy1706_Bug.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

a, a, b, b, groovy1706_bug, groovy1706a, groovy1706a, groovy1706b, groovy1706b, groovytestcase

The Groovy Groovy1706_Bug.groovy source code

package groovy.bugs

class Groovy1706_Bug extends GroovyTestCase {
   void testStaticMethodIsCalledFromSubclass() {
      // disclaimer: static methods shouldn't be
      // called on instances
      Groovy1706A a = new Groovy1706A()
      Groovy1706B b = new Groovy1706B()
      assert "A" == a.doit()
      assert "B" == b.doit()
   }

   void testStaticMethodIsCalledInCorrectInstance() {
      // disclaimer: static methods shouldn't be
      // called on instances
      Groovy1706A i = new Groovy1706B()
      assert "B" == i.doit()
      // in Java the answer would be "A"
   }
}

class Groovy1706A { static doit() { "A" } }
class Groovy1706B extends Groovy1706A { static doit() { "B" } }

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy Groovy1706_Bug.groovy source code file:

new blog posts

 

Copyright 1998-2014 Alvin Alexander, alvinalexander.com
All Rights Reserved.