Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding Mockito internal APIs #64

Closed
mockitoguy opened this issue Jun 18, 2017 · 7 comments
Closed

Avoiding Mockito internal APIs #64

mockitoguy opened this issue Jun 18, 2017 · 7 comments

Comments

@mockitoguy
Copy link
Contributor

Hey guys!

Dexmaker is using internal Mockito APIs, are you interested in working together to clean this up?

While working on extending Mockito APIs so that it is easier to integrate (mockito/mockito#1110), I took a look at dexmaker code in case I need to be cautions about breaking some compatibility :) I found a class that imports a couple of internal Mockito classes (org.mockito.internal).

@drewhannay
Copy link
Contributor

It'd be great to clean this up. Luckily it looks like all the internal api usages are centralized in InvocationHandlerAdapter (and there's only a few).

Do you have any more info you can provide on what can be used instead of these internal classes / interfaces?

@moltmann
Copy link
Contributor

moltmann commented Feb 5, 2018

When trying to convert the non-inline dexmaker mockmaker I am currently stuck in the problem that

Mockito.framework().getInvocationFactory().createInvocation ... takes a Callable for the read-method. If the real method throws an non-Exception-Throwable the realmethod-Callable cannot re-throw this. Wrapping it in a InvocationTargetException hides the lowest stack frame.

@moltmann
Copy link
Contributor

moltmann commented Feb 5, 2018

@mockitoguy : Can you recommend how to throw a non-Exception-Throwable from a realMethod used in Mockito.framework().getInvocationFactory().createInvocation(...) ?

moltmann added a commit to moltmann/dexmaker that referenced this issue Feb 23, 2018
moltmann added a commit to moltmann/dexmaker that referenced this issue Feb 23, 2018
….Set

The MockMap is mostly a re-implementation of WeakConcurrentMap with a
few Android'y twists such as creating less objects and using
android.util types where they don't cause a performance regression.

I stopped using the WeakConcurrentSet as we need to remember which
classes are transformed, hence using a weak-reference would require us
to un-transform the classes when the reference goes away. We don't do
that, hence don't use weak-references.
moltmann added a commit to moltmann/dexmaker that referenced this issue Feb 23, 2018
... still waiting for mockito 2.16 to be able to replace the usage of
the internal Instantiator.
drewhannay pushed a commit that referenced this issue Feb 23, 2018
The MockMap is mostly a re-implementation of WeakConcurrentMap with a
few Android'y twists such as creating less objects and using
android.util types where they don't cause a performance regression.

I stopped using the WeakConcurrentSet as we need to remember which
classes are transformed, hence using a weak-reference would require us
to un-transform the classes when the reference goes away. We don't do
that, hence don't use weak-references.
drewhannay pushed a commit that referenced this issue Feb 23, 2018
... still waiting for mockito 2.16 to be able to replace the usage of
the internal Instantiator.
@drewhannay
Copy link
Contributor

@moltmann is there still work left to do on this one?

moltmann added a commit to moltmann/dexmaker that referenced this issue Mar 27, 2018
Now that there is a public instantiator provider, use it.

This was the last internal mockito API we used.
@moltmann
Copy link
Contributor

pull #93 and we are done.

drewhannay pushed a commit that referenced this issue Mar 27, 2018
Now that there is a public instantiator provider, use it.

This was the last internal mockito API we used.
@drewhannay
Copy link
Contributor

Thanks @moltmann!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants