[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
finding method efficiently
From: |
Robert Schuster |
Subject: |
finding method efficiently |
Date: |
Tue, 28 Sep 2004 02:06:07 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.2) Gecko/20040819 |
Hi Classpath hackers,
I am currently implementing java.beans.XMLDecoder which now starts to
work. But I have a small (efficiency) problem.
As you might know the decoder accepts XML data like this:
<object class="java.awt.Point">
<int>12</int>
<int>43</int>
</object>
and executes this using reflection as if I had written: new Point(12, 43).
Now something more complicated:
<object class="java.util.HashMap">
<void method="put">
<string>someId</string>
<object class="javax.swing.JFrame"/>
</void>
</object>
This is equivalent to:
m = new HashMap();
m.put("someId", new JFrame());
(variable m is not needed in XML version)
Now when evaluating the XML data I have to search the method "put" which
accepts the two arguments. Having
only String and JFrame as argument types means that the call to
HashMap.class.getMethod("put", new Class[] { String.class,
JFrame.class });
will fail. My current naive approach to find HashMap.put(Object, Object)
is to generate a long list of a superclasses and
interfaces of all arguments and then calling getMethod("put", ..) with
every combination. It should be clear that
performance is not on my side when doing this.
My question is: Is there anything I can do to make this more efficient?
cu
Robert
- finding method efficiently,
Robert Schuster <=
- Re: finding method efficiently, Tom Tromey, 2004/09/28
- RE: finding method efficiently, David Holmes, 2004/09/28
- Re: finding method efficiently, Tom Tromey, 2004/09/28
- RE: finding method efficiently, David Holmes, 2004/09/28
- Re: finding method efficiently, Archie Cobbs, 2004/09/28
- Re: finding method efficiently, Tom Tromey, 2004/09/28
- Re: finding method efficiently, Robert Schuster, 2004/09/28
- Re: finding method efficiently, Artur Biesiadowski, 2004/09/28