greyblue9 / dexmaker

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

Dexmaker+mockito crashes on the JVM #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
We should work with the Mockito guys to find something that doesn't require 
users to manually remove dexmaker from the class paths of their Android 
projects.

Original issue reported on code.google.com by jessewil...@google.com on 2 Apr 2012 at 2:03

GoogleCodeExporter commented 8 years ago
For information only this issue is related to this issue (406) on our side : 
https://code.google.com/p/mockito/issues/detail?id=406

Original comment by brice.du...@gmail.com on 4 Dec 2013 at 4:10

GoogleCodeExporter commented 8 years ago
Hey Jesse

This problem keeps popping up in the Mockito list. Shall we go ahead and deal 
with it? :) I'm happy to make changes to Mockito. Some options:

1. Create new org.mockito.plugins.PluginSwitcher extension point:

interface PluginSwitcher {
  boolean isEnabled(Class pluginClass);
}

You/your team could implement this and disable MockMaker plugin if not running 
on dalvik. Alternatively (or while waiting for you:) users can drop an 
implementation of this plugin to their classpaths / test source code and add a 
check for dalvik. 

2. Add new method to MockMaker interface: MockMaker.isEnabled(). I don't quite 
like it because for consistency I would need to add this to 
StackTraceCleanerProvider. Plus it would be a breaking change.

3. Add new interface org.mockito.plugins.Switchable

interface Switchable {
  boolean isEnabled();
}

For every extension point Mockito attempts to load, Mockito checks if the 
plugin implementation class implements Switchable. If so, it would ask if it is 
enabled before using the implementation. In dexmaker, you could make the 
android MockMaker implementation implement Switchable and add the logic that 
checks if running on dalvik.

Feedback/suggestions/other options? If I don't hear from dexmakers, I think I 
will go ahead with #1 as it seems to offer a remedy to the problem that users 
can immediately take advantage of.

Original comment by szcze...@gmail.com on 5 Dec 2014 at 10:32

GoogleCodeExporter commented 8 years ago
Hey guys,

Mockito 1.10.15 contains a new extension point: PluginSwitch. 
https://github.com/mockito/mockito/blob/master/doc/release-notes/official.md#110
15-2014-12-12-2342-utc

It can be used to switch off dexmaker's PluginSwitch if we're not running in 
dalvik. The plugin is not documented greatly yet (contributions welcome!) but 
it should be already useful.

This plugin can be implemented and included in dexmaker distribution to solve 
this use case out of the box (contributions welcome!). Until this happens, 
users can drop their own impl of this plugin on the the classpath.

Original comment by szcze...@gmail.com on 13 Dec 2014 at 5:34

GoogleCodeExporter commented 8 years ago
hey, i am running into this problem myself. The PluginSwitch idea sounds great. 
I am guessing it is not yet implemented? 

Original comment by levykl...@gmail.com on 26 Jul 2015 at 2:57