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
Problem verifying bridge methods #304
Comments
The problem here is the following: Byte Buddy does not intercept bridge methods but assumes that these methods should be dispatched as they are. Therefore, the actual method is still invoked which is then intercepted. As a result, the Mockito on the other hand picks up the invoked method from the call site which is I am going to look into how this can be added to Mockito. This requires resolving parameterized tyes along the hierarchy in order to find out to what method the bridge is actually pointing to. |
Since somebody else has this issue, I found a workaround to make the test pass: ((Base<String>)ext).test("456");
verify(ext).test("456"); // Fails
((Base<String>)verify(ext)).test("456"); // Passes (workaround) |
@bric3 Would it be a feasible solution if I relied on Byte Buddy APIs to resolve this? I implemented a rather elaborate algorithm that I have tried to port to Mockito. However, its not as easy as I thought since the algorithm and related data structure are quite bound into the Byte Buddy APIs. I would of course add an interface that does not rely on Byte Buddy for querying this information but asking the library to do it would be the most straight-forward solution. |
@raphw That is possible, maybe in the form of a |
Hello, I think there might be a bug in mockito when verifying bridge methods.
The bug is present both in version 2.0.31-beta, and in version 1.10.19.
The text was updated successfully, but these errors were encountered: