UL: LogStream autoflush?

Thomas Stüfe thomas.stuefe at gmail.com
Wed Apr 25 05:23:36 UTC 2018


I ran into following problem:

  LogTarget(Trace, gc, metaspace) lt;
  if (lt.is_enabled()) {
    LogStream ls(lt);

I did modify VirtualSpaceNode::print_on() to not print a trailing cr,
since that suits my needs at other places. Then I ran into this

#  Internal Error
pid=8827, tid=8828
#  assert(_pos == 0) failed: still outstanding bytes in the line buffer

Of course, the simple fix would here to add an ls.cr() at the end of
the LogStream scope. But I find that clumsy: as a caller of
VirtualSpaceNode::print_on(), why should I have care or even know if
the called print_on() function ends with a cr() ?

I also could add an ls.flush() at the end of the scope, but then, why
should I have to think about this?

The point is that LogStream() requires me to end output with a cr()
before it dies, but as an implementator of a print function, I do not
know how long the stream I write into lives. And as a user of
LogStream, I do not want to have to think about this.

I would it find way more convenient if LogStream would just autoflush
at destruction time, treating an unfinished line like a finished line.
Would that make sense to you?

Kind Regards, Thomas

More information about the hotspot-runtime-dev mailing list