You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this PR I'm adding nullness annotations for classes:
org.openqa.selenium.interactions.Coordinates
org.openqa.selenium.interactions.Interactive
org.openqa.selenium.interactions.SourceType - I also changed null to "none" as descried in the w3.org, this change should be safe to apply because SourceType.NONE has no uses in the code.
The JSpecify nullness annotations will give developers better exposure to potential problems with their code to avoid NullPointerExceptions.
Related issue: #14291
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Add JSpecify Nullness annotations to Selenium framework code
Improve IDE and static code analyzer support for null checks
Non-compliant requirements:
Annotations should specify which parameters and return values can be null (only class-level @NullMarked added, no specific parameter/return annotations)
Requires further human verification:
Enhance interoperability with Kotlin (needs testing with Kotlin codebase)
Changing NONE from null to "none" string value might affect existing code that relies on the null value. Verify this change aligns with w3.org spec and won't break existing implementations.
Consider adding a null check in the constructor since type is now used for all enum values including NONE. This prevents potential NullPointerException when the enum is used.
private final String type;
+private SourceType(String type) {+ if (type == null) {+ throw new IllegalArgumentException("Type cannot be null");+ }+ this.type = type;+}+
Apply this suggestion
Suggestion importance[1-10]: 8
Why: The suggestion is highly relevant as it adds crucial null validation to prevent potential NullPointerException, especially important since the PR changes NONE's value from null to "none" and adds @NullMarked annotation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Description
In this PR I'm adding nullness annotations for classes:
org.openqa.selenium.interactions.Coordinatesorg.openqa.selenium.interactions.Interactiveorg.openqa.selenium.interactions.SourceType- I also changednullto"none"as descried in the w3.org, this change should be safe to apply becauseSourceType.NONEhas no uses in the code.NullAway analysis: #14421
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
Added JSpecify
@NullMarkedannotations to improve nullness handling.Updated
SourceType.NONEvalue fromnullto"none"for compliance.Enhanced IDE and static analysis support for nullability.
Changes walkthrough 📝
Coordinates.java
Add `@NullMarked` annotation to `Coordinates`java/src/org/openqa/selenium/interactions/Coordinates.java
@NullMarkedannotation to theCoordinatesinterface.Interactive.java
Add `@NullMarked` annotation to `Interactive`java/src/org/openqa/selenium/interactions/Interactive.java
@NullMarkedannotation to theInteractiveinterface.SourceType.java
Add `@NullMarked` annotation and update `SourceType.NONE`java/src/org/openqa/selenium/interactions/SourceType.java
@NullMarkedannotation to theSourceTypeenum.SourceType.NONEvalue fromnullto"none".