file manager should be closed

Robert Field robert.field at oracle.com
Fri May 13 06:46:11 UTC 2016


Thanks, Jon.

Created:   https://bugs.openjdk.java.net/browse/JDK-8156911

-Robert


On 05/12/2016 11:23 AM, Jonathan Gibbons wrote:
> This is in SourceCodeAnalysisImpl.java.
> getStandardFileManager is defined to return a new instance each time 
> it is called.   Ideally, each such instance should be closed.  This 
> can be done by creating the file manager with try-wirth-resources,
>
>
>         public SourceCache(AnalyzeTask originalTask) {
>             this.originalTask = originalTask;
>             List<Path> sources = findSources();
>             if (sources.iterator().hasNext()) {
>                 StandardJavaFileManager fm = 
> compiler.getStandardFileManager(null, null, null);
>                 try {
> fm.setLocationFromPaths(StandardLocation.SOURCE_PATH, sources);
>                 } catch (IOException ex) {
>                     proc.debug(ex, 
> "SourceCodeAnalysisImpl.SourceCache.<init>(...)");
>                     fm = null;
>                 }
>                 this.fm = fm;
>             } else {
>                 //don't waste time if there are no sources
>                 this.fm = null;
>             }
>         } 



More information about the kulla-dev mailing list