-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] JSpecify annotations for By locators #14372
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍
|
PR Code Suggestions ✨
|
cd8a687
to
dfcc439
Compare
dfcc439
to
10a7219
Compare
/help |
PR Agent Walkthrough 🤖Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more. Here is a list of tools you can use to interact with the PR Agent:
(1) Note that each tool be triggered automatically when a new PR is opened, or called manually by commenting on a PR. (2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the |
/describe |
PR Description updated to latest commit (10a7219)
|
Is there a way to check in the CI that the annotations are correct? |
Yes, adding a null checker plugin to the CI building is a natural follow-up for nullness annotations. |
Could we add a check in the CI to verify the annotations are correct before merging more PRs? |
Sure! I'll play with it and share the results, I think I'll have something to show and merge next week |
@mk868, will you add unit test for this? |
@VietND96 the plan is to test nullness annotations using the NullAway.
|
@mk868, the dependent PR is merged, you can go ahead with others |
@diemol, do you think this is good to merge? |
User description
Description
In this PR I'm adding nullness annotations for classes
By
ByIdOrName
ByAll
ByChained
Common
boolean equals(Object o)
- accepts null -> an argument marked with@Nullable
Map<String, Object> toJson()
- the value in map can be null (basis on theBy.Remotable.Parameters#toJson()
-> value type marked with@Nullable
By
Remotable.Parameters
can contain null value - based on the comment "There may be subclasses where the value is optional. Allow for this." in theParameters
constructor -> value field marked with@Nullable
ByIdOrName
No null values
ByAll
No null values
ByChained
No null values
Motivation and Context
The JSpecify nullness annotations will give developers better exposure to potential problems with their code to avoid NullPointerExceptions.
Related issue: #14291
Types of changes
Checklist
PR Type
Enhancement
Description
@NullMarked
and@Nullable
) toBy
,ByIdOrName
,ByAll
, andByChained
classes to improve null safety.toJson
methods to handle nullable values.org.jspecify:jspecify
dependency to the Bazel build file.Changes walkthrough 📝
By.java
Add JSpecify nullness annotations to `By` class
java/src/org/openqa/selenium/By.java
@NullMarked
annotation to theBy
class.Object
parameters and return types with@Nullable
whereapplicable.
toJson
method to handle nullable values.ByIdOrName.java
Add JSpecify nullness annotations to `ByIdOrName` class
java/src/org/openqa/selenium/support/ByIdOrName.java
@NullMarked
annotation to theByIdOrName
class.ByAll.java
Add JSpecify nullness annotations to `ByAll` class
java/src/org/openqa/selenium/support/pagefactory/ByAll.java
@NullMarked
annotation to theByAll
class.ByChained.java
Add JSpecify nullness annotations to `ByChained` class
java/src/org/openqa/selenium/support/pagefactory/ByChained.java
@NullMarked
annotation to theByChained
class.BUILD.bazel
Add JSpecify dependency to Bazel build file
java/src/org/openqa/selenium/support/BUILD.bazel
org.jspecify:jspecify
artifact dependency.