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

cleanup ostream, staticBufferStream

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b107

      Description


      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: