]> source.dussan.org Git - aspectj.git/commitdiff
According to javadoc File.isDirectory 'true' if and only if the file denoted by this... 100/head
authorAndrey Turbanov <turbanoff@gmail.com>
Sat, 20 Nov 2021 13:53:30 +0000 (16:53 +0300)
committerAndrey Turbanov <turbanoff@gmail.com>
Sat, 20 Nov 2021 13:53:30 +0000 (16:53 +0300)
It means that separate File.exists() check before File.isDirectory() check is redundant.

bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassPath.java
build/src/test/java/org/aspectj/build/BuildModuleTests.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
testing/src/test/java/org/aspectj/testing/util/FileUtil.java

index 29f8f6d6d96c08ff4c3d2ac77b01217e99c437cf..c2f350d0c652d161096b98253134e2e6ab4932a5 100644 (file)
@@ -117,10 +117,10 @@ public class ClassPath implements Serializable {
                                File file = new File(path);
 
                                try {
-                                       if (file.exists()) {
-                                               if (file.isDirectory()) {
-                                                       vec.add(new Dir(path));
-                                               } else if (file.getName().endsWith("jrt-fs.jar")) { // TODO a bit crude...
+                                       if (file.isDirectory()) {
+                                               vec.add(new Dir(path));
+                                       } else if (file.exists()) {
+                                               if (file.getName().endsWith("jrt-fs.jar")) { // TODO a bit crude...
                                                        vec.add(new JImage());
                                                } else {
                                                        vec.add(new Zip(new ZipFile(file)));
index 64f8b101606ce29eb1be2e6486c82959d3170a1f..181d84fcc26cde0f0c74aa450f4661e22d102de1 100644 (file)
@@ -175,7 +175,7 @@ public class BuildModuleTests extends TestCase {
 
     void checkSourceDirectory(File srcDir, String module) {
         final String label = "source dir " + srcDir + " (module " + module + ")";
-        assertTrue(label,  (srcDir.exists() && srcDir.isDirectory()));
+        assertTrue(label, srcDir.isDirectory());
         String license = getLicense(module);
 //        if (replacing) {
 //            if (replacing && true) {
index 54fee3bfa926938d1cd48dbcc360349e3f8a6e20..1e3310cd73ffd633e4c6bc26cbbdeda13e7a33b2 100644 (file)
@@ -993,7 +993,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
                        if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) {
                                return true;
                        }
-                       if (checkClassFiles && f.exists() && f.isDirectory()) {
+                       if (checkClassFiles && f.isDirectory()) {
 
                                // We should use here a list/set of directories we know have or have not changed - some kind of
                                // List<File> buildConfig.getClasspathEntriesWithChangedContents()
@@ -1045,7 +1045,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe
                        if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) {
                                return true;
                        }
-                       if (checkClassFiles && f.exists() && f.isDirectory()) {
+                       if (checkClassFiles && f.isDirectory()) {
 
                                // We should use here a list/set of directories we know have or have not changed - some kind of
                                // List<File> buildConfig.getClasspathEntriesWithChangedContents()
index 4c3bb93ea3d350b843f107dbcbefc903bb8a31c1..7755718ddf4a5f010c9997656b6706e256c94580 100644 (file)
@@ -465,7 +465,7 @@ public class Ajc2 extends Javac {
         File parent = argfile.getParentFile();
 
         // Sanity check
-        if (parent == null || !parent.exists() || !parent.isDirectory()) {
+        if (parent == null || !parent.isDirectory()) {
             return;
         }
 
index 6aea81dfa6e07cdf26a84d0cfb3d5ee7ebd3de47..03b29a85a1da93e35254c77bc07207930facb79b 100644 (file)
@@ -267,7 +267,7 @@ public class FileUtil {
      *        return true;
      *     }}, true);</code></pre>
      * @param file root/starting point.  If a file, the only one visited.
-     * @param filter supplies boolean accept(File) method
+     * @param fileFilter supplies boolean accept(File) method
      * @param userRecursion - if true, do accept() on dirs; else, recurse
      * @return false if any fileFilter.accept(File) did.
      * @throws IllegalArgumentException if file or fileFilter is null
@@ -655,7 +655,6 @@ public class FileUtil {
      */
     protected static boolean deleteDirectory(File dir) {
         return ((null != dir)
-                && dir.exists()
                 && dir.isDirectory()
                 && FileUtil.descendFileTree(dir, DELETE_FILES, false)
                 && FileUtil.descendFileTree(dir, DELETE_DIRS, true)
@@ -675,7 +674,7 @@ public class FileUtil {
     protected static final FileFilter DELETE_DIRS = new FileFilter() {
             public boolean accept(File file) {
                 return ((null != file) && file.isDirectory()
-                        && file.exists() && file.delete());
+                        && file.delete());
             }
         };
     protected static final FileFilter DELETE_FILES = new FileFilter() {