Skip to content

Commit

Permalink
Annotate much of java.util.zip. (#106)
Browse files Browse the repository at this point in the history
Prompted by
google/xplat@4461165.

Co-authored-by: Werner Dietl <[email protected]>
  • Loading branch information
cpovirk and wmdietl authored Dec 18, 2024
1 parent f669c5b commit 9d345e7
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/util/zip/Adler32.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import jdk.internal.util.Preconditions;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import sun.nio.ch.DirectBuffer;
import org.jspecify.annotations.NullMarked;

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

Expand All @@ -44,6 +45,7 @@
* @author David Connelly
* @since 1.1
*/
@NullMarked
public class Adler32 implements Checksum {

private int adler = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/util/zip/Checksum.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
package java.util.zip;

import java.nio.ByteBuffer;
import org.jspecify.annotations.NullMarked;

/**
* An interface representing a data checksum.
*
* @author David Connelly
* @since 1.1
*/
@NullMarked
public interface Checksum {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@

package java.util.zip;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Signals that a data format error has occurred.
*
* @author David Connelly
* @since 1.1
*/
@NullMarked
public class DataFormatException extends Exception {
@java.io.Serial
private static final long serialVersionUID = 2219632870893641452L;
Expand All @@ -47,7 +51,7 @@ public DataFormatException() {
* A detail message is a String that describes this particular exception.
* @param s the String containing a detail message
*/
public DataFormatException(String s) {
public DataFormatException(@Nullable String s) {
super(s);
}
}
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/util/zip/Deflater.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import jdk.internal.ref.CleanerFactory;
import jdk.internal.util.Preconditions;
import sun.nio.ch.DirectBuffer;
import org.jspecify.annotations.NullMarked;

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

Expand Down Expand Up @@ -70,7 +71,7 @@
* @author David Connelly
* @since 1.1
*/

@NullMarked
public class Deflater {

private final DeflaterZStreamRef zsRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.OutputStream;
import java.io.InputStream;
import java.io.IOException;
import org.jspecify.annotations.NullMarked;

/**
* This class implements an output stream filter for compressing data in
Expand All @@ -42,6 +43,7 @@
* @author David Connelly
* @since 1.1
*/
@NullMarked
public class DeflaterOutputStream extends FilterOutputStream {
/**
* Compressor for this stream.
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/util/zip/Inflater.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import jdk.internal.ref.CleanerFactory;
import jdk.internal.util.Preconditions;
import sun.nio.ch.DirectBuffer;
import org.jspecify.annotations.NullMarked;

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

Expand Down Expand Up @@ -70,7 +71,7 @@
* @since 1.1
*
*/

@NullMarked
public class Inflater {

private final InflaterZStreamRef zsRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;
import org.jspecify.annotations.NullMarked;

/**
* Implements an output stream filter for uncompressing data stored in the
Expand All @@ -41,7 +42,7 @@
* @see DeflaterInputStream
* @see DeflaterOutputStream
*/

@NullMarked
public class InflaterOutputStream extends FilterOutputStream {
/** Decompressor for this stream. */
protected final Inflater inf;
Expand Down
6 changes: 4 additions & 2 deletions src/java.base/share/classes/java/util/zip/ZipException.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
package java.util.zip;

import java.io.IOException;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Signals that a ZIP exception of some sort has occurred.
*
* @see java.io.IOException
* @since 1.1
*/

@NullMarked
public class ZipException extends IOException {
@java.io.Serial
private static final long serialVersionUID = 8000196834066748623L;
Expand All @@ -53,7 +55,7 @@ public ZipException() {
* @param s the detail message.
*/

public ZipException(String s) {
public ZipException(@Nullable String s) {
super(s);
}
}

0 comments on commit 9d345e7

Please sign in to comment.