Limit instrumentation on interfaces #6866
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Limit instrumentation on interfaces
Previously, Robolectric enabled some of its instrumentation on interfaces
in order to support hooking up interceptors on default interface methods.
This is because there are now some default interface methods that invoke
System.logW (e.g. android.compat.Compatibility$BehaviorChangeDelegate)
However, the instrumentation step that makes classes public
was also applied to interfaces, and this seems to confuse Mockito/ByteBuddy,
but only in certain environments.
As a fix, restrict the instrumentation to only rewrite interface method
bodies, as well as extends 'InstrumentedInterface', so Robolectric does
not re-instrument interfaces when the preinstrumented jars are used.
A test case will be added after the preinstrumented jar version is
bumped.
Fixes #6858