|
From: Sharif J. A. <sja...@ya...> - 2004-01-22 20:24:28
|
Hi,
I checked my sublcass and it turns out that I do have the order of the
methods listed as you suggested:
get(Object key) { ...}
get(int key) { ... }
I'm sure if this is the root cause of not, but the problem appears to be in
the MethodAccessor class defined in PropertyOperatorCache.java. I've
included the relevant portion for your reference:
abstract class MethodAccessor extends Accessor {
protected Method _getMethod; // only one get method allowed
private Method[] _setMethods = null; // may be multiple set methods
private Class[] _setParams = null; // variable arg type for set meth N
.....
final void addMethod(final Method m, Class[] params)
throws PropertyException {
final int setArgsLength = numArgsSet();
final int getArgsLength = numArgsGet();
if (params.length == getArgsLength) {
_getMethod = m;
}
else if (params.length == setArgsLength) {
setCount++;
if (_setMethods == null) {
....
-Sharif
--- Keats <ke...@xa...> wrote:
> Sharif,
>
> I believe there is a minor introspection problem with WM if your method has
> a "get(<primitive-type>)" declared before the "get(Object)" method. You
> should be able to fix your problem by reordering your methods. For
> example,
> import java.util.Hashtable;
> public class CustomMap extends Hashtable {
> public Object get(Object key) {
> System.out.println("CustomMap.get(Object) called with: " + key);
> return super.get(key);
> }
> public Object get(int key) {
> System.out.println("CustomMap.get(int) called with: " + key);
> return super.get(new Integer(key));
> }
> }
>
> Works, whereas:
> import java.util.Hashtable;
> public class CustomMap extends Hashtable {
> public Object get(int key) {
> System.out.println("CustomMap.get(int) called with: " + key);
> return super.get(new Integer(key));
> }
> public Object get(Object key) {
> System.out.println("CustomMap.get(Object) called with: " + key);
> return super.get(key);
> }
> }
>
> fails.
>
> I looked into fixing this a couple of years ago, but for some reason
> decided
> it wasn't worth it. I could look into it again if folks think it's a big
> deal.
>
> Keats
>
> ----- Original Message -----
> From: "Sharif J. Alexandre" <sja...@ya...>
> To: <web...@li...>
> Sent: Saturday, January 17, 2004 6:31 PM
> Subject: [Webmacro-devel] bug or feature?
>
>
> > Hi,
> >
> > I have an object that extends a Hashtable and overloads the get() method
> with
> > a get(int). When I place this object into a Context, I get an error when
> any
> > of the entries in that object are accessed. Here's a portion of that
> error:
> >
> > org.webmacro.PropertyException: Some kind of error occurred processing
> your
> > request: this indicates a failure in PropertyOperator.java that should be
> > reported: attempt to access method public java.lang.Object
> > org.dbadmin.util.MyMap.get(int) on object {systemDate=Jan 17, 2004
> 5:31:47
> > PM} with 1 parameters threw an exception:
> > java.lang.IllegalArgumentException: argument type mismatch
> >
> > I did some digging and found that in engine/PropertyOperatorCache.java a
> > MethodAccessor class is defined which only allows one get method (I'm
> using
> > 1.1 final). Is there a reason for this? Shouldn't it be possible to
> include
> > any object in a Context -- even if it's a subclassed Hashtable?
> >
> > Thanks,
> > Sharif
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> >
> >
> > -------------------------------------------------------
> > The SF.Net email is sponsored by EclipseCon 2004
> > Premiere Conference on Open Tools Development and Integration
> > See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> > http://www.eclipsecon.org/osdn
> > _______________________________________________
> > Webmacro-devel mailing list
> > Web...@li...
> > https://lists.sourceforge.net/lists/listinfo/webmacro-devel
> >
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/
|