1 /* |
1 /* |
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2014, 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 |
43 import javax.tools.JavaFileObject; |
43 import javax.tools.JavaFileObject; |
44 import javax.tools.StandardJavaFileManager; |
44 import javax.tools.StandardJavaFileManager; |
45 |
45 |
46 import com.sun.tools.javac.api.ClientCodeWrapper; |
46 import com.sun.tools.javac.api.ClientCodeWrapper; |
47 import com.sun.tools.javac.file.JavacFileManager; |
47 import com.sun.tools.javac.file.JavacFileManager; |
|
48 import com.sun.tools.javac.util.BaseFileManager; |
48 import com.sun.tools.javac.util.ClientCodeException; |
49 import com.sun.tools.javac.util.ClientCodeException; |
49 import com.sun.tools.javac.util.Context; |
50 import com.sun.tools.javac.util.Context; |
50 import com.sun.tools.javac.util.DefinedBy; |
51 import com.sun.tools.javac.util.DefinedBy; |
51 import com.sun.tools.javac.util.DefinedBy.Api; |
52 import com.sun.tools.javac.util.DefinedBy.Api; |
52 import com.sun.tools.javac.util.Log; |
53 import com.sun.tools.javac.util.Log; |
109 else if (out instanceof PrintWriter) |
110 else if (out instanceof PrintWriter) |
110 context.put(Log.outKey, ((PrintWriter) out)); |
111 context.put(Log.outKey, ((PrintWriter) out)); |
111 else |
112 else |
112 context.put(Log.outKey, new PrintWriter(out, true)); |
113 context.put(Log.outKey, new PrintWriter(out, true)); |
113 |
114 |
114 if (fileManager == null) |
115 if (fileManager == null) { |
115 fileManager = getStandardFileManager(diagnosticListener, null, null); |
116 fileManager = getStandardFileManager(diagnosticListener, null, null); |
|
117 if (fileManager instanceof BaseFileManager) { |
|
118 ((BaseFileManager) fileManager).autoClose = true; |
|
119 } |
|
120 } |
116 fileManager = ccw.wrap(fileManager); |
121 fileManager = ccw.wrap(fileManager); |
117 context.put(JavaFileManager.class, fileManager); |
122 context.put(JavaFileManager.class, fileManager); |
118 |
123 |
119 return new JavadocTaskImpl(context, docletClass, options, compilationUnits); |
124 return new JavadocTaskImpl(context, docletClass, options, compilationUnits); |
120 } catch (ClientCodeException ex) { |
125 } catch (ClientCodeException ex) { |