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

Fix lossy-conversions lint warnings #96398

Merged
merged 2 commits into from
May 31, 2023

Conversation

ChrisHegarty
Copy link
Contributor

JDK 20 has added a new javac lint warning for possible lossy conversion in compound assignments - because of implicit type casts, e.g.
warning: [lossy-conversions] implicit cast from int to byte in compound assignment is possibly lossy

The change resolves all such warnings, by either widening the type of the left-hand operand, or explicitly casting the type of the right-hand operand. The changes are largely mechanical.

Resolving these issues allows to build with JDK 20 using JAVA_TOOLCHAIN_HOME.

FYI - The JDK issue that added the javac lint warning - https://bugs.openjdk.org/browse/JDK-8244681

closes #95839

@ChrisHegarty ChrisHegarty added :Core/Infra/Core Core issues without another label >refactoring Team:Core/Infra Meta label for core/infra team labels May 28, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@@ -59,7 +59,7 @@ public void reset(byte[] bytes, int offset, int len) {
}

public void skipBytes(long count) {
pos += count;
pos += (int) count;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Optionally, we could choose to use Math::toIntExact here.

Copy link
Contributor

@pugnascotia pugnascotia left a comment

Choose a reason for hiding this comment

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

LGTM

@ChrisHegarty ChrisHegarty merged commit 1cc1d12 into elastic:main May 31, 2023
@ChrisHegarty ChrisHegarty deleted the lossy_conversions branch May 31, 2023 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >refactoring Team:Core/Infra Meta label for core/infra team v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation failure with JDK 20
3 participants