greyblue9 / dexmaker

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

ProxyBuilder + no args method causes NullPointerException #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
As originally reported by allurefx here:
http://code.google.com/p/mockito/issues/detail?id=308#c71

I'm getting an IllegalArgumentException when running verify() on methods with 
no args. Things are OK when there are args (from the 
InvocationHandlerAdapter.java source, looks like invoke(Object proxy, Method 
method, Object[] args) is getting a null for args). E.g.,

interface Whatever {
    void doStuff();
}

public void testWhatever() {
    final Whatever whateverMock = mock(Whatever.class);
    whateverMock.doStuff();
    verify(whateverMock).doStuff();
}

throws:

java.lang.IllegalArgumentException
    at com.google.dexmaker.mockito.InvocationHandlerAdapter.invoke(InvocationHandlerAdapter.java:49)
    at com.sanitas.wellaho.login.$Proxy26.doStuff(Unknown Source)
    at com.sanitas.wellaho.login.LoginTest.testWhatever(LoginTest.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:243)
    at junit.framework.TestSuite.run(TestSuite.java:238)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Original issue reported on code.google.com by limpbizkit on 29 Mar 2012 at 10:57

GoogleCodeExporter commented 8 years ago
I couldn't reproduce this.

Original comment by jessewil...@google.com on 1 Apr 2012 at 10:56

GoogleCodeExporter commented 8 years ago
The error seems to be coming only if you run it as a JUnit test. E.g., add the 
attached test case to your project and run it as a JUnit test (not Android 
JUnit). You will need to add the libs/ jars to the class path. I tried, and I 
got the exception again.

Original comment by allur...@gmail.com on 1 Apr 2012 at 11:02

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The problem was that I had dexmaker library in the path even when using JUnit. 
Once I removed it, it ran fine.

Original comment by allur...@gmail.com on 2 Apr 2012 at 12:54