diff --git a/MODULE.bazel b/MODULE.bazel index 7c121fef1f9b5..0ee03b3fc581c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -210,6 +210,7 @@ maven.install( "org.bouncycastle:bcpkix-jdk18on:1.78.1", "org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5", "org.hsqldb:hsqldb:2.7.3", + "org.jspecify:jspecify:1.0.0", "org.junit.jupiter:junit-jupiter-api:5.10.3", "org.junit.jupiter:junit-jupiter-engine:5.10.3", "org.junit.jupiter:junit-jupiter-params:5.10.3", diff --git a/java/maven_install.json b/java/maven_install.json index 20c9884b32628..f5722636b1062 100644 --- a/java/maven_install.json +++ b/java/maven_install.json @@ -1,7 +1,7 @@ { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": 966816920, - "__RESOLVED_ARTIFACTS_HASH": -1502533934, + "__INPUT_ARTIFACTS_HASH": -1798640815, + "__RESOLVED_ARTIFACTS_HASH": 890286156, "conflict_resolution": { "com.google.code.gson:gson:2.8.9": "com.google.code.gson:gson:2.11.0", "com.google.errorprone:error_prone_annotations:2.3.2": "com.google.errorprone:error_prone_annotations:2.27.0", @@ -654,6 +654,13 @@ }, "version": "6.2.2" }, + "org.jspecify:jspecify": { + "shasums": { + "jar": "1fad6e6be7557781e4d33729d49ae1cdc8fdda6fe477bb0cc68ce351eafdfbab", + "sources": "adf0898191d55937fb3192ba971826f4f294292c4a960740f3c27310e7b70296" + }, + "version": "1.0.0" + }, "org.junit.jupiter:junit-jupiter-api": { "shasums": { "jar": "6efe6e01ca1ff79b7bf4c6f1eed0b29292e166c27eaf7b00ac981a14d4de61aa", @@ -2620,6 +2627,9 @@ "jodd.typeconverter.impl", "jodd.util" ], + "org.jspecify:jspecify": [ + "org.jspecify.annotations" + ], "org.junit.jupiter:junit-jupiter-api": [ "org.junit.jupiter.api", "org.junit.jupiter.api.condition", @@ -3134,6 +3144,8 @@ "org.htmlunit:htmlunit-core-js:jar:sources", "org.jodd:jodd-util", "org.jodd:jodd-util:jar:sources", + "org.jspecify:jspecify", + "org.jspecify:jspecify:jar:sources", "org.junit.jupiter:junit-jupiter-api", "org.junit.jupiter:junit-jupiter-api:jar:sources", "org.junit.jupiter:junit-jupiter-engine", diff --git a/java/src/org/openqa/selenium/BUILD.bazel b/java/src/org/openqa/selenium/BUILD.bazel index 8a26ac79a8f4a..94d243ec83524 100644 --- a/java/src/org/openqa/selenium/BUILD.bazel +++ b/java/src/org/openqa/selenium/BUILD.bazel @@ -1,4 +1,4 @@ -load("//java:defs.bzl", "java_dist_zip", "java_export", "java_import", "javadoc") +load("//java:defs.bzl", "artifact", "java_dist_zip", "java_export", "java_import", "javadoc") load("//java:version.bzl", "SE_VERSION") load("//java/src/org/openqa/selenium/devtools:versions.bzl", "CDP_DEPS") @@ -32,8 +32,8 @@ java_export( pom_template = ":template-pom", visibility = ["//visibility:public"], deps = [ - # Nothing from third party ":manifest", + artifact("org.jspecify:jspecify"), ], ) diff --git a/java/src/org/openqa/selenium/SearchContext.java b/java/src/org/openqa/selenium/SearchContext.java index 1eb614b3aac4c..9da7967fe5b26 100644 --- a/java/src/org/openqa/selenium/SearchContext.java +++ b/java/src/org/openqa/selenium/SearchContext.java @@ -18,7 +18,9 @@ package org.openqa.selenium; import java.util.List; +import org.jspecify.annotations.NullMarked; +@NullMarked public interface SearchContext { /** * Find all elements within the current context using the given mechanism. diff --git a/java/src/org/openqa/selenium/WebElement.java b/java/src/org/openqa/selenium/WebElement.java index 5dc7b8c8d9113..8f9029ec2fd97 100644 --- a/java/src/org/openqa/selenium/WebElement.java +++ b/java/src/org/openqa/selenium/WebElement.java @@ -18,6 +18,8 @@ package org.openqa.selenium; import java.util.List; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Represents an HTML element. Generally, all interesting operations to do with interacting with a @@ -28,6 +30,7 @@ * fails, then an {@link org.openqa.selenium.StaleElementReferenceException} is thrown, and all * future calls to this instance will fail. */ +@NullMarked public interface WebElement extends SearchContext, TakesScreenshot { /** * Click this element. If this causes a new page to load, you should discard all references to @@ -98,7 +101,7 @@ public interface WebElement extends SearchContext, TakesScreenshot { * @param name The name of the property. * @return The property's current value or null if the value is not set. */ - default String getDomProperty(String name) { + default @Nullable String getDomProperty(String name) { throw new UnsupportedOperationException("getDomProperty"); } @@ -122,7 +125,7 @@ default String getDomProperty(String name) { * @param name The name of the attribute. * @return The attribute's value or null if the value is not set. */ - default String getDomAttribute(String name) { + default @Nullable String getDomAttribute(String name) { throw new UnsupportedOperationException("getDomAttribute"); } @@ -163,7 +166,7 @@ default String getDomAttribute(String name) { * @param name The name of the attribute. * @return The attribute/property's current value or null if the value is not set. */ - String getAttribute(String name); + @Nullable String getAttribute(String name); /** * Gets result of computing the WAI-ARIA role of element. @@ -173,7 +176,7 @@ default String getDomAttribute(String name) { * * @return the WAI-ARIA role of the element. */ - default String getAriaRole() { + default @Nullable String getAriaRole() { throw new UnsupportedOperationException("getAriaRole"); } @@ -186,7 +189,7 @@ default String getAriaRole() { * * @return the accessible name of the element. */ - default String getAccessibleName() { + default @Nullable String getAccessibleName() { throw new UnsupportedOperationException("getAccessibleName"); }