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

Limit instrumentation on interfaces #6866

Merged
merged 1 commit into from Nov 17, 2021
Merged

Limit instrumentation on interfaces #6866

merged 1 commit into from Nov 17, 2021

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Nov 17, 2021

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

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

PiperOrigin-RevId: 410440888
@hoisie hoisie merged commit 7ec9ef3 into master Nov 17, 2021
13 checks passed
@hoisie hoisie deleted the piper_410440888 branch Nov 17, 2021
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.

1 participant