|
From: James N. <jam...@ya...> - 2002-01-08 22:53:42
|
> >> Pros:
> >> - We will save a pointer for each instance of PyInstance and
> >> PyJavaInstance and an instance of a CollectionProxy for each Vector,
> >> Hashtable, Map, etc.
> >>
> >> Cons:
> >> - A serie of instanceof operations is necessary every time one of
> >> the sequence method is called on a java instance.
> >
> >I would think it would be more straight forward to keep the
> >CollectionProxy's as they are now even though it requires an extra
> >instance. While the number of Collection classes is small it still
> >*feels* better to avoid a big if block of instanceof calls.
>
> It would be the same two blocks of instanceof operations that you can
> already find in CollectionProxy*.java. I suggest that we execute these 5
> if statement for each __len__ and __XXXitem__ call on a java class,
> instead of executing it just once for each java class and storing the
> result. The java2 "if" statements would still be located in
> CollectionProxy2.
sounds like the proposed good ideas are worthy and the idea's proposed
implementation is awkward.
consider that the great majority of reflection api is native code and the
blind fragment:
try{
o.getClass().getMethod(...).invoke(...)
}catch(...){...}
is niether unmaintainable nor performance hindered.
a registry can be built on-the-fly per container class which then houses a
few methods which are thereafter simply plugged with (instance, Object[])
parms
classnames and classloaders are going to be final strings. thus the
registry, a final static hashmap, would be as good as it gets, and meet the
criterion of stomping blocks of comparison.
given that there is 1 Arrays, 1 collection, 1 map, 1 iterator (2 counting
ListIterator), and 1 enumeration class, i can see no cause for writing
per-instance proxies and I question the necesity of per-class proxies. this
is as orthogonal as java gets and if we perchance write a single final proxy
class with orthoganal method calls in mind and the occasional random
reflection probe to categorize a new class entry into its behavior family,
all is well ever after.
no instanceof calls? no per-object proxy? what if someone calls the wrong
reflection method on our container object? we let java throw what it will.
I qualify this hint by adding that I know nothing about jython collections
and proxies and everything about ripping out blocks of comparisons and
replacing them with factory/registry reflection code.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
|