changeset 54322:e348b0160d61

8216172: File.renameTo(File dest) should check for NPE at the very beginning Reviewed-by: lancea
author bpb
date Fri, 11 Jan 2019 08:20:25 -0800
parents 5170dc2bcf64
children 754312b616de
files src/java.base/share/classes/java/io/File.java
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/io/File.java	Thu Nov 29 13:36:23 2018 -0300
+++ b/src/java.base/share/classes/java/io/File.java	Fri Jan 11 08:20:25 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2019, 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
@@ -29,11 +29,11 @@
 import java.net.URL;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+import java.security.SecureRandom;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.ArrayList;
-import java.security.SecureRandom;
-import java.nio.file.Path;
-import java.nio.file.FileSystems;
 import sun.security.action.GetPropertyAction;
 
 /**
@@ -1395,14 +1395,14 @@
      *          If parameter <code>dest</code> is <code>null</code>
      */
     public boolean renameTo(File dest) {
+        if (dest == null) {
+            throw new NullPointerException();
+        }
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             security.checkWrite(path);
             security.checkWrite(dest.path);
         }
-        if (dest == null) {
-            throw new NullPointerException();
-        }
         if (this.isInvalid() || dest.isInvalid()) {
             return false;
         }