Mercurial > hg > truffle
comparison graal/com.oracle.max.criutils/src/com/oracle/max/criutils/TTY.java @ 4142:bc8527f3071c
Adjust code base to new level of warnings.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 18 Dec 2011 05:24:06 +0100 |
parents | e233f5660da4 |
children | e4e02131c58b |
comparison
equal
deleted
inserted
replaced
4141:04d21be7a24f | 4142:bc8527f3071c |
---|---|
100 private static LogStream createLog() { | 100 private static LogStream createLog() { |
101 if (cachedOut == null) { | 101 if (cachedOut == null) { |
102 // In case initialize() was not called. | 102 // In case initialize() was not called. |
103 cachedOut = System.out; | 103 cachedOut = System.out; |
104 } | 104 } |
105 PrintStream out = cachedOut; | 105 PrintStream newOut = cachedOut; |
106 String value = System.getProperty(MAX_TTY_LOG_FILE_PROPERTY); | 106 String value = System.getProperty(MAX_TTY_LOG_FILE_PROPERTY); |
107 if (value != null) { | 107 if (value != null) { |
108 try { | 108 try { |
109 out = new PrintStream(new FileOutputStream(value)); | 109 newOut = new PrintStream(new FileOutputStream(value)); |
110 } catch (FileNotFoundException e) { | 110 } catch (FileNotFoundException e) { |
111 System.err.println("Could not open log file " + value + ": " + e); | 111 System.err.println("Could not open log file " + value + ": " + e); |
112 } | 112 } |
113 } | 113 } |
114 return new LogStream(out); | 114 return new LogStream(newOut); |
115 } | 115 } |
116 | 116 |
117 private static final ThreadLocal<LogStream> out = new ThreadLocal<LogStream>() { | 117 private static final ThreadLocal<LogStream> out = new ThreadLocal<LogStream>() { |
118 @Override | 118 @Override |
119 protected LogStream initialValue() { | 119 protected LogStream initialValue() { |
285 } | 285 } |
286 | 286 |
287 private static String printMap(Map<?, ?> m) { | 287 private static String printMap(Map<?, ?> m) { |
288 StringBuilder sb = new StringBuilder(); | 288 StringBuilder sb = new StringBuilder(); |
289 | 289 |
290 List<String> keys = new ArrayList<String>(); | 290 List<String> keys = new ArrayList<>(); |
291 for (Object key : m.keySet()) { | 291 for (Object key : m.keySet()) { |
292 keys.add((String) key); | 292 keys.add((String) key); |
293 } | 293 } |
294 Collections.sort(keys); | 294 Collections.sort(keys); |
295 | 295 |
301 } | 301 } |
302 | 302 |
303 return sb.toString(); | 303 return sb.toString(); |
304 } | 304 } |
305 | 305 |
306 private static void printField(String fieldName, long value) { | |
307 TTY.print(" " + fieldName + " = " + value + "\n"); | |
308 } | |
309 | |
310 private static void printField(String fieldName, double value) { | |
311 TTY.print(" " + fieldName + " = " + value + "\n"); | |
312 } | |
313 | |
314 public static void flush() { | 306 public static void flush() { |
315 out().flush(); | 307 out().flush(); |
316 } | 308 } |
317 } | 309 } |