Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6
-
None
-
None
Description
import groovy.sql.Sql
import java.sql.SQLException
class TestStaticMethod extends GroovyTestCase {
void testSqlNewInstance() {
shouldFail(SQLException)
MetaClassRegistry registry = GroovySystem.metaClassRegistry
def original = registry.getMetaClass(Sql)
def mc = new ClassProxyMetaClass(registry, Sql, original)
registry.setMetaClass(Sql, mc)
assert 'static' == SqlNewInstance.get()
registry.setMetaClass(Sql, original)
shouldFail(SQLException) { SqlNewInstance.get() }
// failed here
}
}
class ClassProxyMetaClass extends ProxyMetaClass {
ClassProxyMetaClass(MetaClassRegistry metaClassRegistry, Class aClass, MetaClass adaptee)
public Object invokeStaticMethod(final Object aClass, final String method, final Object[] arguments)
{ 'static' }}
class SqlNewInstance {
static get()
}