1 /* |
1 /* |
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
105 |
105 |
106 if (diagnosticListener != null) |
106 if (diagnosticListener != null) |
107 context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener)); |
107 context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener)); |
108 |
108 |
109 if (out == null) |
109 if (out == null) |
110 context.put(Log.outKey, new PrintWriter(System.err, true)); |
110 context.put(Log.errKey, new PrintWriter(System.err, true)); |
111 else if (out instanceof PrintWriter) |
111 else if (out instanceof PrintWriter) |
112 context.put(Log.outKey, ((PrintWriter) out)); |
112 context.put(Log.errKey, ((PrintWriter) out)); |
113 else |
113 else |
114 context.put(Log.outKey, new PrintWriter(out, true)); |
114 context.put(Log.errKey, new PrintWriter(out, true)); |
115 |
115 |
116 if (fileManager == null) { |
116 if (fileManager == null) { |
117 fileManager = getStandardFileManager(diagnosticListener, null, null); |
117 fileManager = getStandardFileManager(diagnosticListener, null, null); |
118 if (fileManager instanceof BaseFileManager) { |
118 if (fileManager instanceof BaseFileManager) { |
119 ((BaseFileManager) fileManager).autoClose = true; |
119 ((BaseFileManager) fileManager).autoClose = true; |
139 if (diagnosticListener != null) |
139 if (diagnosticListener != null) |
140 context.put(DiagnosticListener.class, diagnosticListener); |
140 context.put(DiagnosticListener.class, diagnosticListener); |
141 PrintWriter pw = (charset == null) |
141 PrintWriter pw = (charset == null) |
142 ? new PrintWriter(System.err, true) |
142 ? new PrintWriter(System.err, true) |
143 : new PrintWriter(new OutputStreamWriter(System.err, charset), true); |
143 : new PrintWriter(new OutputStreamWriter(System.err, charset), true); |
144 context.put(Log.outKey, pw); |
144 context.put(Log.errKey, pw); |
145 return new JavacFileManager(context, true, charset); |
145 return new JavacFileManager(context, true, charset); |
146 } |
146 } |
147 |
147 |
148 @Override @DefinedBy(Api.COMPILER) |
148 @Override @DefinedBy(Api.COMPILER) |
149 public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { |
149 public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { |