On Tue, 7 Apr 2026 19:29:49 GMT, Lance Andersen <[email protected]> wrote:

> I feel it can be handled within this PR as we really only need to indicate 
> that UTF-8 is the default charset and`ZipOutputStream(OutputStream, CharSet)` 
> may be used to specify an alternative charset
> 
> Let's see what Alan/Jai have for a preference.
> 
> Worst case, a PR for the clarifying the charset within the class description 
> could be addressed 1st.

Okay, on second thought I think you're right and I was just getting a bit 
impatient here for no good reason.

While waiting for Alan/Jai preferences and just help understand what you're 
looking for, is the following structure similar to what you intended? (Details 
can be sorted later).


Index: src/java.base/share/classes/java/util/zip/ZipOutputStream.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/java.base/share/classes/java/util/zip/ZipOutputStream.java 
b/src/java.base/share/classes/java/util/zip/ZipOutputStream.java
--- a/src/java.base/share/classes/java/util/zip/ZipOutputStream.java    
(revision e22b8072173879a71b2b577127ba4b67e79d9869)
+++ b/src/java.base/share/classes/java/util/zip/ZipOutputStream.java    (date 
1775593037904)
@@ -43,6 +43,10 @@
  * <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> A {@code ZipOutputStream} uses a {@linkplain Charset} to encode entry 
names,
+ * entry comments and ZIP file comments. A stream created without specifying
+ * a {@code Charset} uses UTF-8 to encode strings.
+ *
  * @author      David Connelly
  * @since 1.1
  */
@@ -110,10 +114,7 @@
     public static final int DEFLATED = ZipEntry.DEFLATED;
 
     /**
-     * Creates a new ZIP output stream.
-     *
-     * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used
-     * to encode the entry names and comments.
+     * Creates a new ZIP output stream using UTF-8 to encode strings.
      *
      * @param out the actual output stream
      */
@@ -122,12 +123,12 @@
     }
 
     /**
-     * Creates a new ZIP output stream.
+     * Creates a new ZIP output stream using the provided {@code Charset} to 
encode strings
      *
      * @param out the actual output stream
      *
      * @param charset the {@linkplain java.nio.charset.Charset charset}
-     *                to be used to encode the entry names and comments
+     *                used for string encoding
      *
      * @since 1.7
      */
@@ -148,7 +149,7 @@
      * @throws    IllegalArgumentException if the length of the specified ZIP 
file
      *            comment is greater than 0xFFFF bytes or if the {@code 
comment}
      *            contains characters that cannot be mapped by the {@code 
Charset}
-     *            used to encode entry names and comments
+     *            of this {@code ZipOutputStream}
      */
     public void setComment(String comment) {
         byte[] bytes = null;

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/30338#discussion_r3047670251

Reply via email to