This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] java.beans.EventHandler


Hi Jerry,

Jerry Quinn wrote:

+ // Obtain the property XXX propertyType keeps showing up null - why?
+ // because the object inside getProperty changes, but the ref variable
+ // can't change this way, dolt! need a better way to get both values out
+ // - need method and object to do the invoke and get return type
+ Object v[] = getProperty(event, property);
+ Object val = v[0];
+ Class propertyType = (Class) v[1];
+
+ System.out.println("ptype="+propertyType.getName());
+ System.out.println(" val="+((val==null)?"null":val.toString()));


Presumably these are left-overs from debugging and should be removed?

+ // Find the actual method of target to invoke. We can't do this in the
+ // constructor since we don't know the type of the property we extracted
+ // from the event then.
+ //
+ // action can be either a property or a method. Sun's docs seem to imply
+ // that action should be treated as a property first, and then a method,
+ // but don't specifically say it.
+ //
+ // XXX check what happens with native type wrappers. The better thing to
+ // do is look at the return type of the method
+ Method actionMethod;
+ try
+ {
+ // Look for a property setter for action.
+ actionMethod =
+ target.getClass().getMethod("set" + capitalize(action),
+ new Class[] {propertyType});
+ }



It would be much faster to look up the actionMethod once when the EventHandler is constructed, and cache it, rather than looking it up again during every dispatch. Looking up methods can be quite slow, plus you'll avoid several allocations.


Otherwise, this looks good.

Regards

Bryce


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]