| 
      
      
      From: Gavin_King/Cirrus%<CI...@ci...> - 2002-02-04 10:42:34
      
     | 
| 
Actually instanceof will still work. For example:
class Foo implements Persistent {
  String name;
  String id;
  String getName() {..}
  void setName(String name) { ...}
  String getID() { ....}
  void setID(String id) { .... }
  ......
}
Foo has the proxy subclass FooProx (not strictly a proxy cos its not really
using delegation)
FooProx extends Foo {
  String getName() { ....; return super.getName(); }
  void setName(String name) { ...; super.setName(name) }
  String getID() { ....; return super.getID(); }
  void setID(String id) { ....; super.setID(id); }
}
so an instance of FooProx is also an instance of Foo. So instanceof works
fine. also Foo.class.isAssignableFrom( foo.getClass() ) works.
foo.getClass().isAssignableFrom( Foo.class ) breaks but i think thats the
less important case. Actually def less important.
reflection still works .... you will get a different bunch of methods but
they do the right thing.....
foo.getClass()==Foo.class breaks ... thats kind of nasty ... could break
equals(). But then the proxies might even be smart enough to do something
special in the case of equals.
foo.getClass.getName() breaks...
notify(), wait() and synchronized() all work (they wouldnt if you were
using seperate wrapper objects.
most importantly == works which it wouldn't if you use seperate wrapper
objects that delegate.
Actually the reason all this is okay is because we are using polymorphism
which is fundamentally OO. So basically the only real problem is getClass()
and that only because its declared final on Object.
 |