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

cleanup ostream, staticBufferStream

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • None
    • b107


      When printing the error log in vmError.cpp, we want to use as little stack space as possible. outputStream class uses on-stack buffers to assemble snprintf functions. So, staticBufferStream was introduced as a child of outputStream which overwrites the print functions and makes them use a caller provided buffer. It then delegates the real writing to a connected stream object.

      The problem with that approach is that this is not a good fit for a child class.Not all operations possible with outputStream are cleanly delegated to the connected stream class, so a staticBufferStream behaves sometimes differently from all other streams (see e.g. JDK-8145410).

      Another problem is that this delegation model leads to some code duplication, because all print() methods of outputStream are practically duplicated in staticBufferStream.

      Another cosmetic note is that all other child classes of outputStream (bufferedStream, stringStream, fileStream...) are specializations in term of log destination, not internal behaviour.

      This could be implemented in a simpler way - and staticBufferStream could be removed - simply by giving the parent class itself the ability to use a caller provided buffer instead of always using on-stack buffers.

            stuefe Thomas Stuefe
            stuefe Thomas Stuefe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: