Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1265548

java.io.PrintStream constructor does not work with null parameter

XMLWordPrintable

    • 1.2fcs
    • sparc
    • solaris_2.5
    • Not verified



      Name: saf@russia Date: 08/28/96


      This bug was found by St.Petersburg Java SQE team (by Alexander Kuzmin).

      The java.io.PrintStream.PrintStream(String, int) method does not work properly
       with the first parameter.

               The Java Language specification :
      22.22.2 public PrintStream(OutputStream out, boolean autoflush)
      This constructor initializes a newly created PrintStream by saving its argument, the output stream out, for later
      use. This stream will autoflush if and only if autoflush is true.


      ---------------------------------------
      It is a source code of the constructor - it does not throw any exceptions
      if out is null.
         public PrintStream(OutputStream out, boolean autoflush) {
      super(out);
      this.autoflush = autoflush;
      trouble = false;
          }
      ---------------------------------------

      --Short example-------
       Status PStreamB002() {
       PrintStream y1;
        try {
        y1 = new PrintStream( null );
            }
               // there is no check for null in the constructor - see source
        catch (Exception e) {return Status.passed("PStreamB002: Ok");}
               // will never catch

       // Try to call any method
        y1.print("Hello , World!"); // here will be troubles

       }
      ----------------------

       I don't think this should be a P1, but we should have some kind of ruling on
      what exceptions are generally required to be raised, so I'm leaving this as a
      P1 pending some such ruling.

      david.bowen@Eng 1996-10-04

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

            bgomessunw Benedict Gomes (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: