JDK-4296707 : (spec) DataOutputStream javadoc is incomplete (e.g limit on strings size)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-12-03
  • Updated: 2024-04-06
  • Resolved: 2024-04-06
Related Reports
Duplicate :  
Description
Name: skT88420			Date: 12/03/99


Independent of version: documentation bug


The javadoc for the class DataOutputStream is incomplete.

For example the writeUTF method does not document the limitation
in string size as documented in the JLS. As a result, developers are 
surprised to receive an IOException that they can interprete as a network 
error, when the trouble is only that the string length was exceeded. It 
happened to me and it's a time consumming debugging activity!
At least the throws clause should document the UTFDataFormatError when
"the total number of bytes needed to represent all the characters of s is
calculated." Then a method should be provided to let users of the class 
DataOutputStream know if they string is larger than the accepted size 
without waiting for the exception to occur or duplicate the code in
DataOutputStream.writeUTF.

Check it:
http://java.sun.com/products/jdk/1.2/docs/api/java/io/DataOutputStream.html#writeUTF(java.lang.String)

Suggestion: reproduce the documentation from the JLS section 22.2.14
(that very throughout!) into the javadoc.
Note: this bug is obviously also in 1.1 code base (1.1.8)
(Review ID: 98590) 
======================================================================

Comments
This got addressed in https://bugs.openjdk.org/browse/JDK-8219196
06-04-2024

EVALUATION I don't have my copy of the JLS (1st ed) with me right now, but we made a pass to merge the JLS documentation with the javadoc in the source file in the merlin (jdk1.3) time-frame. Significant differences between the JLS and the class javadoc may no longer exist. DataOutputStream implements DataOutput. In DataOutput.writeUTF, we mention the possibility of a UTFDataFormatException in the method description (we appear to have fogotten to put this into an @throws). Minimally, we should add the @throws to DataOutput{Stream}.writeUTF. ###@###.### 2005-1-28 20:59:07 GMT
28-01-2005