Open GoogleCodeExporter opened 9 years ago
my apologies, this was an error in my environment. please discard this issue.
Original comment by rpratiw...@gmail.com
on 31 May 2012 at 6:57
No worries. I'm glad it's resolved.
Original comment by klyu...@google.com
on 26 Jun 2012 at 6:26
Getting the exact same error doing a partial mock of an activity using mockito
1.9.5 + dexmaker 0.9. How was this solved? Any pointers are appreciated
java.lang.VirtualMachineError
at dalvik.system.DexFile.defineClass(Native Method)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:207)
at dalvik.system.DexFile.loadClass(DexFile.java:196)
at dalvik.system.DexClassLoader.findClass(DexClassLoader.java:226)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at com.google.dexmaker.stock.ProxyBuilder.loadClass(ProxyBuilder.java:272)
at com.google.dexmaker.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:254)
at
com.google.dexmaker.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:
54)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:49)
at org.mockito.Mockito.spy(Mockito.java:1324)
at
com.company.droid.helper.ActivitySandbox.setupActivity(ActivitySandbox.java:21)
at
com.company.droid.ui.fragment.signup.SignupFragmentTest.setUp(SignupFragmentTest
.java:50)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:52
9)
at
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
Original comment by work.am...@gmail.com
on 17 Oct 2012 at 5:51
Would you please obtain the system log -- it will contain much more information
(e.g., what the VM didn't like about the generated bytecode). Without that
information, it's impossible to tell what went wrong.
Original comment by klyu...@google.com
on 17 Oct 2012 at 5:54
I am having the same issue. It would look like mockito is overriding a final
method.
01-23 12:01:56.417: W/dalvikvm(16726): Method LMyView_Proxy;.getParent
overrides final Landroid/view/View;.getParent
01-23 12:01:56.417: W/dalvikvm(16726): Link of class 'LMyView_Proxy;' failed
Original comment by michele.sama
on 23 Jan 2013 at 12:07
Are you experiencing this with DexMaker v1.0?
Original comment by klyu...@google.com
on 23 Jan 2013 at 4:27
I have same error trying to mock a relative layout and it happens with
dexmarker 1.0.
7186 dalvikvm W Method LRelativeLayout_Proxy;.getParent overrides final Landroid/view/View;.getParent
7186 dalvikvm W failed creating vtable
7186 dalvikvm W Link of class 'LRelativeLayout_Proxy;' failed
Original comment by pedro.fr...@gmail.com
on 7 Feb 2013 at 10:24
I can also reproduce this issue on v1.0 (see below). Any ideas?
DexOpt: --- BEGIN 'Generated-254988436.jar' (bootstrap=0) ---
method LRelativeLayout_Proxy;.assignParent incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.canAcceptDrag incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.clearAccessibilityFocusNoCallbacks incorrectly
overrides package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.createSnapshot incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.destroyLayer incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.dispatchAttachedToWindow incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.dispatchCollectViewAttributes incorrectly
overrides package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.dispatchDetachedFromWindow incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.dispatchPopulateAccessibilityEventInternal
incorrectly overrides package-private method with same name in
Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.dispatchScreenStateChanged incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.draw incorrectly overrides package-private method
with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.ensureInputFocusOnFirstFocusable incorrectly
overrides package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.ensureTransformationInfo incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.findFrontmostDroppableChildAt incorrectly
overrides package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.findUserSetNextFocus incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.findViewByAccessibilityIdTraversal incorrectly
overrides package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.finishAnimatingView incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.getBoundsOnScreen incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.getHardwareLayer incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.getListenerInfo incorrectly overrides
package-private method with same name in Landroid/view/View;
Method LRelativeLayout_Proxy;.getParent overrides final
Landroid/view/View;.getParent
failed creating vtable
DexOpt: load 17ms, verify+opt 0ms, 230404 bytes
DexOpt: --- END 'Generated-254988436.jar' (success) ---
DEX prep
'/data/data/com.google.android.apps.authenticator2/cache/Generated-254988436.jar
': unzip in 2ms, rewrite 86ms
method LRelativeLayout_Proxy;.assignParent incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.canAcceptDrag incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.clearAccessibilityFocusNoCallbacks incorrectly
overrides package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.createSnapshot incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.destroyLayer incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.dispatchAttachedToWindow incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.dispatchCollectViewAttributes incorrectly
overrides package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.dispatchDetachedFromWindow incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.dispatchPopulateAccessibilityEventInternal
incorrectly overrides package-private method with same name in
Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.dispatchScreenStateChanged incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.draw incorrectly overrides package-private method
with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.ensureInputFocusOnFirstFocusable incorrectly
overrides package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.ensureTransformationInfo incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.findFrontmostDroppableChildAt incorrectly
overrides package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.findUserSetNextFocus incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.findViewByAccessibilityIdTraversal incorrectly
overrides package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.finishAnimatingView incorrectly overrides
package-private method with same name in Landroid/view/ViewGroup;
method LRelativeLayout_Proxy;.getBoundsOnScreen incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.getHardwareLayer incorrectly overrides
package-private method with same name in Landroid/view/View;
method LRelativeLayout_Proxy;.getListenerInfo incorrectly overrides
package-private method with same name in Landroid/view/View;
Method LRelativeLayout_Proxy;.getParent overrides final
Landroid/view/View;.getParent
failed creating vtable
Link of class 'LRelativeLayout_Proxy;' failed
java.lang.VirtualMachineError
at dalvik.system.DexFile.defineClass(Native Method)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:211)
at dalvik.system.DexPathList.findClass(DexPathList.java:305)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:62)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at com.google.dexmaker.stock.ProxyBuilder.loadClass(ProxyBuilder.java:272)
at com.google.dexmaker.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:254)
at com.google.dexmaker.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:56)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)
at org.mockito.Mockito.mock(Mockito.java:1243)
at org.mockito.Mockito.mock(Mockito.java:1120)
Original comment by klyu...@google.com
on 7 Feb 2013 at 7:37
Looks like we're generating mocks in the wrong package. We can't mock
package-private methods of superclasses defined in the android.view package if
our mock subclass is in the android.widget package.
The fix is to either stop mocking these methods, or to change dexmaker to put
classes in another package. I thought we had tests for this but may be mistaken.
Original comment by limpbizkit
on 8 Feb 2013 at 3:23
Nope, the package private methods are not the problem, the final ones are:
Method LRelativeLayout_Proxy;.getParent overrides final Landroid/view/View;.getParent
Our code that attempts to not override final methods must be broken.
Original comment by limpbizkit
on 8 Feb 2013 at 3:50
It's a VM bug in Dalvik. I'll report it upstream. (Which doesn't necessarily
mean we shouldn't also work around in dexmaker).
Original comment by limpbizkit
on 8 Feb 2013 at 4:04
Report upstream: https://code.google.com/p/android/issues/detail?id=46766
Our workaround should be to not override methods if there's a final package
private method with the same signature.
Original comment by limpbizkit
on 8 Feb 2013 at 4:14
[deleted comment]
Added patch for ProxyBuilder that implements the workaround mentioned by
@limpbizkit.
Specifically it skips private methods declared in a package other than the
original package of the class being mocked.
Original comment by j...@sharethis.com
on 10 Dec 2013 at 7:23
Attachments:
I still see the error after applying the patch
java.lang.VirtualMachineError
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:222)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
at dalvik.system.DexPathList.findClass(DexPathList.java:322)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at com.google.dexmaker.stock.ProxyBuilder.loadClass(ProxyBuilder.java:272)
at com.google.dexmaker.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:254)
at com.google.dexmaker.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:57)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:32)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:55)
at org.mockito.Mockito.mock(Mockito.java:1243)
Original comment by dsaket.t...@gmail.com
on 12 Sep 2014 at 5:22
Which class is this failing on?
Original comment by jason.po...@gmail.com
on 12 Sep 2014 at 5:26
com.android.settings.bluetooth.BluetoothDeviceDetailsFragmentIntegrationTests:
Error in testAskDisconnect:
java.lang.VirtualMachineError
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:222)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)
at dalvik.system.DexPathList.findClass(DexPathList.java:322)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at com.google.dexmaker.stock.ProxyBuilder.loadClass(ProxyBuilder.java:272)
at com.google.dexmaker.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:254)
at com.google.dexmaker.mockito.DexmakerMockMaker.createMock(DexmakerMockMaker.java:57)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:32)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:55)
at org.mockito.Mockito.mock(Mockito.java:1243)
at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:33)
at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
at org.mockito.internal.configuration.DefaultAnnotationEngine.createMockFor(DefaultAnnotationEngine.java:43)
at org.mockito.internal.configuration.DefaultAnnotationEngine.process(DefaultAnnotationEngine.java:66)
at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:71)
at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:55)
at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:117)
at com.android.settings.bluetooth.BluetoothDeviceDetailsFragmentIntegrationTests.setUp(BluetoothDeviceDetailsFragmentIntegrationTests.java:77)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:556)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1705)
Original comment by dsaket.t...@gmail.com
on 16 Sep 2014 at 1:21
Class usage
public class BluetoothDeviceDetailsFragmentIntegrationTests extends
ActivityInstrumentationTestCase2<EmptyActivity> {
74 @Override
75 protected void setUp() throws Exception {
76 super.setUp();
77 MockitoAnnotations.initMocks(this);
}
Original comment by dsaket.t...@gmail.com
on 16 Sep 2014 at 1:31
Original issue reported on code.google.com by
rpratiw...@gmail.com
on 31 May 2012 at 1:05