Stephen, et al,

I'm not sure I understand what you mean by "no need to do the String 
searching based on field name", but my timing tests eliminated the 
lookup of the Field/Method object and were isolated to just a comparison 
of the execution times between my getValue(Object) and 
java.lang.reflect.Field's get(Object) and Method's invoke(...).  (In our 
system, we only do the lookup once and cache the result in a way that's 
fast for what we're doing.)

Note that I never took the time to test my setValue() vs. the equivalent 
for Field/Method, but I suspect a similar performance gain would have 
been observed, especially since my api doesn't require you to cons up an 
Object[] arglist to pass to the Method.

BTW, I have heard a rumor that, in jdk1.4, they have sped up reflection 
by doing pretty much what I'm doing -- dynamically create a Class with 
dedicated bytecode in it to access the Field/Method.  Of course, my 
approach is limited to setters/getters so will always be faster than the 
more general solution, but only marginally so in the future.  
Furthermore, I can only access public members, which was the original 
thrust of this thread.

On that topic, should I give up trying to emulate AccessibleObject?  
Nobody here seems to have a suggestion for how to defeat the 
IllegalAccessViolation exceptions.

Thanks,
Charles.


On Saturday, May 18, 2002, at 02:11  AM, Stephen Colebourne wrote:

> I too am intrigued by this thread. At the Joda project, we have 
> implemented
> something which I think is kind of similar. We have a 'Property' 
> interface
> which has set(Object) and toObject() methods, similar to the setValue 
> and
> getValue methods in the example below. The difference is that the 
> Property
> object stores a reference to the Bean it belongs to, whereas in the 
> example
> below the target is passed in. The Joda code is all Java - at present.
>
> I am guessing the speed up comes because there is no need to do the 
> String
> searching based on field name. The BCEL coding will have 'dynamically 
> hard
> coded' the Field object.
>
[snip]


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to