Skip to content

Commit 0db798e

Browse files
committed
Annotate java.util.zip.
Prompted by google/xplat@4461165.
1 parent 457b292 commit 0db798e

File tree

8 files changed

+24
-16
lines changed

8 files changed

+24
-16
lines changed

src/java.base/share/classes/java/util/zip/Adler32.java

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import jdk.internal.util.Preconditions;
3131
import jdk.internal.vm.annotation.IntrinsicCandidate;
3232
import sun.nio.ch.DirectBuffer;
33+
import org.jspecify.annotations.NullMarked;
3334

3435
import static java.util.zip.ZipUtils.NIO_ACCESS;
3536

@@ -44,6 +45,7 @@
4445
* @author David Connelly
4546
* @since 1.1
4647
*/
48+
@NullMarked
4749
public class Adler32 implements Checksum {
4850

4951
private int adler = 1;

src/java.base/share/classes/java/util/zip/Checksum.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828
import org.checkerframework.framework.qual.AnnotatedFor;
2929

3030
import java.nio.ByteBuffer;
31+
import org.jspecify.annotations.NullMarked;
3132

3233
/**
3334
* An interface representing a data checksum.
3435
*
3536
* @author David Connelly
3637
* @since 1.1
3738
*/
38-
@AnnotatedFor({"index"})
39+
@NullMarked
3940
public interface Checksum {
4041

4142
/**
@@ -69,7 +70,7 @@ default public void update(byte[] b) {
6970
* @param off the start offset of the data
7071
* @param len the number of bytes to use for the update
7172
*/
72-
public void update(byte[] b, @IndexOrHigh({"#1"}) int off, @IndexOrHigh({"#1"}) int len);
73+
public void update(byte[] b, int off, int len);
7374

7475
/**
7576
* Updates the current checksum with the bytes from the specified buffer.

src/java.base/share/classes/java/util/zip/DataFormatException.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@
2525

2626
package java.util.zip;
2727

28+
import org.jspecify.annotations.NullMarked;
29+
import org.jspecify.annotations.Nullable;
30+
2831
/**
2932
* Signals that a data format error has occurred.
3033
*
3134
* @author David Connelly
3235
* @since 1.1
3336
*/
37+
@NullMarked
3438
public class DataFormatException extends Exception {
3539
@java.io.Serial
3640
private static final long serialVersionUID = 2219632870893641452L;
@@ -47,7 +51,7 @@ public DataFormatException() {
4751
* A detail message is a String that describes this particular exception.
4852
* @param s the String containing a detail message
4953
*/
50-
public DataFormatException(String s) {
54+
public DataFormatException(@Nullable String s) {
5155
super(s);
5256
}
5357
}

src/java.base/share/classes/java/util/zip/Deflater.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import jdk.internal.ref.CleanerFactory;
3434
import jdk.internal.util.Preconditions;
3535
import sun.nio.ch.DirectBuffer;
36+
import org.jspecify.annotations.NullMarked;
3637

3738
import static java.util.zip.ZipUtils.NIO_ACCESS;
3839

@@ -70,7 +71,7 @@
7071
* @author David Connelly
7172
* @since 1.1
7273
*/
73-
74+
@NullMarked
7475
public class Deflater {
7576

7677
private final DeflaterZStreamRef zsRef;

src/java.base/share/classes/java/util/zip/DeflaterOutputStream.java

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.io.OutputStream;
3030
import java.io.InputStream;
3131
import java.io.IOException;
32+
import org.jspecify.annotations.NullMarked;
3233

3334
/**
3435
* This class implements an output stream filter for compressing data in
@@ -42,6 +43,7 @@
4243
* @author David Connelly
4344
* @since 1.1
4445
*/
46+
@NullMarked
4547
public class DeflaterOutputStream extends FilterOutputStream {
4648
/**
4749
* Compressor for this stream.

src/java.base/share/classes/java/util/zip/Inflater.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import jdk.internal.ref.CleanerFactory;
3434
import jdk.internal.util.Preconditions;
3535
import sun.nio.ch.DirectBuffer;
36+
import org.jspecify.annotations.NullMarked;
3637

3738
import static java.util.zip.ZipUtils.NIO_ACCESS;
3839

@@ -70,7 +71,7 @@
7071
* @since 1.1
7172
*
7273
*/
73-
74+
@NullMarked
7475
public class Inflater {
7576

7677
private final InflaterZStreamRef zsRef;

src/java.base/share/classes/java/util/zip/InflaterOutputStream.java

+4-9
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@
2525

2626
package java.util.zip;
2727

28-
import org.checkerframework.checker.index.qual.IndexOrHigh;
29-
import org.checkerframework.checker.index.qual.Positive;
30-
import org.checkerframework.checker.signedness.qual.PolySigned;
31-
import org.checkerframework.framework.qual.AnnotatedFor;
32-
3328
import java.io.FilterOutputStream;
3429
import java.io.IOException;
3530
import java.io.OutputStream;
3631
import java.util.Objects;
32+
import org.jspecify.annotations.NullMarked;
3733

3834
/**
3935
* Implements an output stream filter for uncompressing data stored in the
@@ -46,8 +42,7 @@
4642
* @see DeflaterInputStream
4743
* @see DeflaterOutputStream
4844
*/
49-
50-
@AnnotatedFor({"index", "signedness"})
45+
@NullMarked
5146
public class InflaterOutputStream extends FilterOutputStream {
5247
/** Decompressor for this stream. */
5348
protected final Inflater inf;
@@ -107,7 +102,7 @@ public InflaterOutputStream(OutputStream out, Inflater infl) {
107102
* @throws IllegalArgumentException if {@code bufLen <= 0}
108103
* @throws NullPointerException if {@code out} or {@code infl} is null
109104
*/
110-
public InflaterOutputStream(OutputStream out, Inflater infl, @Positive int bufLen) {
105+
public InflaterOutputStream(OutputStream out, Inflater infl, int bufLen) {
111106
super(out);
112107

113108
// Sanity checks
@@ -225,7 +220,7 @@ public void write(int b) throws IOException {
225220
* @throws NullPointerException if {@code b} is null
226221
* @throws ZipException if a compression (ZIP) format error occurs
227222
*/
228-
public void write(@PolySigned byte[] b, @IndexOrHigh({"#1"}) int off, @IndexOrHigh({"#1"}) int len) throws IOException {
223+
public void write(byte[] b, int off, int len) throws IOException {
229224
// Sanity checks
230225
ensureOpen();
231226
if (b == null) {

src/java.base/share/classes/java/util/zip/ZipException.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@
2626
package java.util.zip;
2727

2828
import java.io.IOException;
29+
import org.jspecify.annotations.NullMarked;
30+
import org.jspecify.annotations.Nullable;
2931

3032
/**
3133
* Signals that a ZIP exception of some sort has occurred.
3234
*
3335
* @see java.io.IOException
3436
* @since 1.1
3537
*/
36-
38+
@NullMarked
3739
public class ZipException extends IOException {
3840
@java.io.Serial
3941
private static final long serialVersionUID = 8000196834066748623L;
@@ -53,7 +55,7 @@ public ZipException() {
5355
* @param s the detail message.
5456
*/
5557

56-
public ZipException(String s) {
58+
public ZipException(@Nullable String s) {
5759
super(s);
5860
}
5961
}

0 commit comments

Comments
 (0)