Skip to content

Commit 1fb9e3d

Browse files
committed
8325304: Several classes in java.util.jar and java.util.zip don't specify the behaviour for null arguments
Reviewed-by: lancea, alanb
1 parent 9cccf05 commit 1fb9e3d

14 files changed

+57
-27
lines changed

src/java.base/share/classes/java/util/jar/JarEntry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -58,6 +58,7 @@ public JarEntry(String name) {
5858
* specified {@code ZipEntry} object.
5959
* @param ze the {@code ZipEntry} object to create the
6060
* {@code JarEntry} from
61+
* @throws NullPointerException if {@code ze} is null
6162
*/
6263
public JarEntry(ZipEntry ze) {
6364
super(ze);
@@ -68,6 +69,7 @@ public JarEntry(ZipEntry ze) {
6869
* specified {@code JarEntry} object.
6970
*
7071
* @param je the {@code JarEntry} to copy
72+
* @throws NullPointerException if {@code je} is null
7173
*/
7274
public JarEntry(JarEntry je) {
7375
this((ZipEntry)je);

src/java.base/share/classes/java/util/jar/JarInputStream.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,11 @@
3636
* <a href="{@docRoot}/../specs/jar/jar.html#jar-manifest">Manifest</a>
3737
* entry. The {@code Manifest} can be used to store
3838
* meta-information about the JAR file and its entries.
39-
*
39+
* <p>
40+
* Unless otherwise noted, passing a {@code null} argument to a constructor
41+
* or method in this class will cause a {@link NullPointerException} to be
42+
* thrown.
43+
* </p>
4044
* <h2>Accessing the Manifest</h2>
4145
* <p>
4246
* The {@link #getManifest() getManifest} method is used to return the
@@ -242,7 +246,6 @@ public JarEntry getNextJarEntry() throws IOException {
242246
* @param len the maximum number of bytes to read
243247
* @return the actual number of bytes read, or -1 if the end of the
244248
* entry is reached
245-
* @throws NullPointerException If {@code b} is {@code null}.
246249
* @throws IndexOutOfBoundsException If {@code off} is negative,
247250
* {@code len} is negative, or {@code len} is greater than
248251
* {@code b.length - off}

src/java.base/share/classes/java/util/jar/JarOutputStream.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
* for writing an optional {@code Manifest} entry. The
3636
* {@code Manifest} can be used to specify meta-information about
3737
* the JAR file and its entries.
38-
*
38+
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
39+
* or method in this class will cause a {@link NullPointerException} to be
40+
* thrown.
3941
* @author David Connelly
4042
* @see Manifest
4143
* @see java.util.zip.ZipOutputStream

src/java.base/share/classes/java/util/jar/Manifest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,9 @@
4343
* see the
4444
* <a href="{@docRoot}/../specs/jar/jar.html">
4545
* Manifest format specification</a>.
46+
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
47+
* or method in this class will cause a {@link NullPointerException} to be
48+
* thrown.
4649
*
4750
* @spec jar/jar.html JAR File Specification
4851
* @author David Connelly
@@ -82,7 +85,8 @@ public Manifest(InputStream is) throws IOException {
8285
* Constructs a new Manifest from the specified input stream.
8386
*
8487
* @param is the input stream containing manifest data
85-
* @param jarFilename the name of the corresponding jar archive if available
88+
* @param jarFilename the name of the corresponding jar archive
89+
* if available, else null
8690
* @throws IOException if an I/O error has occurred
8791
*/
8892
Manifest(InputStream is, String jarFilename) throws IOException {
@@ -93,7 +97,7 @@ public Manifest(InputStream is) throws IOException {
9397
* Constructs a new Manifest from the specified input stream
9498
* and associates it with a JarVerifier.
9599
*
96-
* @param jv the JarVerifier to use
100+
* @param jv the JarVerifier to use if any, else null
97101
* @param is the input stream containing manifest data
98102
* @param jarFilename the name of the corresponding jar archive if available
99103
* @throws IOException if an I/O error has occurred

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,10 @@
4444
* the <a href="package-summary.html#package-description">java.util.zip
4545
* package description</a>.
4646
* <p>
47+
* Unless otherwise noted, passing a {@code null} argument to a method
48+
* in this class will cause a {@link NullPointerException} to be
49+
* thrown.
50+
* <p>
4751
* This class deflates sequences of bytes into ZLIB compressed data format.
4852
* The input byte sequence is provided in either byte array or byte buffer,
4953
* via one of the {@code setInput()} methods. The output byte sequence is

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -164,6 +164,7 @@ public int read() throws IOException {
164164
* @param len maximum number of compressed bytes to read into {@code b}
165165
* @return the actual number of bytes read, or -1 if the end of the
166166
* uncompressed input stream is reached
167+
* @throws NullPointerException if {@code b} is null
167168
* @throws IndexOutOfBoundsException if {@code len > b.length - off}
168169
* @throws IOException if an I/O error occurs or if this input stream is
169170
* already closed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
* This class implements an output stream filter for compressing data in
3535
* the "deflate" compression format. It is also used as the basis for other
3636
* types of compression filters, such as GZIPOutputStream.
37+
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
38+
* or method in this class will cause a {@link NullPointerException} to be
39+
* thrown.
3740
*
3841
* @see Deflater
3942
* @author David Connelly

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -70,6 +70,7 @@ private void ensureOpen() throws IOException {
7070
*
7171
* @throws ZipException if a GZIP format error has occurred or the
7272
* compression method used is unsupported
73+
* @throws NullPointerException if {@code in} is null
7374
* @throws IOException if an I/O error has occurred
7475
* @throws IllegalArgumentException if {@code size <= 0}
7576
*/
@@ -85,6 +86,7 @@ public GZIPInputStream(InputStream in, int size) throws IOException {
8586
*
8687
* @throws ZipException if a GZIP format error has occurred or the
8788
* compression method used is unsupported
89+
* @throws NullPointerException if {@code in} is null
8890
* @throws IOException if an I/O error has occurred
8991
*/
9092
public GZIPInputStream(InputStream in) throws IOException {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,10 @@
3131
/**
3232
* This class implements a stream filter for writing compressed data in
3333
* the GZIP file format.
34+
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
35+
* or method in this class will cause a {@link NullPointerException} to be
36+
* thrown.
37+
*
3438
* @author David Connelly
3539
* @since 1.1
3640
*

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,10 @@
4444
* the <a href="package-summary.html#package-description">java.util.zip
4545
* package description</a>.
4646
* <p>
47+
* Unless otherwise noted, passing a {@code null} argument to a constructor
48+
* or method in this class will cause a {@link NullPointerException} to be
49+
* thrown.
50+
* <p>
4751
* This class inflates sequences of ZLIB compressed bytes. The input byte
4852
* sequence is provided in either byte array or byte buffer, via one of the
4953
* {@code setInput()} methods. The output byte sequence is written to the

0 commit comments

Comments
 (0)