Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.4.1, 2.5.0-beta-1, 3.0.4
-
None
-
Winows 8.1, JDK 1.8
Description
When replaced static method is called from an instance of a class, it still hits original method. Here is code example that fails:
StaticStubFails.java
class Foo { static String greet() { 'Hello from Foo' } } foo = new Foo() assert 'Hello from Foo' == foo.greet() Foo.metaClass.static.greet = { 'Hello from Stub' } assert 'Hello from Stub' == Foo.greet() //uncomment line below and it will pass //foo.metaClass.static.greet = { 'Hello from Stub' } assert 'Hello from Stub' == foo.greet() println 'All ok'
Output
assert 'Hello from Stub' == foo.greet() | | | | | Hello from Foo | Foo@5e82df6a false