8325304: Several classes in java.util.jar and java.util.zip don't specify the behaviour for null arguments

Reviewed-by: lancea, alanb
This commit is contained in:
Jaikiran Pai 2024-02-08 06:35:47 +00:00
parent 9cccf0515e
commit 1fb9e3d674
14 changed files with 57 additions and 27 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,6 +44,10 @@ import static java.util.zip.ZipUtils.NIO_ACCESS;
* the <a href="package-summary.html#package-description">java.util.zip
* package description</a>.
* <p>
* Unless otherwise noted, passing a {@code null} argument to a method
* in this class will cause a {@link NullPointerException} to be
* thrown.
* <p>
* This class deflates sequences of bytes into ZLIB compressed data format.
* The input byte sequence is provided in either byte array or byte buffer,
* via one of the {@code setInput()} methods. The output byte sequence is

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -164,6 +164,7 @@ public class DeflaterInputStream extends FilterInputStream {
* @param len maximum number of compressed bytes to read into {@code b}
* @return the actual number of bytes read, or -1 if the end of the
* uncompressed input stream is reached
* @throws NullPointerException if {@code b} is null
* @throws IndexOutOfBoundsException if {@code len > b.length - off}
* @throws IOException if an I/O error occurs or if this input stream is
* already closed

View file

@ -34,6 +34,9 @@ import java.io.IOException;
* This class implements an output stream filter for compressing data in
* the "deflate" compression format. It is also used as the basis for other
* types of compression filters, such as GZIPOutputStream.
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
* thrown.
*
* @see Deflater
* @author David Connelly

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -70,6 +70,7 @@ public class GZIPInputStream extends InflaterInputStream {
*
* @throws ZipException if a GZIP format error has occurred or the
* compression method used is unsupported
* @throws NullPointerException if {@code in} is null
* @throws IOException if an I/O error has occurred
* @throws IllegalArgumentException if {@code size <= 0}
*/
@ -85,6 +86,7 @@ public class GZIPInputStream extends InflaterInputStream {
*
* @throws ZipException if a GZIP format error has occurred or the
* compression method used is unsupported
* @throws NullPointerException if {@code in} is null
* @throws IOException if an I/O error has occurred
*/
public GZIPInputStream(InputStream in) throws IOException {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,6 +31,10 @@ import java.io.IOException;
/**
* This class implements a stream filter for writing compressed data in
* the GZIP file format.
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
* thrown.
*
* @author David Connelly
* @since 1.1
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,6 +44,10 @@ import static java.util.zip.ZipUtils.NIO_ACCESS;
* the <a href="package-summary.html#package-description">java.util.zip
* package description</a>.
* <p>
* Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
* thrown.
* <p>
* This class inflates sequences of ZLIB compressed bytes. The input byte
* sequence is provided in either byte array or byte buffer, via one of the
* {@code setInput()} methods. The output byte sequence is written to the

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,7 +35,9 @@ import java.util.Objects;
* This class implements a stream filter for uncompressing data in the
* "deflate" compression format. It is also used as the basis for other
* decompression filters, such as GZIPInputStream.
*
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
* thrown.
* @see Inflater
* @author David Connelly
* @since 1.1
@ -110,7 +112,7 @@ public class InflaterInputStream extends FilterInputStream {
usesDefaultInflater = true;
}
private byte[] singleByteBuf = new byte[1];
private final byte[] singleByteBuf = new byte[1];
/**
* Reads a byte of uncompressed data. This method will block until
@ -143,7 +145,6 @@ public class InflaterInputStream extends FilterInputStream {
* @param len the maximum number of bytes read
* @return the actual number of bytes inflated, or -1 if the end of the
* compressed input is reached or a preset dictionary is needed
* @throws NullPointerException If {@code b} is {@code null}.
* @throws IndexOutOfBoundsException If {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -222,7 +222,7 @@ public class ZipEntry implements ZipConstants, Cloneable {
*
* @param time
* The last modification time of the entry in local date-time
*
* @throws NullPointerException if {@code time} is null
* @see #getTimeLocal()
* @since 9
*/

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -42,7 +42,9 @@ import static java.util.zip.ZipUtils.*;
* An input stream for reading compressed and uncompressed
* {@linkplain ZipEntry ZIP file entries} from a stream of bytes in the ZIP file
* format.
*
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
* thrown.
* <H2>Reading Zip File Entries</H2>
*
* The {@link #getNextEntry()} method is used to read the next ZIP file entry
@ -304,7 +306,6 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
* may be in an inconsistent state. It is strongly recommended that the
* stream be promptly closed if an I/O error occurs.
*
* @throws NullPointerException {@inheritDoc}
* @throws IndexOutOfBoundsException {@inheritDoc}
*
* @since 9
@ -359,8 +360,6 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
* one, or both, streams may be in an inconsistent state. It is strongly
* recommended that both streams be promptly closed if an I/O error occurs.
*
* @throws NullPointerException {@inheritDoc}
*
* @since 9
*/
@Override
@ -390,7 +389,6 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
* @param len the maximum number of bytes read
* @return the actual number of bytes read, or -1 if the end of the
* entry is reached
* @throws NullPointerException if {@code b} is {@code null}.
* @throws IndexOutOfBoundsException if {@code off} is negative,
* {@code len} is negative, or {@code len} is greater than
* {@code b.length - off}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,9 @@ import sun.security.action.GetBooleanAction;
* This class implements an output stream filter for writing files in the
* ZIP file format. Includes support for both compressed and uncompressed
* entries.
*
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
* thrown.
* @author David Connelly
* @since 1.1
*/