JDK-4294755 : java.lang.Process get*Stream methods have wrong names
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 1999-11-25
  • Updated: 1999-12-18
  • Resolved: 1999-12-18
Description

Name: skT88420			Date: 11/25/99


$ java -version
java version "1.2"
Solaris VM (build Solaris_JDK_1.2_01, native threads, sunwjit)


The class java.lang.Process provides a method:

  java.io.InputStream getInputStream ();

The name of the method is wrong, because it returns the Process' output
stream (the return type of the method is fine, since our Java code needs
an InputStream to read from).

The name of the method includes its return type (which is unnecessary),
instead of naming the member of the Process that one wishes to access.
One wishes to get the output stream of the Process (and manipulate it
as an InputStream).

The method should have been named:

  java.io.InputStream getOutputStream ();

(or perhaps "getOutput" would be even less confusing).

The javadoc generated documentation says:

  public abstract InputStream getInputStream()

  Gets the input stream of the subprocess. The stream obtains data
  piped from the standard output stream of the process represented
  by this Process object.

The first sentence is clearly wrong.  I repeat, this method gets the
output stream of the subprocess (who type is necessarily an InputStream).

The method getOutputStream is symmetrically wrongly named.

Of course, you'll never be able to fix this, but perhaps you can find
the person in Sun who named these methods, and explain why the names
are wrong, so that no more conceptual damage will be done.
(Review ID: 98289) 
======================================================================

Comments
WORK AROUND Name: skT88420 Date: 11/25/99 Correct the documentation. Hope that people are clever enough to work out what was meant. ======================================================================
11-06-2004

EVALUATION Having been confused by this myself, I will agree that the naming convention chosen is unfortunate. It is quite correct and sensible, however, when you realize that the the terms input and output here do not refer to the situation with respect to the process, but from the program that is *using* the stream. The program writes to an output stream (even though the data is then read by the subprocess) and reads from an input stream (even though the data there was written by the subprocess). william.maddox@Eng 1999-12-17
17-12-1999