diff --git a/src/java.base/share/classes/java/io/ObjectInput.java b/src/java.base/share/classes/java/io/ObjectInput.java index d13301ba472..4f6bf226f42 100644 --- a/src/java.base/share/classes/java/io/ObjectInput.java +++ b/src/java.base/share/classes/java/io/ObjectInput.java @@ -51,7 +51,7 @@ public interface ObjectInput extends DataInput, AutoCloseable { * @exception IOException If any of the usual Input/Output * related exceptions occur. */ - public Object readObject() + public @Nullable Object readObject() throws ClassNotFoundException, IOException; /** diff --git a/src/java.base/share/classes/java/io/ObjectInputStream.java b/src/java.base/share/classes/java/io/ObjectInputStream.java index 912c3123b2c..3eb2f2e8273 100644 --- a/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -421,7 +421,7 @@ protected ObjectInputStream() throws IOException, SecurityException { * stream instead of objects. * @throws IOException Any of the usual Input/Output related exceptions. */ - public final Object readObject() + public final @Nullable Object readObject() throws IOException, ClassNotFoundException { if (enableOverride) { @@ -467,7 +467,7 @@ public final Object readObject() * @see #readObject() * @since 1.2 */ - protected Object readObjectOverride() + protected @Nullable Object readObjectOverride() throws IOException, ClassNotFoundException { return null; @@ -522,7 +522,7 @@ protected Object readObjectOverride() * @throws IOException if an I/O error occurs during deserialization * @since 1.4 */ - public Object readUnshared() throws IOException, ClassNotFoundException { + public @Nullable Object readUnshared() throws IOException, ClassNotFoundException { // if nested read, passHandle contains handle of enclosing object int outerHandle = passHandle; try { @@ -1167,7 +1167,7 @@ public String readUTF() throws IOException { * @return the serialization filter for the stream; may be null * @since 9 */ - public final ObjectInputFilter getObjectInputFilter() { + public final @Nullable ObjectInputFilter getObjectInputFilter() { return serialFilter; } @@ -1240,7 +1240,7 @@ public final ObjectInputFilter getObjectInputFilter() { * is not {@code null} and is not the process-wide filter * @since 9 */ - public final void setObjectInputFilter(ObjectInputFilter filter) { + public final void setObjectInputFilter(@Nullable ObjectInputFilter filter) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION); diff --git a/src/java.base/share/classes/java/io/ObjectOutputStream.java b/src/java.base/share/classes/java/io/ObjectOutputStream.java index a578e7f942c..c1ad0cbd88e 100644 --- a/src/java.base/share/classes/java/io/ObjectOutputStream.java +++ b/src/java.base/share/classes/java/io/ObjectOutputStream.java @@ -373,7 +373,7 @@ public final void writeObject(@Nullable Object obj) throws IOException { * @see #writeObject(Object) * @since 1.2 */ - protected void writeObjectOverride(Object obj) throws IOException { + protected void writeObjectOverride(@Nullable Object obj) throws IOException { } /**