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

Java2D: createFont temporary font files still open on exit aren't removed on windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.4.0
    • client-libs
    • None
    • 2d
    • b14
    • generic
    • windows_xp

        File.deleteOnExit is used to remove temporary font files created
        by the implementation of Font.createFont.

        That implementation is run via a shutdown hook on normal exit only.
        On windows files that are open cannot be deleted and deleteOnExit
        doesn't make any attempt to close open files first - it doesn't
        know which streams correspond to this file and probably can't
        easily determine this?)
        So using this default implementation has several problems.
        - If the app happens to be using the font file, and it is still open
        the temp file can't be deleted
        - you can't remove a file from the File.deleteOnExit list so in
        the event an app makes a lot of use of this API we end up with
        lots of files on the list that were probably removed earlier when
        all references were removed and finalisers run
        - if an app ends abnormally the shutdown hook isn't run.

        So at the least we should try to close the font files so that the
        deleteOnExit hook can remove them. The obvious way to do this
        is with our own shutdown hook which closes the files. But there
        is no guarantee which hook will run first! In fact all shutdown
        hook threads are by spec started in unspecified order and
        run concurrently.

        So we may as well do everything in our own shutdown hook - close
        the files and then remove them, and if files are GC'd and
        deleted before shutdown remove them from the list to delete on exit.
        Need to be careful only to remove the temporary copies.
        We would only install this hook if a temp font file is created.

        The deleteOnExit hook is, so far as I can tell, no more likely
        to get run on abnormal exits than our own hook - in fact its doc
        says its only run on normal termination.

        So there is no way we can 100% guarantee temp files are removed
        on abnormal termination. But we can guarantee it for normal termination.
        ###@###.### 11/3/04 00:18 GMT

              prr Philip Race
              prr Philip Race
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: