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

(spec) File.createTempFile(prefix, suffix, dir) needs clarification for illegal symbols in suffix

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • core-libs
    • None
    • behavioral
    • minimal
    • Minimal risk as it is a verbiage-only change.
    • Java API
    • SE

      Summary

      Add verbiage to the specification of java.io.File.createTempFile(String,String,File) clarifying the behavior when the platform cannot create a file with the requested name.

      Problem

      The specification of File.createTempFile makes no reference to the behavior when it is not possible to create a file having the name implied by the given prefix and suffix.

      Solution

      Augment the specification of File.createTempFile to indicate the behavior when the file cannot be created.

      Specification

      --- a/src/java.base/share/classes/java/io/File.java
      +++ b/src/java.base/share/classes/java/io/File.java
      @@ -2117,6 +2117,11 @@ static File generateFile(String prefix, String suffix, File dir)
            * made the name of the new file will be generated by concatenating the
            * prefix, five or more internally-generated characters, and the suffix.
            *
      +     * <p> If a file with the generated name cannot be created by the
      +     * underlying platform, then an {@code IOException} will be thrown.
      +     * This could occur for example if the supplied prefix or suffix contains
      +     * one or more characters not supported by the underlying file system.
      +     *
            * <p> If the {@code directory} argument is {@code null} then the
            * system-dependent default temporary-file directory will be used.  The
            * default temporary-file directory is specified by the system property

            bpb Brian Burkhalter
            mismirno Mikhail Smirnov (Inactive)
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: