Skip to content

Add explicit writeUTF/readUTF javadoc to LittleEndian stream classes#8299

Open
daguimu wants to merge 1 commit intogoogle:masterfrom
daguimu:fix/littleendian-utf-javadoc-1659
Open

Add explicit writeUTF/readUTF javadoc to LittleEndian stream classes#8299
daguimu wants to merge 1 commit intogoogle:masterfrom
daguimu:fix/littleendian-utf-javadoc-1659

Conversation

@daguimu
Copy link
Copy Markdown

@daguimu daguimu commented Mar 26, 2026

Problem

LittleEndianDataOutputStream.writeUTF() and LittleEndianDataInputStream.readUTF() inherit their javadoc from DataOutput and DataInput. The inherited documentation references writeShort and readUnsignedShort for the UTF string length prefix encoding, which in these classes use little-endian byte order. However, the actual implementations delegate to standard DataOutputStream.writeUTF() and DataInputStream.readUTF(), which encode the length prefix in big-endian byte order.

Root Cause

These methods had no explicit javadoc, so they inherited documentation that became misleading in the context of little-endian stream classes.

Fix

  • Added explicit javadoc to writeUTF() in LittleEndianDataOutputStream clarifying the big-endian length prefix
  • Added explicit javadoc to readUTF() in LittleEndianDataInputStream clarifying the big-endian length prefix
  • Applied to both JRE and Android variants

Impact

Javadoc-only change. No behavioral change. Prevents users from incorrectly assuming the UTF length prefix is little-endian.

Fixes #1659

The inherited javadoc from DataOutput/DataInput references writeShort
and readUnsignedShort for the UTF length prefix, which in these classes
use little-endian byte order. However, writeUTF/readUTF actually
delegate to standard DataOutputStream/DataInputStream, which use
big-endian for the length prefix. This is misleading.

Added explicit javadoc to clarify that the 2-byte UTF length prefix
uses big-endian byte order, unlike the other methods in these classes.

Fixes google#1659
@chaoren chaoren added type=api-docs Change/add API documentation status=triaged package=io P3 no SLO labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 no SLO package=io status=triaged type=api-docs Change/add API documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API documentation for LittleEndianDataOutputStream.writeUTF and LittleEndianDataInputStream.readUTF is misleading

2 participants