| 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 "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 { == "foo" }.parameterTypes[0].name.contains("String")

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

            assert A.B.declaredMethods.find { == "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:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.