ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Magesh Umasankar" <umag...@apache.org>
Subject Re: addXXX related question
Date Sun, 03 Mar 2002 18:32:30 GMT
From: "Magesh Umasankar" <umagesh@apache.org>

> From: "Peter Donald" <peter@apache.org>
>
> > 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:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message