RFR: 8339699: Optimize DataOutputStream writeUTF [v5]

Chen Liang liach at openjdk.org
Thu Sep 19 19:03:36 UTC 2024


On Mon, 16 Sep 2024 14:23:52 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> PR #20772 introduced an optimization for writeUTF, which can also be used in DataOutputStream::writeUTF.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
> 
>   suggestion from @liach

Changes requested by liach (Reviewer).

src/java.base/share/classes/java/io/ObjectOutputStream.java line 2047:

> 2045:                     writeByte(TC_LONGSTRING);
> 2046:                 }
> 2047:                 writeLong(utflen);

The old plain `writeUTF` does not write a long utf if the length is too long, but rather throws an `UTFDataFormatException`. There should be code paths that no longer throw this exception, because a few tests, including:
- `java/io/Serializable/longString/LongString.java`
- `java/io/Serializable/sanityCheck/SanityCheck.java`
- `java/text/Format/DateFormat/DateFormatRegression.java`
are failing. I think this might be the root cause.

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

PR Review: https://git.openjdk.org/jdk/pull/20886#pullrequestreview-2316520096
PR Review Comment: https://git.openjdk.org/jdk/pull/20886#discussion_r1767459534


More information about the core-libs-dev mailing list