JDK-8131664 : Javadoc for PrintStream is now incorrect
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-07-14
  • Updated: 2020-10-13
  • Resolved: 2019-07-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 14
14 b07Fixed
Related Reports
CSR :  
Relates :  
Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
javadoc so platform is irrelevant

EXTRA RELEVANT SYSTEM CONFIGURATION :
http://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html

A DESCRIPTION OF THE PROBLEM :
The class javadoc for PrintStream states

"All characters printed by a PrintStream are converted into bytes using the platform's default character encoding."

However there are now constructors that take an encoding (http://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html#PrintStream-java.io.File-java.lang.String-)   which state

"Creates a new print stream, without automatic line flushing, ***with the specified file and charset***. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will encode characters using the provided charset."

The statement in this constructors javadoc is at odds with the statement in the class javadoc (they are mutually exclusive).  Assuming that the PrintStreams that take a charset option do the right thing then the class level javadoc is now incorrect and needs updating.


ADDITIONAL REGRESSION INFORMATION: 
This is a regression form JDK 1.4 when the first constructor that took and encoding was introduced (subsequent constructors taking encodings where introduced in 1.5).  This is not an option in the dropdown to select from.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Look at the javadoc links and read the class and constructor descriptions.

http://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
There are not contradictions. 
ACTUAL -
the javadoc contains multually exclusive statements about encoding at the class level and the constructor level.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
no source code is needed.
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
ignore what the API says.  (this is not a good thing to do!)


Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/070ffafc4294 User: bpb Date: 2019-07-17 21:26:59 +0000
17-07-2019

Spec should be clarified to remove erroneous statement.
20-07-2015