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

JShell: file manager should be closed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b133
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Description

      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

        Attachments

          Activity

            People

            Assignee:
            jlahoda Jan Lahoda
            Reporter:
            rfield Robert Field
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: