Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8156911

JShell: file manager should be closed

XMLWordPrintable

    • b133
    • generic
    • generic
    • Not verified

      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-with-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;
                  }
              }

      - Jon

            jlahoda Jan Lahoda
            rfield Robert Field (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: