8062504: javadoc Start does not close file managers that it opens

Reviewed-by: ksrini
This commit is contained in:
Jonathan Gibbons 2014-10-29 18:01:22 -07:00
parent 8bd23f1681
commit 4ce27b2f9e

View File

@ -88,6 +88,9 @@ public class Start extends ToolOption.Helper {
*/
private boolean apiMode;
private JavaFileManager fileManager;
private boolean closeFileManagerOnExit;
Start(String programName,
PrintWriter errWriter,
PrintWriter warnWriter,
@ -239,6 +242,12 @@ public class Start extends ToolOption.Helper {
messager.error(Messager.NOPOS, "main.fatal.exception");
failed = true;
} finally {
if (fileManager != null && closeFileManagerOnExit) {
try {
fileManager.close();
} catch (IOException ignore) {
}
}
messager.exitNotice();
messager.flush();
}
@ -270,7 +279,8 @@ public class Start extends ToolOption.Helper {
}
JavaFileManager fileManager = context.get(JavaFileManager.class);
fileManager = context.get(JavaFileManager.class);
setDocletInvoker(docletClass, fileManager, argv);
compOpts = Options.instance(context);
@ -333,6 +343,7 @@ public class Start extends ToolOption.Helper {
if (fileManager == null) {
JavacFileManager.preRegister(context);
fileManager = context.get(JavaFileManager.class);
closeFileManagerOnExit = true;
}
if (fileManager instanceof BaseFileManager) {
((BaseFileManager) fileManager).handleOptions(fileManagerOpts);