Calling getParent() on oata.AntClassLoader doesn't return the - expected - actual parent classloader but allways the SystemClassLoader. The Reason is simple: Parent-Property is immutuable in java.lang.ClassLoader and getParent() is final. AntClassLoader has a local, mutuable parent property that can be set via setParent(ClassLoader). However, there should be a way to get AntClassLoader's real parent loader. I see two solutions: 1. Remove the local property and it's setter-method. Allow setting of the parent only in the constructors. Use ClassLoader's parent property. Advantages: IMHO, the cleanest solution. Disadvantages: Many build brakes. Fazit: Not usable 2. Provide a "special" getter like getRealParent() Advantages: works with existing environments. Disadvantages: such a shame Fazit: No better way !? Any other idea? Regards Rainer
This will be fixed in ant 1.7. I have added a new constructor to set the parent classloader and made all the other constructors deprecated. I have not converted all uses to use the new constructor (since some of them do strange things), however I have modifed the setParent() to use reflection to attempt to set the private field of the super class to the new parent.
The change had to be reverted as it did work for java 1.4 and lower. In java 5, ClassLoader.getResources() is protected, in java 1.4, it is private.
(In reply to comment #2) > The change had to be reverted as it did work > for java 1.4 and lower. > > In java 5, ClassLoader.getResources() is protected, > in java 1.4, it is private. > Can Dale Anson's "object rape" technique (see ac Variable task) be used here?
No, one would have to change the class itself, not the use of the class. Well.., we could do this, but it would mess up the JDK rt.jar file..... Users call classloader.getResources() to get the resources. As ClassLoader.getResources() is final in java 1.4 (but not in java 5), AntClassLoader cannot have a getResources() method. It has to fake the getResources by not having a parent as seen by ClassLoader.getResources().
Opps, hit the wrong button... reopen
*** This bug has been marked as a duplicate of bug 46759 ***
the getResources issue is fixed in the Java5 case now. I don't think we would achieve much by setting ClassLoader.parent since we'd still have to deal with parentFirst and setIsolated in a way incompatible with the base implementation. In order to close this issue I've simply added a getConfiguredParent method in svn revision 796649