From 609f2cd32266314a7990dabbdaaa3b30cb1b8e6f Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Wed, 6 Sep 2023 11:49:26 -0400 Subject: [PATCH] Add+fix annotations in zip+jar streams. (#40) --- .../share/classes/java/util/jar/JarInputStream.java | 2 +- .../share/classes/java/util/zip/ZipInputStream.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/util/jar/JarInputStream.java b/src/java.base/share/classes/java/util/jar/JarInputStream.java index 9d76f4101e4..1de4cedf238 100644 --- a/src/java.base/share/classes/java/util/jar/JarInputStream.java +++ b/src/java.base/share/classes/java/util/jar/JarInputStream.java @@ -140,7 +140,7 @@ private byte[] getBytes(InputStream is) * @exception SecurityException if any of the jar file entries * are incorrectly signed. */ - public ZipEntry getNextEntry() throws IOException { + public @Nullable ZipEntry getNextEntry() throws IOException { JarEntry e; if (first == null) { e = (JarEntry)super.getNextEntry(); diff --git a/src/java.base/share/classes/java/util/zip/ZipInputStream.java b/src/java.base/share/classes/java/util/zip/ZipInputStream.java index 23dc6648f2c..9a2e4ad9998 100644 --- a/src/java.base/share/classes/java/util/zip/ZipInputStream.java +++ b/src/java.base/share/classes/java/util/zip/ZipInputStream.java @@ -30,6 +30,9 @@ import org.checkerframework.checker.index.qual.LTEqLengthOf; import org.checkerframework.framework.qual.AnnotatedFor; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + import java.io.InputStream; import java.io.IOException; import java.io.EOFException; @@ -48,6 +51,7 @@ * @since 1.1 */ @AnnotatedFor({"index"}) +@NullMarked public class ZipInputStream extends InflaterInputStream implements ZipConstants { private ZipEntry entry; @@ -119,7 +123,7 @@ public ZipInputStream(InputStream in, Charset charset) { * @exception ZipException if a ZIP file error has occurred * @exception IOException if an I/O error has occurred */ - public ZipEntry getNextEntry() throws IOException { + public @Nullable ZipEntry getNextEntry() throws IOException { ensureOpen(); if (entry != null) { closeEntry();