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

Muzzle should check whether used fields are declared somewhere #2870

Merged
merged 1 commit into from
Apr 28, 2021

Conversation

mateuszrzeszutek
Copy link
Member

Fixes #2823

@Override
public Stream<Field> getFields() {
return reference.getFields().stream()
.filter(this::isDeclaredAndNotPrivate)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are private fields special? An optimization? Nestmates can access private fields within nest, would that be an issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an optimization. This field check is mostly meant to detect changed/renamed fields when we're extending library classes - nested classes are not a valid scenario in this case. And if we use nested classes in our own instrumentation code the Java compiler will pick up all inconsistencies.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 😅

@trask trask merged commit e4133f1 into open-telemetry:main Apr 28, 2021
@mateuszrzeszutek mateuszrzeszutek deleted the muzzle-fields branch April 28, 2021 17:09
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.

Muzzle incorrectly constructs field references
3 participants