Skip to content

Commit 888ce3b

Browse files
authored
[java] Add JSpecify annotations to WebElement and SearchContext (#14319)
[java] Add JSpecify annotations to WebElement and SearchContext (#14291)
1 parent a5de377 commit 888ce3b

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ maven.install(
210210
"org.bouncycastle:bcpkix-jdk18on:1.78.1",
211211
"org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5",
212212
"org.hsqldb:hsqldb:2.7.3",
213+
"org.jspecify:jspecify:1.0.0",
213214
"org.junit.jupiter:junit-jupiter-api:5.10.3",
214215
"org.junit.jupiter:junit-jupiter-engine:5.10.3",
215216
"org.junit.jupiter:junit-jupiter-params:5.10.3",

java/maven_install.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
3-
"__INPUT_ARTIFACTS_HASH": 966816920,
4-
"__RESOLVED_ARTIFACTS_HASH": -1502533934,
3+
"__INPUT_ARTIFACTS_HASH": -1798640815,
4+
"__RESOLVED_ARTIFACTS_HASH": 890286156,
55
"conflict_resolution": {
66
"com.google.code.gson:gson:2.8.9": "com.google.code.gson:gson:2.11.0",
77
"com.google.errorprone:error_prone_annotations:2.3.2": "com.google.errorprone:error_prone_annotations:2.27.0",
@@ -654,6 +654,13 @@
654654
},
655655
"version": "6.2.2"
656656
},
657+
"org.jspecify:jspecify": {
658+
"shasums": {
659+
"jar": "1fad6e6be7557781e4d33729d49ae1cdc8fdda6fe477bb0cc68ce351eafdfbab",
660+
"sources": "adf0898191d55937fb3192ba971826f4f294292c4a960740f3c27310e7b70296"
661+
},
662+
"version": "1.0.0"
663+
},
657664
"org.junit.jupiter:junit-jupiter-api": {
658665
"shasums": {
659666
"jar": "6efe6e01ca1ff79b7bf4c6f1eed0b29292e166c27eaf7b00ac981a14d4de61aa",
@@ -2620,6 +2627,9 @@
26202627
"jodd.typeconverter.impl",
26212628
"jodd.util"
26222629
],
2630+
"org.jspecify:jspecify": [
2631+
"org.jspecify.annotations"
2632+
],
26232633
"org.junit.jupiter:junit-jupiter-api": [
26242634
"org.junit.jupiter.api",
26252635
"org.junit.jupiter.api.condition",
@@ -3134,6 +3144,8 @@
31343144
"org.htmlunit:htmlunit-core-js:jar:sources",
31353145
"org.jodd:jodd-util",
31363146
"org.jodd:jodd-util:jar:sources",
3147+
"org.jspecify:jspecify",
3148+
"org.jspecify:jspecify:jar:sources",
31373149
"org.junit.jupiter:junit-jupiter-api",
31383150
"org.junit.jupiter:junit-jupiter-api:jar:sources",
31393151
"org.junit.jupiter:junit-jupiter-engine",

java/src/org/openqa/selenium/BUILD.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//java:defs.bzl", "java_dist_zip", "java_export", "java_import", "javadoc")
1+
load("//java:defs.bzl", "artifact", "java_dist_zip", "java_export", "java_import", "javadoc")
22
load("//java:version.bzl", "SE_VERSION")
33
load("//java/src/org/openqa/selenium/devtools:versions.bzl", "CDP_DEPS")
44

@@ -32,8 +32,8 @@ java_export(
3232
pom_template = ":template-pom",
3333
visibility = ["//visibility:public"],
3434
deps = [
35-
# Nothing from third party
3635
":manifest",
36+
artifact("org.jspecify:jspecify"),
3737
],
3838
)
3939

java/src/org/openqa/selenium/SearchContext.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
package org.openqa.selenium;
1919

2020
import java.util.List;
21+
import org.jspecify.annotations.NullMarked;
2122

23+
@NullMarked
2224
public interface SearchContext {
2325
/**
2426
* Find all elements within the current context using the given mechanism.

java/src/org/openqa/selenium/WebElement.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
package org.openqa.selenium;
1919

2020
import java.util.List;
21+
import org.jspecify.annotations.NullMarked;
22+
import org.jspecify.annotations.Nullable;
2123

2224
/**
2325
* Represents an HTML element. Generally, all interesting operations to do with interacting with a
@@ -28,6 +30,7 @@
2830
* fails, then an {@link org.openqa.selenium.StaleElementReferenceException} is thrown, and all
2931
* future calls to this instance will fail.
3032
*/
33+
@NullMarked
3134
public interface WebElement extends SearchContext, TakesScreenshot {
3235
/**
3336
* 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 {
98101
* @param name The name of the property.
99102
* @return The property's current value or null if the value is not set.
100103
*/
101-
default String getDomProperty(String name) {
104+
default @Nullable String getDomProperty(String name) {
102105
throw new UnsupportedOperationException("getDomProperty");
103106
}
104107

@@ -122,7 +125,7 @@ default String getDomProperty(String name) {
122125
* @param name The name of the attribute.
123126
* @return The attribute's value or null if the value is not set.
124127
*/
125-
default String getDomAttribute(String name) {
128+
default @Nullable String getDomAttribute(String name) {
126129
throw new UnsupportedOperationException("getDomAttribute");
127130
}
128131

@@ -163,7 +166,7 @@ default String getDomAttribute(String name) {
163166
* @param name The name of the attribute.
164167
* @return The attribute/property's current value or null if the value is not set.
165168
*/
166-
String getAttribute(String name);
169+
@Nullable String getAttribute(String name);
167170

168171
/**
169172
* Gets result of computing the WAI-ARIA role of element.
@@ -173,7 +176,7 @@ default String getDomAttribute(String name) {
173176
*
174177
* @return the WAI-ARIA role of the element.
175178
*/
176-
default String getAriaRole() {
179+
default @Nullable String getAriaRole() {
177180
throw new UnsupportedOperationException("getAriaRole");
178181
}
179182

@@ -186,7 +189,7 @@ default String getAriaRole() {
186189
*
187190
* @return the accessible name of the element.
188191
*/
189-
default String getAccessibleName() {
192+
default @Nullable String getAccessibleName() {
190193
throw new UnsupportedOperationException("getAccessibleName");
191194
}
192195

0 commit comments

Comments
 (0)