Bug 46752 - AntClassLoader.getResources unimplemented
Summary: AntClassLoader.getResources unimplemented
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.7.1
Hardware: PC All
: P2 normal (vote)
Target Milestone: 1.8.0
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks: 46759
  Show dependency tree
 
Reported: 2009-02-21 13:42 UTC by Jesse Glick
Modified: 2009-07-22 02:45 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2009-02-21 13:42:14 UTC
While getResource is overridden to search ACL.parent (see bug #749), getResources is not. Therefore it uses CL.getResources, which uses CL.parent, which in the case of ACL is arbitrarily initialized to CL.getSystemClassLoader(). Therefore an ACL whose ACL.parent cannot "see" some resource, and whose pathComponents does not contain it, will nonetheless return it from getResources if that resource can be found in the application classpath.

This is bad because, for example, ServiceLoader calls getResources("META-INF/services/....") and tries to load all the classes it finds using the same loader. If the configured loader is an ACL (or a child of one) which is not parented to the app CP, and the app CP defines some services, then a ServiceConfigurationError will result. See: http://www.netbeans.org/nonav/issues/show_bug.cgi?id=158934
Comment 1 Stefan Bodewig 2009-02-23 05:19:15 UTC

*** This bug has been marked as a duplicate of bug 46759 ***
Comment 2 Peter Reilly 2009-02-23 05:23:55 UTC
Is this one a duplicate of the other ones?
I think that this one can be fixed independently of fixing the other ant classloader issues.
Comment 3 Stefan Bodewig 2009-07-21 21:10:40 UTC
since getResources in Java 1.4 is final, is there anything we can do until Ant moves to Java 5?

see bug 35436

Maybe overriding findResources would help.
Comment 4 Stefan Bodewig 2009-07-21 21:21:36 UTC
obviously overriding findResources doesn't help, since we already do that.  Sorry.
Comment 5 Stefan Bodewig 2009-07-22 02:45:08 UTC
There now is an AntClassLoader5 class which overrides getResources.  This class will be used by all classes in Ant when it is available (and Ant is running on Java5, of course).

The real implementation sits in AntClassLoader.getNamedResources but that probably doesn't help people in Java 1.4 land too much.

svn revision 796647