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

Fixes issue 524 : Mockito 1.10.9+ incompatibility, by repackaging CGLIB MockMaker #15

Merged
merged 1 commit into from Jan 30, 2015

Conversation

bric3
Copy link
Contributor

@bric3 bric3 commented Jan 29, 2015

Fixes issue 524

As Mockito changed the structure of this internals : renaming, package changes, visibility change, interface change. PowerMock doesn't have anymore the opportunity to hack his way by extension.

So he best way currently is to repackage some of the mockito internals (the CGLIB related part), and change visibility where relevant. However it means that PowerMock won't use current Mockito MockMaker. As Mockito is progressively moving away from CGLIB, there will for sure be another implementation. Let's forget bug fixes on this front too.

A better solution has to be engineered. PR are welcome on https://github.com/mockito/mockito/

Not a perfect solution as PowerMock don't use current Mockito MockMaker. Could be another implementation, and there will be.
Or won't benefit from bugfixes on this front. A better solution has to be engineered.
@bric3 bric3 force-pushed the repackage-some-mockito-classes branch from 7fc81a0 to d9615ec Compare January 29, 2015 13:21
johanhaleby added a commit that referenced this pull request Jan 30, 2015
Fixes issue 524 : Mockito 1.10.9+ incompatibility, by repackaging CGLIB MockMaker
@johanhaleby johanhaleby merged commit 6e46ee7 into powermock:master Jan 30, 2015
@johanhaleby
Copy link
Collaborator

Thanks Brice. A better solution would be great since the PowerMock Mockito integration is very hacky and fragile (and has always been). Unfortunately I guess that I won't have the time needed to undertake such as big task atm. Perhaps this is off topic but I'm curious to know what lib Mockito will use instead of CgLib in the future?

@bric3
Copy link
Contributor Author

bric3 commented Jan 30, 2015

We'd like to move to bytebuddy, and actually @raphw (the author of bytebuddy) contributed us something. I agree it's moving slower that I would like to be, but we're getting there :)

At some point we may completely remove CGLIB, maybe still offering it as a MockMaker.

Anyway mockito already offers a way to change the MockMaker. In bytebuddy, you could propose extension points, Szczepan introduced the Plugins class that may be a starting point to extend / plug in behavior.

@bric3
Copy link
Contributor Author

bric3 commented Jan 30, 2015

By the way do you have an idea when you want to release this temporary fix.

@bric3 bric3 deleted the repackage-some-mockito-classes branch January 30, 2015 11:22
@raphw
Copy link

raphw commented Jan 30, 2015

I very much agree that Mockito should move on to using Byte Buddy soon. ;)

Is there any specific extension you would like to see in the library to simplify integration or are you rather speaking about Mockito's interface to the code generator? Byte Buddy gained a fair amount of users recently and as those users did not experience too many bugs, I am very much open to suggestions that extend the library's functionality if the implementation makes sense at this point in time.

As a matter of fact, Byte Buddy already offers a rebase definition which more or less flattens a defined subclass into the base class without breaking the subclass calling semantics. (Overridden methods are simply inlined as private methods.) This might be an interesting option for PowerMock as the rebased class would behave like a Mockito mock by only changing one instruction of the DSL.

Just ping me if you need any help with this.

@bric3
Copy link
Contributor Author

bric3 commented Jan 30, 2015

@raphw I was mostly speaking for the powermock development to plug-in behavior within mockito. Anyway regarding the byte code manipulation, bytebuddy might offer a compelling alternative to what is used now.

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

Successfully merging this pull request may close these issues.

None yet

3 participants