The Artima Developer Community
Sponsored Link

Legacy Design Forum
Canonical Object Idiom

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Don't Forget Namespaces

Posted by Bill Venners on February 28, 2000 at 2:01 PM

Dave,

> > I think the class of both objects must be the same, which
> > none of these approaches are checking for. I'll post again
> > with a way to do that. And, I'll change the idiom to match.
> > Any ideas yourself?

> Exactly. You need to check if the class names of both classes are the same. The class name is specific to the actual object, irrespective of subtyping. Any type of casting (whether done with explicit casting or testing with instanceof) allows subtypes to get "through the screen" if you will. For instance, the following will get through:

We can't just check the class names, though, because a VM
can load multiple classes of the same name with different
class loaders. (Each class loader maintains its own namespace.)
We'll have to check to see if the Class instances for the
two objects are identical.

bv





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us