Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.8.6
-
None
-
None
-
Linux Mint 12 (Linux 3.0.0-12 x86_64)
Sun Java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
Description
When using MockFor on a concrete Java class, calling proxyDelegateInstance produces a proxy that's incompatible with that class.
This appears to be because MockFor.getInstance (eventually called by MockFor.proxyDelegateInstance) calls ProxyGenerator.INSTANCE.instantiateDelegate with a new instance of the class only. Down below in instantiateDelegateWithBaseClass, since it has no baseClass it doesn't try to extend that class.
Should it be calling instantiateDelegateWithBaseClass with the Java class as the baseClass instead? It appears to be doing this with abstract classes, but not with concrete classes.
A workaround it to add a shim subclass of the Java class, either an abstract Java class or a Groovy class, and use that in MockFor instead.