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

java.awt.Desktop.open(File) does not throw IOException if no app is registered

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10. Tested with other Java version like 1.6 and also there it is reproducible.

      A DESCRIPTION OF THE PROBLEM :
      On Windows 10: When the method is invoked with a file like "exmaple.car" and there is no application registered for the file extension ".car", the OS displays the "Choose app to open file" dialog and the method returns silently without any exception.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See example source code below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      According to the javadoc "@throws IOException if the specified file has no associatedapplication or the associated application fails to be launched"
      ACTUAL -
      No exception is thrown.

      ---------- BEGIN SOURCE ----------
      import java.io.File;

      public class Example {

      public static void main(String[] args) {
      try {
      File file = new File("example.extension");
      file.createNewFile();
      java.awt.Desktop.getDesktop().open(file);
      } catch (Exception ex) {
      ex.printStackTrace();
      return;
      }
      System.out.println("No exception");
      }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              kabhishek Kumar Abhishek
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated: