-
-
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_levelflag:--//java:nullaway_level=WARN--//java:nullaway_level=ERRORFor 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-qualto version3.49.2because 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-qualdependency from 3.21.2 to 3.49.2Creates custom
java_librarywrapper with conditional NullAway plugin injectionDiagram Walkthrough
File Walkthrough
java_library.bzl
Add custom java_library wrapper with NullAway supportjava/private/java_library.bzl
java_librarywrapper functionorg.openqa.seleniumexport.bzl
Switch to custom java_library wrapperjava/private/export.bzl
java_libraryfrom contrib_rules_jvmjava_libraryfrom local wrapper modulelibrary.bzl
Update library imports to use wrapperjava/private/library.bzl
java_libraryimport from contrib_rules_jvmjava_libraryfrom wrapper moduleBUILD.bazel
Configure NullAway plugin and build flagsjava/BUILD.bazel
nullawayjava_plugin with uber.nullaway dependencynullaway_levelstring flag with NONE/WARN/ERROR valuesMODULE.bazel
Add NullAway and update checker-qual dependenciesMODULE.bazel
com.uber.nullaway:nullaway:0.12.10dependencyorg.checkerframework:checker-qualfrom 3.21.2 to 3.49.2maven_install.json
Regenerate Maven dependency lockfilejava/maven_install.json