basil commented on a change in pull request #151:
URL: https://github.com/apache/ant/pull/151#discussion_r674341363



##########
File path: src/main/org/apache/tools/ant/AntClassLoader.java
##########
@@ -982,26 +979,21 @@ protected URL findResource(final String name) {
      *
      * @param name The resource name to search for.
      *             Must not be <code>null</code>.
-     * @param parentHasBeenSearched whether ClassLoader.this.parent
-     * has been searched - will be true if the method is (indirectly)
-     * called from ClassLoader.getResources
+     * @param searchParent whether to search the parent first - will be true 
if the method is
+     *     invoked from {@link #getResources(String)} or {@link 
#getNamedResources(String)} and
+     *     false if the method is invoked from {@link #findResources(String)}.

Review comment:
       This documentation is misleading as of commit 17527b6490.
   
   Before commit 17527b6490, we didn't override `getResources(String)`. The 
base version from `ClassLoader` is roughly as follows:
   
   ```java
   public Enumeration<URL> getResources(String name) throws IOException {
       if (parent != null) {
           // parent.getResources(name);
       } else {
           // getBootstrapResources(name);
       } else {
           // findResources(name);
       }
   }
   ```
   
   This was `final` in earlier versions of Java, so the `parentHasBeenSearched` 
semantics make sense. We didn't want to repeat this work if invoked from 
`ClassLoader#getResources(String)`. But as of commit 17527b6490 we now have:
   
   
   ```java
   /** {@inheritDoc} */
   @Override
   public Enumeration<URL> getResources(String name) throws IOException {
       return getNamedResources(name);
   }
   ```
   
   So we're now no longer running `ClassLoader#getResources()`, only our own 
code. The only thing that still is necessary is to distinguish between our own 
`getResources()` (which is recursive and must check the parent first) and our 
own `findResources()` (which is non-recursive and must not check the parent 
first).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to