|
Groovy example source code file (Groovy4457GenericTypeDeclarationLeakTest.groovy)
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: |
Other websites by Alvin Alexander:
Life/living in Alaska (OneMansAlaska.com)
How I Sold My Business (HowISoldMyBusiness.com)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.