-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java] NullAway added #16416
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
[java] NullAway added #16416
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Let's get this in and enable a GH workflow when more coverage has been put in place.
User description
🔗 Related Issues
Related issue: #14291
Original PR (auto-closed): #14421
💥 What does this PR do?
Introduce the NullAway nullness analyzer to Selenium’s Java builds to simplify the process of adding JSpecify annotations and easily reveal inconsistencies.
This is a recreation of the original PR #14421 which was automatically closed.
I intentionally omitted the GitHub CI configuration to run NullAway analysis locally to simplify addition of the JSpecify annotations.
After applying all JSpecify annotations, we can enable verification in GitHub CI - it's too early for that right now, because it will only cause build failures.
By default, the NullAway plugin is disabled, to enable it, set the
//java:nullaway_level
flag:--//java:nullaway_level=WARN
--//java:nullaway_level=ERROR
For example:
🔧 Implementation Notes
Used NullAway parameters:
-Xep:NullAway:WARN
- report problems as warnings-Xep:NullAway:ERROR
- report problems as errors and stop compilation when an error occurs - good for CI/CD-XepOpt:NullAway:AnnotatedPackages=org.openqa.selenium
- analyze this package (including subpackages)I also updated
org.checkerframework:checker-qual
to version3.49.2
because there was a conflict with version3.21.2
.💡 Additional Considerations
Once all classes are properly and consistently annotated with JSpecify, we can add the configuration to GitHub CI to ensure nullness correctness for newly added code.
🔄 Types of changes
PR Type
Enhancement
Description
Integrates NullAway static analyzer for Java nullness checking
Adds configurable build flag (
--//java:nullaway_level
) with WARN/ERROR levelsUpdates
checker-qual
dependency from 3.21.2 to 3.49.2Creates custom
java_library
wrapper with conditional NullAway plugin injectionDiagram Walkthrough
File Walkthrough
java_library.bzl
Add custom java_library wrapper with NullAway support
java/private/java_library.bzl
java_library
wrapper functionorg.openqa.selenium
export.bzl
Switch to custom java_library wrapper
java/private/export.bzl
java_library
from contrib_rules_jvmjava_library
from local wrapper modulelibrary.bzl
Update library imports to use wrapper
java/private/library.bzl
java_library
import from contrib_rules_jvmjava_library
from wrapper moduleBUILD.bazel
Configure NullAway plugin and build flags
java/BUILD.bazel
nullaway
java_plugin with uber.nullaway dependencynullaway_level
string flag with NONE/WARN/ERROR valuesMODULE.bazel
Add NullAway and update checker-qual dependencies
MODULE.bazel
com.uber.nullaway:nullaway:0.12.10
dependencyorg.checkerframework:checker-qual
from 3.21.2 to 3.49.2maven_install.json
Regenerate Maven dependency lockfile
java/maven_install.json