diff --git a/src/java.base/share/classes/java/io/BufferedInputStream.java b/src/java.base/share/classes/java/io/BufferedInputStream.java
index d023349d6da..095a84b6249 100644
--- a/src/java.base/share/classes/java/io/BufferedInputStream.java
+++ b/src/java.base/share/classes/java/io/BufferedInputStream.java
@@ -91,7 +91,7 @@ public class BufferedInputStream extends FilterInputStream {
* indicator that this stream is closed. (The "in" field is also
* nulled out on close.)
*/
- protected volatile byte[] buf;
+ protected volatile byte @Nullable [] buf;
/**
* The index one greater than the index of the last valid byte in
diff --git a/src/java.base/share/classes/java/io/FilterInputStream.java b/src/java.base/share/classes/java/io/FilterInputStream.java
index 1ee9f0f31e2..e631e23dfed 100644
--- a/src/java.base/share/classes/java/io/FilterInputStream.java
+++ b/src/java.base/share/classes/java/io/FilterInputStream.java
@@ -46,7 +46,7 @@ public class FilterInputStream extends InputStream {
/**
* The input stream to be filtered.
*/
- protected volatile InputStream in;
+ protected volatile @Nullable InputStream in;
/**
* Creates a {@code FilterInputStream}
diff --git a/src/java.base/share/classes/java/lang/ClassLoader.java b/src/java.base/share/classes/java/lang/ClassLoader.java
index f0e2bb8d938..a808f84abe9 100644
--- a/src/java.base/share/classes/java/lang/ClassLoader.java
+++ b/src/java.base/share/classes/java/lang/ClassLoader.java
@@ -2091,7 +2091,7 @@ protected Package definePackage( String name, @Nullable String specTitle,
*
* @since 9
*/
- public final Package getDefinedPackage(String name) {
+ public final @Nullable Package getDefinedPackage(String name) {
Objects.requireNonNull(name, "name cannot be null");
NamedPackage p = packages.get(name);
diff --git a/src/java.base/share/classes/java/net/URL.java b/src/java.base/share/classes/java/net/URL.java
index 6f5ad345843..873c7752c06 100644
--- a/src/java.base/share/classes/java/net/URL.java
+++ b/src/java.base/share/classes/java/net/URL.java
@@ -961,7 +961,7 @@ synchronized InetAddress getHostAddress() {
* or null if one does not exist
* @since 1.3
*/
- public String getQuery() {
+ public @Nullable String getQuery() {
return query;
}
@@ -983,7 +983,7 @@ public String getPath() {
* null if one does not exist
* @since 1.3
*/
- public String getUserInfo() {
+ public @Nullable String getUserInfo() {
return userInfo;
}
@@ -993,7 +993,7 @@ public String getUserInfo() {
* @return the authority part of this {@code URL}
* @since 1.3
*/
- public String getAuthority() {
+ public @Nullable String getAuthority() {
return authority;
}
@@ -1062,7 +1062,7 @@ public String getFile() {
* @return the anchor (also known as the "reference") of this
* {@code URL}, or null if one does not exist
*/
- public String getRef() {
+ public @Nullable String getRef() {
return ref;
}
diff --git a/src/java.base/share/classes/java/security/AlgorithmParameters.java b/src/java.base/share/classes/java/security/AlgorithmParameters.java
index 2a6fe830ba9..fdcdf8ae01f 100644
--- a/src/java.base/share/classes/java/security/AlgorithmParameters.java
+++ b/src/java.base/share/classes/java/security/AlgorithmParameters.java
@@ -29,6 +29,7 @@
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import java.util.Objects;
+import org.jspecify.annotations.Nullable;
/**
* This class is used as an opaque representation of cryptographic parameters.
@@ -420,7 +421,7 @@ public final byte[] getEncoded(String format) throws IOException
* @return a formatted string describing the parameters, or {@code null}
* if this parameter object has not been initialized.
*/
- public final String toString() {
+ public final @Nullable String toString() {
if (!this.initialized) {
return null;
}
diff --git a/src/java.base/share/classes/java/util/regex/Matcher.java b/src/java.base/share/classes/java/util/regex/Matcher.java
index 5e10211b2de..edfbb334087 100644
--- a/src/java.base/share/classes/java/util/regex/Matcher.java
+++ b/src/java.base/share/classes/java/util/regex/Matcher.java
@@ -644,7 +644,7 @@ public int end(String name) {
* or if the previous match operation failed
*/
- public String group() {
+ public @Nullable String group() {
return group(0);
}
diff --git a/src/java.desktop/share/classes/java/awt/Component.java b/src/java.desktop/share/classes/java/awt/Component.java
index 5aed78c77f8..85d43eb2fc3 100644
--- a/src/java.desktop/share/classes/java/awt/Component.java
+++ b/src/java.desktop/share/classes/java/awt/Component.java
@@ -991,7 +991,7 @@ void initializeFocusTraversalKeys() {
* Constructs a name for this component. Called by {@code getName}
* when the name is {@code null}.
*/
- @Nullable String constructComponentName() {
+ String constructComponentName() {
return null; // For strict compliance with prior platform versions, a Component
// that doesn't set its name should return null from
// getName()
@@ -1003,7 +1003,7 @@ void initializeFocusTraversalKeys() {
* @see #setName
* @since 1.1
*/
- public String getName() {
+ public @Nullable String getName() {
if (name == null && !nameExplicitlySet) {
synchronized(getObjectLock()) {
if (name == null && !nameExplicitlySet)
@@ -1020,7 +1020,7 @@ public String getName() {
* @see #getName
* @since 1.1
*/
- public void setName(String name) {
+ public void setName(@Nullable String name) {
String oldName;
synchronized(getObjectLock()) {
oldName = this.name;
diff --git a/src/java.desktop/share/classes/java/awt/Container.java b/src/java.desktop/share/classes/java/awt/Container.java
index c09e8dd4395..15d6cb4283c 100644
--- a/src/java.desktop/share/classes/java/awt/Container.java
+++ b/src/java.desktop/share/classes/java/awt/Container.java
@@ -2668,7 +2668,7 @@ boolean isSameOrAncestorOf(Component comp, boolean allowChildren) {
* @see #getComponentAt
* @since 1.2
*/
- public Component findComponentAt(int x, int y) {
+ public @Nullable Component findComponentAt(int x, int y) {
return findComponentAt(x, y, true);
}
@@ -2763,7 +2763,7 @@ private static Component getChildAt(Component comp, int x, int y,
* @see #getComponentAt
* @since 1.2
*/
- public Component findComponentAt(Point p) {
+ public @Nullable Component findComponentAt(Point p) {
return findComponentAt(p.x, p.y);
}
diff --git a/src/java.sql/share/classes/java/sql/ResultSet.java b/src/java.sql/share/classes/java/sql/ResultSet.java
index ec97dc9ee47..c5ea06764b5 100644
--- a/src/java.sql/share/classes/java/sql/ResultSet.java
+++ b/src/java.sql/share/classes/java/sql/ResultSet.java
@@ -652,7 +652,7 @@ public interface ResultSet extends Wrapper, AutoCloseable {
* or {@code getBigDecimal(String columnLabel)}
*/
@Deprecated(since="1.2")
- BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException;
+ @Nullable BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException;
/**
* Retrieves the value of the designated column in the current row
@@ -795,7 +795,7 @@ public interface ResultSet extends Wrapper, AutoCloseable {
* if a database access error occurs or this method is
* called on a closed result set
*/
- java.io.InputStream getBinaryStream(String columnLabel)
+ java.io.@Nullable InputStream getBinaryStream(String columnLabel)
throws SQLException;
@@ -2493,7 +2493,7 @@ void updateObject(String columnLabel, @Nullable Object x, int scaleOrLength)
* this method
* @since 1.2
*/
- Blob getBlob(int columnIndex) throws SQLException;
+ @Nullable Blob getBlob(int columnIndex) throws SQLException;
/**
* Retrieves the value of the designated column in the current row
@@ -4115,7 +4115,7 @@ void updateCharacterStream(String columnLabel,
* this method
* @since 1.7
*/
- public @Nullable T getObject(int columnIndex, Class type) throws SQLException;
+ public @Nullable T getObject(int columnIndex, Class type) throws SQLException;
/**
@@ -4146,7 +4146,7 @@ void updateCharacterStream(String columnLabel,
* this method
* @since 1.7
*/
- public @Nullable T getObject(String columnLabel, Class type) throws SQLException;
+ public @Nullable T getObject(String columnLabel, Class type) throws SQLException;
//------------------------- JDBC 4.2 -----------------------------------