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

Groovy example source code file (Groovy4457GenericTypeDeclarationLeakTest.groovy)

This example Groovy source code file (Groovy4457GenericTypeDeclarationLeakTest.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, groovy4457generictypedeclarationleaktest, groovy4457generictypedeclarationleaktest, groovytestcase, string, string

The Groovy Groovy4457GenericTypeDeclarationLeakTest.groovy source code

package groovy.bugs

/**
 * @author Guillaume Laforge
 */
class Groovy4457GenericTypeDeclarationLeakTest extends GroovyTestCase {

    void testLeak() {
        assertScript """
            class A<String> {}

            class B {
                void foo(String s) {}
            }

            // use the name to check the class, since the error was that String was seen as
            // a symbol resolved to Object, not as the class String, thus a ... == String would
            // not have failed
            assert B.declaredMethods.find { it.name == "foo" }.parameterTypes[0].name.contains("String")
        """
    }

    void testLeakWithInnerClass() {
        assertScript """
            class A<String> {
                static class B {
                    void foo(String s) {}
                }
            }

            assert A.B.declaredMethods.find { it.name == "foo" }.parameterTypes[0].name.contains("String")
        """
    }
}

Other Groovy examples (source code examples)

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

new blog posts

 

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