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

Groovy example source code file (Groovy3163Bug.groovy)

This example Groovy source code file (Groovy3163Bug.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

groovy3163somebaseclass, groovy3163somebaseclass, groovy3163someimplementorwithstatic, groovy3163someimplementorwithstatic, groovy3163test, groovytestcase, groovytestcase, math, object, object

The Groovy Groovy3163Bug.groovy source code

package groovy.bugs

import java.math.BigInteger;


public class Groovy3163Test extends GroovyTestCase {

public void testSuperOverStatic()
{
    def siws = new Groovy3163SomeImplementorWithStatic()

    assert (1 == siws.build(1)[0])
    
    def c = { -> 'foo ' }
    
//    def s = c as Script
//    assert s.is(siws.build(s)[0])

    assert c.is(siws.build(c)[0])
}

}


class Groovy3163SomeBaseClass {

    public Object build(Integer i) {
        return i;
    }

    public Object build(BigInteger i) {
        return i;
    }

    public Object build(Class c) {
        return c;
    }

    public Object build(Script s) {
        return s;
    }
}

class Groovy3163SomeImplementorWithStatic extends Groovy3163SomeBaseClass {

    // Comment this out, otherwise the super.build(x) calls won't match the members in our parent.

    public static Object build(Closure c) {
        return [c]
    }

    // This one will also block a super.build, but it's the Script one.
    public static Object build(BigDecimal d) {
        return [d]
    }

    public Object build(Integer i) {
        return [super.build(i)]
    }

    public Object build(Script s) {
        return [super.build(s)]
    }

}

Other Groovy examples (source code examples)

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

new blog posts

 

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