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

Replace Vector with ArrayList in BasicDirectoryModel.FilesLoader

    XMLWordPrintable

Details

    • b60
    • 7

    Description

      javax.swing.plaf.basic.BasicDirectoryModel.FilesLoader.run0() stores its temporary lists in Vector objects:

      Vector<File> newFileCache;
      Vector<File> newFiles;

      These are local variables, they aren't accessed concurrently. Therefore, the collections could be replaced with ArrayList which has no synchronisation overhead.

      newFileCache is used from another thread.

      On Linux and macOS, ShellFolder.invoke runs the Callable on the same thread, using sun.awt.shell.ShellFolderManager.DirectInvoker.

      On Windows ShellFolder.invoke executes the code on the COM thread, using sun.awt.shell.Win32ShellFolderManager2.ComInvoker. In this case, the Callable is wrapped into a Future object.

      In either case, no additional synchronisation is needed for newFileCache.


      I noticed this issue during code review for JDK-8323670.
      https://github.com/openjdk/jdk/pull/17462#discussion_r1465414103

      Attachments

        Issue Links

          Activity

            People

              aivanov Alexey Ivanov
              aivanov Alexey Ivanov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: