# HG changeset patch # User Doug Simon # Date 1433875005 -7200 # Node ID c869a5c3da16f21d30f6942d888354909c1dcf97 # Parent 525c4df9428b2d49e84022965c9f3bc82966a206 made access to CompilerToVM from PrintStreamOption lazy to resolve initialization issue diff -r 525c4df9428b -r c869a5c3da16 jvmci/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/internal/DebugScope.java --- a/jvmci/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/internal/DebugScope.java Tue Jun 09 12:04:47 2015 -0700 +++ b/jvmci/com.oracle.jvmci.debug/src/com/oracle/jvmci/debug/internal/DebugScope.java Tue Jun 09 20:36:45 2015 +0200 @@ -144,8 +144,6 @@ logScopeName = true; } - // Be pragmatic: provide a default log stream to prevent a crash if the stream is not - // set while logging this.output = TTY.out; assert context != null; } diff -r 525c4df9428b -r c869a5c3da16 jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotTTYStreamProvider.java --- a/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotTTYStreamProvider.java Tue Jun 09 12:04:47 2015 -0700 +++ b/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotTTYStreamProvider.java Tue Jun 09 20:36:45 2015 +0200 @@ -32,7 +32,6 @@ class HotSpotTTYStreamProvider implements TTYStreamProvider { public PrintStream getStream() { - CompilerToVM compilerToVm = HotSpotJVMCIRuntime.runtime().getCompilerToVM(); - return Options.LogFile.getStream(compilerToVm); + return Options.LogFile.getStream(); } } diff -r 525c4df9428b -r c869a5c3da16 jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/PrintStreamOption.java --- a/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/PrintStreamOption.java Tue Jun 09 12:04:47 2015 -0700 +++ b/jvmci/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/PrintStreamOption.java Tue Jun 09 20:36:45 2015 +0200 @@ -40,7 +40,7 @@ * The print stream to which output will be written. * * Declared {@code volatile} to enable safe use of double-checked locking in - * {@link #getStream(CompilerToVM)} and {@link #setValue(Object)}. + * {@link #getStream()} and {@link #setValue(Object)}. */ private volatile PrintStream ps; @@ -72,7 +72,7 @@ * Gets the print stream configured by this option. If no file is configured, the print stream * will output to {@link CompilerToVM#writeDebugOutput(byte[], int, int)}. */ - public PrintStream getStream(final CompilerToVM compilerToVM) { + public PrintStream getStream() { if (ps == null) { if (getValue() != null) { synchronized (this) { @@ -94,6 +94,15 @@ } } else { OutputStream ttyOut = new OutputStream() { + CompilerToVM vm; + + private CompilerToVM vm() { + if (vm == null) { + vm = HotSpotJVMCIRuntime.runtime().getCompilerToVM(); + } + return vm; + } + @Override public void write(byte[] b, int off, int len) throws IOException { if (b == null) { @@ -103,7 +112,7 @@ } else if (len == 0) { return; } - compilerToVM.writeDebugOutput(b, off, len); + vm().writeDebugOutput(b, off, len); } @Override @@ -113,7 +122,7 @@ @Override public void flush() throws IOException { - compilerToVM.flushDebugOutput(); + vm().flushDebugOutput(); } }; ps = new PrintStream(ttyOut);