[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Objects versus proxies



Hi!

I'm getting a ClassCastException which doesn't make sense. Basically I
have one database object which creates database objects of two other
classes and then passes on of these to the other as a parameter of a
method. The method call throws a ClassCastException referencing the
Proxy for the parameter.

OK. I have an object, dbObj1, with a default constructor and a method.
The client app calls createObject(dbObj1) and then the method.
 Method is like this:
blah, blah
try {
Interface2 varDbObj2 = (Interface2)
database().createObject(class_DbObj2);
varDbObj2.someMethod_update(); // no params

Interface3 varDbObj3 = (Interface3)
database().createObject(class_DbObj3);
varDbObj3.init_update(String, String); // so the strings become
persistent members of the dbObj3

varDbObj2.add_update(varDbObj3); // throws UnexpectedException
}

The UnexpectedException is: ClassCastException class_DbObj3_Proxy
at class_DbObj2_Proxy.add_update
at class_DbObj1.Method

The the add method is:
public void add_update(Interface3 anObj) {
someCollection.add(obj);
// other stuff
}

But class_DbObj3, varDbObj3 and classDbObj3_Proxy all implement
Interface 3, so why do I get a class cast exception?

Thanks,

Charles