Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 18711 invoked from network); 3 Mar 2002 18:24:26 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 3 Mar 2002 18:24:26 -0000 Received: (qmail 2180 invoked by uid 97); 3 Mar 2002 18:24:25 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 2164 invoked by uid 97); 3 Mar 2002 18:24:25 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 2153 invoked from network); 3 Mar 2002 18:24:24 -0000 Message-ID: <015201c1c2e1$c991f2e0$9640d6d1@compaq> From: "Magesh Umasankar" To: "Ant Developers List" References: <011201c1c292$374ea800$9640d6d1@compaq> <200203030914.g239EKU30793@mail004.syd.optusnet.com.au> <014801c1c2d8$715365e0$9640d6d1@compaq> Subject: Re: addXXX related question Date: Sun, 3 Mar 2002 13:32:30 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N From: "Magesh Umasankar" > From: "Peter Donald" > > > On Sun, 3 Mar 2002 20:02, Magesh Umasankar wrote: > > > The problem seems to be in IntrospectionHelper/ > > > ProjectHelper. If the method name begins with > > > "add", IntrospectionHelper requires to be able to > > > create an instance of the argument, whether > > > it is used as an element in the build file or not. > > > If it does not find the class, it throws a > > > NoClassDefFoundError. > > > > It is a feature of classloading. When you define the FilterChain class you > > need to able to define all classes it uses - > > I should be able to define all classes it uses, yes. But > why should I be forced to be able to instantiate them? > > > when you use reflection you > > force the class to be fully defined. Thus it will try to load BCEL anytime > > you perform reflection on FilterChain. > > FilterChain uses ClassConstants - that is all. It doesn't > know about bcel until it tries to instantiate ClassConstants... > Why should it be trying to instantiate elements that have > not been added in the build file. From the code, I see that > each "add" method's element's constructor is obtained > and an object of the class created. I still do not understand > the reason behind this... > > > > > A way around this would to provide an interface+wrapper type system. Take > a > > look at how the mappers or regex objects behave to see what I mean. > > > > Yes, seems like a wrapper would be needed... But still, > why the extra layer? Or am I totally missing something? > > > > > Pete > > > When I apply this patch (perhaps a bit hackish...), I can work around the problem and everything works as I expect it to... Please let me know if I can go ahead and apply this patch against the main tree... Index: IntrospectionHelper.java =================================================================== RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/IntrospectionHelper.java ,v retrieving revision 1.37 diff -u -w -r1.37 IntrospectionHelper.java --- IntrospectionHelper.java 24 Feb 2002 08:57:02 -0000 1.37 +++ IntrospectionHelper.java 3 Mar 2002 18:21:25 -0000 @@ -348,6 +348,16 @@ }); nestedStorers.remove(name); } catch (NoSuchMethodException nse) { + } catch (NoClassDefFoundError ncdfe) { + String propName = getPropertyName(name, "add"); + nestedTypes.put(propName, args[0]); + nestedCreators.put(propName, new NestedCreator() { + public Object create(Object parent) { + return new Object(); + } + + }); + nestedStorers.remove(name); } } } > Magesh > Cheers, Magesh -- To unsubscribe, e-mail: For additional commands, e-mail: