Mercurial > hg > graal-compiler
diff graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinterObserver.java @ 2811:03027a0ef819
Allow to specify the output stream in CFGPrinterObserver (for C1XVisualizer)
author | Peter Hofer <peter.hofer@jku.at> |
---|---|
date | Mon, 30 May 2011 15:11:34 +0200 |
parents | d3fc4fe063bf |
children |
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinterObserver.java Mon May 30 15:03:04 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinterObserver.java Mon May 30 15:11:34 2011 +0200 @@ -39,8 +39,14 @@ private C1XCompilation currentCompilation; private CFGPrinter cfgPrinter; private ByteArrayOutputStream buffer = null; + private final OutputStream stream; public CFGPrinterObserver() { + this(CFGPrinter.cfgFileStream()); + } + + public CFGPrinterObserver(OutputStream stream) { + this.stream = stream; } @Override @@ -96,13 +102,13 @@ cfgPrinter.flush(); - OutputStream cfgFileStream = CFGPrinter.cfgFileStream(); - if (cfgFileStream != null) { - synchronized (cfgFileStream) { + if (stream != null) { + synchronized (stream) { try { - cfgFileStream.write(buffer.toByteArray()); + stream.write(buffer.toByteArray()); + stream.flush(); } catch (IOException e) { - TTY.println("WARNING: Error writing CFGPrinter output for %s to disk: %s", event.getMethod(), e); + TTY.println("WARNING: Error writing CFGPrinter output for %s: %s", event.getMethod(), e); } } }