easyforgood / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

MockitoInvocationHandler.handle returns null when a primitive is expected #331

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I believe Mockito is relying on some unspecified behaviour in cglib that allows 
MockitoInvocationHandler.handle() to return null when a primitive is expected. 
Cglib's MethodInterceptor.intercept() documents the legal return values like 
this:
 * @return any value compatible with the signature of the
 * proxied method. Method returning void will ignore this value.

This suggests it is an error for MockitoInvocationHandler.handle() to return 
null for methods with primitive return types. We haven't noticed until now 
because I believe cglib is ignoring the error and replacing mockito's null with 
its own default.

But it's causing a crash on Android+dexmaker because dexmaker doesn't convert 
null to a primitive type. We could work around this in dexmaker but I believe 
mockito is the right place to fix the problem.

I think the fix is to use HandyReturnValues.returnFor() instead of null in 
MockHandler#handle on lines 63 and 82.

We're tracking this in dexmaker here:
http://code.google.com/p/dexmaker/issues/detail?id=3

See also issue 308.

Original issue reported on code.google.com by limpbizkit on 2 Apr 2012 at 2:34

GoogleCodeExporter commented 8 years ago
I agree - it makes sense for Mockito to less depend on cglib.  Also, thanks for 
good hints on impl details - I think that's exactly what we need to do.

Original comment by szcze...@gmail.com on 2 Apr 2012 at 7:32

GoogleCodeExporter commented 8 years ago
Friendly ping! This is the only issue that's problematic for Android/dexmaker 
integration.

Original comment by jessewil...@google.com on 15 May 2012 at 2:10

GoogleCodeExporter commented 8 years ago
Thanks for the reminder :) I'm looking into fixing this.

Original comment by szcze...@gmail.com on 15 May 2012 at 6:57

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 441930b6659a.

Original comment by szcze...@gmail.com on 23 May 2012 at 8:10

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 3 Jun 2012 at 2:04

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 3 Jun 2012 at 2:06

GoogleCodeExporter commented 8 years ago

Original comment by brice.du...@gmail.com on 19 Dec 2012 at 10:59