From 2528d52d6dc3dd1820dbdc6a0479f14d1f1eae61 Mon Sep 17 00:00:00 2001 From: serb Date: Thu, 1 Feb 2018 20:19:42 -0800 Subject: [PATCH] 8191239: Improve desktop file usage Reviewed-by: prr, rhalade, aghaisas --- src/share/classes/java/awt/Desktop.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/share/classes/java/awt/Desktop.java b/src/share/classes/java/awt/Desktop.java index a9b947dfa..577ffdde0 100644 --- a/src/share/classes/java/awt/Desktop.java +++ b/src/share/classes/java/awt/Desktop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -202,15 +202,11 @@ public class Desktop { * @throws NullPointerException if file is null * @throws IllegalArgumentException if file doesn't exist */ - private static void checkFileValidation(File file){ - if (file == null) throw new NullPointerException("File must not be null"); - + private static void checkFileValidation(File file) { if (!file.exists()) { throw new IllegalArgumentException("The file: " + file.getPath() + " doesn't exist."); } - - file.canRead(); } /** @@ -264,6 +260,7 @@ public class Desktop { * @see java.awt.AWTPermission */ public void open(File file) throws IOException { + file = new File(file.getPath()); checkAWTPermission(); checkExec(); checkActionSupport(Action.OPEN); @@ -295,6 +292,7 @@ public class Desktop { * @see java.awt.AWTPermission */ public void edit(File file) throws IOException { + file = new File(file.getPath()); checkAWTPermission(); checkExec(); checkActionSupport(Action.EDIT); @@ -325,6 +323,7 @@ public class Desktop { * allowed to create a subprocess */ public void print(File file) throws IOException { + file = new File(file.getPath()); checkExec(); SecurityManager sm = System.getSecurityManager(); if (sm != null) { -- GitLab