qdrzwd / dexmaker

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

mockito plugin does not correctly handle null values #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This issue impacts using dexmaker as a code generation library for mockito.

What steps will reproduce the problem?
1. Create a class/interface with a method foo that returns a primitive type, 
i.e:

public class Foo {
  public int foo() {return 0;}
}

2. Create a mock of this object, and call said method, i.e.:

Foo mock = mock(Foo.class);
mock.foo();

3. Verify the method call, i.e.:

verify(mock).foo();

What is the expected output? What do you see instead?

The last line throws a NullPointerException where it should have no output.  It 
appears (though I have not verified) that mockito just passes null back to the 
generated class when the mock is in the verify state, and dexmaker's mock tries 
to unbox it as a primitive, causing problems.  In cglib, intercepting methods 
with a primitive return value and returning null does not cause errors.

What version of the product are you using? On what operating system?

Android ICS on Ubuntu OS

Original issue reported on code.google.com by kevinmac...@live.com on 27 Mar 2012 at 3:04

GoogleCodeExporter commented 8 years ago
Thanks for the helpful bug report. The test made it very easy to reproduce!

I've figured this one out. The invocation handler is giving us back null, and 
we're attempting to unbox that as an int. We can paper over this in dexmaker 
but I'd prefer to see it fixed in mockito. I've filed a bug with them; we'll 
see how they respond.
  http://code.google.com/p/mockito/issues/detail?id=331

Original comment by jessewil...@google.com on 2 Apr 2012 at 2:36

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
Fixed in Mockito 1.9.5-rc1.

Original comment by limpbizkit on 21 Jun 2012 at 5:20